babylon.module.d.ts 4.8 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module "babylonjs/Misc/arrayTools" {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module "babylonjs/Maths/math.scalar" {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module "babylonjs/Maths/math" {
  256. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  257. /**
  258. * Constant used to convert a value to gamma space
  259. * @ignorenaming
  260. */
  261. export const ToGammaSpace: number;
  262. /**
  263. * Constant used to convert a value to linear space
  264. * @ignorenaming
  265. */
  266. export const ToLinearSpace = 2.2;
  267. /**
  268. * Constant used to define the minimal number value in Babylon.js
  269. * @ignorenaming
  270. */
  271. export const Epsilon = 0.001;
  272. /**
  273. * Class used to hold a RBG color
  274. */
  275. export class Color3 {
  276. /**
  277. * Defines the red component (between 0 and 1, default is 0)
  278. */
  279. r: number;
  280. /**
  281. * Defines the green component (between 0 and 1, default is 0)
  282. */
  283. g: number;
  284. /**
  285. * Defines the blue component (between 0 and 1, default is 0)
  286. */
  287. b: number;
  288. /**
  289. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  290. * @param r defines the red component (between 0 and 1, default is 0)
  291. * @param g defines the green component (between 0 and 1, default is 0)
  292. * @param b defines the blue component (between 0 and 1, default is 0)
  293. */
  294. constructor(
  295. /**
  296. * Defines the red component (between 0 and 1, default is 0)
  297. */
  298. r?: number,
  299. /**
  300. * Defines the green component (between 0 and 1, default is 0)
  301. */
  302. g?: number,
  303. /**
  304. * Defines the blue component (between 0 and 1, default is 0)
  305. */
  306. b?: number);
  307. /**
  308. * Creates a string with the Color3 current values
  309. * @returns the string representation of the Color3 object
  310. */
  311. toString(): string;
  312. /**
  313. * Returns the string "Color3"
  314. * @returns "Color3"
  315. */
  316. getClassName(): string;
  317. /**
  318. * Compute the Color3 hash code
  319. * @returns an unique number that can be used to hash Color3 objects
  320. */
  321. getHashCode(): number;
  322. /**
  323. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  324. * @param array defines the array where to store the r,g,b components
  325. * @param index defines an optional index in the target array to define where to start storing values
  326. * @returns the current Color3 object
  327. */
  328. toArray(array: FloatArray, index?: number): Color3;
  329. /**
  330. * Returns a new Color4 object from the current Color3 and the given alpha
  331. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  332. * @returns a new Color4 object
  333. */
  334. toColor4(alpha?: number): Color4;
  335. /**
  336. * Returns a new array populated with 3 numeric elements : red, green and blue values
  337. * @returns the new array
  338. */
  339. asArray(): number[];
  340. /**
  341. * Returns the luminance value
  342. * @returns a float value
  343. */
  344. toLuminance(): number;
  345. /**
  346. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  347. * @param otherColor defines the second operand
  348. * @returns the new Color3 object
  349. */
  350. multiply(otherColor: DeepImmutable<Color3>): Color3;
  351. /**
  352. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  353. * @param otherColor defines the second operand
  354. * @param result defines the Color3 object where to store the result
  355. * @returns the current Color3
  356. */
  357. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  358. /**
  359. * Determines equality between Color3 objects
  360. * @param otherColor defines the second operand
  361. * @returns true if the rgb values are equal to the given ones
  362. */
  363. equals(otherColor: DeepImmutable<Color3>): boolean;
  364. /**
  365. * Determines equality between the current Color3 object and a set of r,b,g values
  366. * @param r defines the red component to check
  367. * @param g defines the green component to check
  368. * @param b defines the blue component to check
  369. * @returns true if the rgb values are equal to the given ones
  370. */
  371. equalsFloats(r: number, g: number, b: number): boolean;
  372. /**
  373. * Multiplies in place each rgb value by scale
  374. * @param scale defines the scaling factor
  375. * @returns the updated Color3
  376. */
  377. scale(scale: number): Color3;
  378. /**
  379. * Multiplies the rgb values by scale and stores the result into "result"
  380. * @param scale defines the scaling factor
  381. * @param result defines the Color3 object where to store the result
  382. * @returns the unmodified current Color3
  383. */
  384. scaleToRef(scale: number, result: Color3): Color3;
  385. /**
  386. * Scale the current Color3 values by a factor and add the result to a given Color3
  387. * @param scale defines the scale factor
  388. * @param result defines color to store the result into
  389. * @returns the unmodified current Color3
  390. */
  391. scaleAndAddToRef(scale: number, result: Color3): Color3;
  392. /**
  393. * Clamps the rgb values by the min and max values and stores the result into "result"
  394. * @param min defines minimum clamping value (default is 0)
  395. * @param max defines maximum clamping value (default is 1)
  396. * @param result defines color to store the result into
  397. * @returns the original Color3
  398. */
  399. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  400. /**
  401. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  402. * @param otherColor defines the second operand
  403. * @returns the new Color3
  404. */
  405. add(otherColor: DeepImmutable<Color3>): Color3;
  406. /**
  407. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  408. * @param otherColor defines the second operand
  409. * @param result defines Color3 object to store the result into
  410. * @returns the unmodified current Color3
  411. */
  412. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  413. /**
  414. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  415. * @param otherColor defines the second operand
  416. * @returns the new Color3
  417. */
  418. subtract(otherColor: DeepImmutable<Color3>): Color3;
  419. /**
  420. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  421. * @param otherColor defines the second operand
  422. * @param result defines Color3 object to store the result into
  423. * @returns the unmodified current Color3
  424. */
  425. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  426. /**
  427. * Copy the current object
  428. * @returns a new Color3 copied the current one
  429. */
  430. clone(): Color3;
  431. /**
  432. * Copies the rgb values from the source in the current Color3
  433. * @param source defines the source Color3 object
  434. * @returns the updated Color3 object
  435. */
  436. copyFrom(source: DeepImmutable<Color3>): Color3;
  437. /**
  438. * Updates the Color3 rgb values from the given floats
  439. * @param r defines the red component to read from
  440. * @param g defines the green component to read from
  441. * @param b defines the blue component to read from
  442. * @returns the current Color3 object
  443. */
  444. copyFromFloats(r: number, g: number, b: number): Color3;
  445. /**
  446. * Updates the Color3 rgb values from the given floats
  447. * @param r defines the red component to read from
  448. * @param g defines the green component to read from
  449. * @param b defines the blue component to read from
  450. * @returns the current Color3 object
  451. */
  452. set(r: number, g: number, b: number): Color3;
  453. /**
  454. * Compute the Color3 hexadecimal code as a string
  455. * @returns a string containing the hexadecimal representation of the Color3 object
  456. */
  457. toHexString(): string;
  458. /**
  459. * Computes a new Color3 converted from the current one to linear space
  460. * @returns a new Color3 object
  461. */
  462. toLinearSpace(): Color3;
  463. /**
  464. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  465. * @param convertedColor defines the Color3 object where to store the linear space version
  466. * @returns the unmodified Color3
  467. */
  468. toLinearSpaceToRef(convertedColor: Color3): Color3;
  469. /**
  470. * Computes a new Color3 converted from the current one to gamma space
  471. * @returns a new Color3 object
  472. */
  473. toGammaSpace(): Color3;
  474. /**
  475. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  476. * @param convertedColor defines the Color3 object where to store the gamma space version
  477. * @returns the unmodified Color3
  478. */
  479. toGammaSpaceToRef(convertedColor: Color3): Color3;
  480. private static _BlackReadOnly;
  481. /**
  482. * Creates a new Color3 from the string containing valid hexadecimal values
  483. * @param hex defines a string containing valid hexadecimal values
  484. * @returns a new Color3 object
  485. */
  486. static FromHexString(hex: string): Color3;
  487. /**
  488. * Creates a new Vector3 from the starting index of the given array
  489. * @param array defines the source array
  490. * @param offset defines an offset in the source array
  491. * @returns a new Color3 object
  492. */
  493. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  494. /**
  495. * Creates a new Color3 from integer values (< 256)
  496. * @param r defines the red component to read from (value between 0 and 255)
  497. * @param g defines the green component to read from (value between 0 and 255)
  498. * @param b defines the blue component to read from (value between 0 and 255)
  499. * @returns a new Color3 object
  500. */
  501. static FromInts(r: number, g: number, b: number): Color3;
  502. /**
  503. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  504. * @param start defines the start Color3 value
  505. * @param end defines the end Color3 value
  506. * @param amount defines the gradient value between start and end
  507. * @returns a new Color3 object
  508. */
  509. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  510. /**
  511. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  512. * @param left defines the start value
  513. * @param right defines the end value
  514. * @param amount defines the gradient factor
  515. * @param result defines the Color3 object where to store the result
  516. */
  517. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  518. /**
  519. * Returns a Color3 value containing a red color
  520. * @returns a new Color3 object
  521. */
  522. static Red(): Color3;
  523. /**
  524. * Returns a Color3 value containing a green color
  525. * @returns a new Color3 object
  526. */
  527. static Green(): Color3;
  528. /**
  529. * Returns a Color3 value containing a blue color
  530. * @returns a new Color3 object
  531. */
  532. static Blue(): Color3;
  533. /**
  534. * Returns a Color3 value containing a black color
  535. * @returns a new Color3 object
  536. */
  537. static Black(): Color3;
  538. /**
  539. * Gets a Color3 value containing a black color that must not be updated
  540. */
  541. static readonly BlackReadOnly: DeepImmutable<Color3>;
  542. /**
  543. * Returns a Color3 value containing a white color
  544. * @returns a new Color3 object
  545. */
  546. static White(): Color3;
  547. /**
  548. * Returns a Color3 value containing a purple color
  549. * @returns a new Color3 object
  550. */
  551. static Purple(): Color3;
  552. /**
  553. * Returns a Color3 value containing a magenta color
  554. * @returns a new Color3 object
  555. */
  556. static Magenta(): Color3;
  557. /**
  558. * Returns a Color3 value containing a yellow color
  559. * @returns a new Color3 object
  560. */
  561. static Yellow(): Color3;
  562. /**
  563. * Returns a Color3 value containing a gray color
  564. * @returns a new Color3 object
  565. */
  566. static Gray(): Color3;
  567. /**
  568. * Returns a Color3 value containing a teal color
  569. * @returns a new Color3 object
  570. */
  571. static Teal(): Color3;
  572. /**
  573. * Returns a Color3 value containing a random color
  574. * @returns a new Color3 object
  575. */
  576. static Random(): Color3;
  577. }
  578. /**
  579. * Class used to hold a RBGA color
  580. */
  581. export class Color4 {
  582. /**
  583. * Defines the red component (between 0 and 1, default is 0)
  584. */
  585. r: number;
  586. /**
  587. * Defines the green component (between 0 and 1, default is 0)
  588. */
  589. g: number;
  590. /**
  591. * Defines the blue component (between 0 and 1, default is 0)
  592. */
  593. b: number;
  594. /**
  595. * Defines the alpha component (between 0 and 1, default is 1)
  596. */
  597. a: number;
  598. /**
  599. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  600. * @param r defines the red component (between 0 and 1, default is 0)
  601. * @param g defines the green component (between 0 and 1, default is 0)
  602. * @param b defines the blue component (between 0 and 1, default is 0)
  603. * @param a defines the alpha component (between 0 and 1, default is 1)
  604. */
  605. constructor(
  606. /**
  607. * Defines the red component (between 0 and 1, default is 0)
  608. */
  609. r?: number,
  610. /**
  611. * Defines the green component (between 0 and 1, default is 0)
  612. */
  613. g?: number,
  614. /**
  615. * Defines the blue component (between 0 and 1, default is 0)
  616. */
  617. b?: number,
  618. /**
  619. * Defines the alpha component (between 0 and 1, default is 1)
  620. */
  621. a?: number);
  622. /**
  623. * Adds in place the given Color4 values to the current Color4 object
  624. * @param right defines the second operand
  625. * @returns the current updated Color4 object
  626. */
  627. addInPlace(right: DeepImmutable<Color4>): Color4;
  628. /**
  629. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  630. * @returns the new array
  631. */
  632. asArray(): number[];
  633. /**
  634. * Stores from the starting index in the given array the Color4 successive values
  635. * @param array defines the array where to store the r,g,b components
  636. * @param index defines an optional index in the target array to define where to start storing values
  637. * @returns the current Color4 object
  638. */
  639. toArray(array: number[], index?: number): Color4;
  640. /**
  641. * Determines equality between Color4 objects
  642. * @param otherColor defines the second operand
  643. * @returns true if the rgba values are equal to the given ones
  644. */
  645. equals(otherColor: DeepImmutable<Color4>): boolean;
  646. /**
  647. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  648. * @param right defines the second operand
  649. * @returns a new Color4 object
  650. */
  651. add(right: DeepImmutable<Color4>): Color4;
  652. /**
  653. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  654. * @param right defines the second operand
  655. * @returns a new Color4 object
  656. */
  657. subtract(right: DeepImmutable<Color4>): Color4;
  658. /**
  659. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  660. * @param right defines the second operand
  661. * @param result defines the Color4 object where to store the result
  662. * @returns the current Color4 object
  663. */
  664. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  665. /**
  666. * Creates a new Color4 with the current Color4 values multiplied by scale
  667. * @param scale defines the scaling factor to apply
  668. * @returns a new Color4 object
  669. */
  670. scale(scale: number): Color4;
  671. /**
  672. * Multiplies the current Color4 values by scale and stores the result in "result"
  673. * @param scale defines the scaling factor to apply
  674. * @param result defines the Color4 object where to store the result
  675. * @returns the current unmodified Color4
  676. */
  677. scaleToRef(scale: number, result: Color4): Color4;
  678. /**
  679. * Scale the current Color4 values by a factor and add the result to a given Color4
  680. * @param scale defines the scale factor
  681. * @param result defines the Color4 object where to store the result
  682. * @returns the unmodified current Color4
  683. */
  684. scaleAndAddToRef(scale: number, result: Color4): Color4;
  685. /**
  686. * Clamps the rgb values by the min and max values and stores the result into "result"
  687. * @param min defines minimum clamping value (default is 0)
  688. * @param max defines maximum clamping value (default is 1)
  689. * @param result defines color to store the result into.
  690. * @returns the cuurent Color4
  691. */
  692. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  693. /**
  694. * Multipy an Color4 value by another and return a new Color4 object
  695. * @param color defines the Color4 value to multiply by
  696. * @returns a new Color4 object
  697. */
  698. multiply(color: Color4): Color4;
  699. /**
  700. * Multipy a Color4 value by another and push the result in a reference value
  701. * @param color defines the Color4 value to multiply by
  702. * @param result defines the Color4 to fill the result in
  703. * @returns the result Color4
  704. */
  705. multiplyToRef(color: Color4, result: Color4): Color4;
  706. /**
  707. * Creates a string with the Color4 current values
  708. * @returns the string representation of the Color4 object
  709. */
  710. toString(): string;
  711. /**
  712. * Returns the string "Color4"
  713. * @returns "Color4"
  714. */
  715. getClassName(): string;
  716. /**
  717. * Compute the Color4 hash code
  718. * @returns an unique number that can be used to hash Color4 objects
  719. */
  720. getHashCode(): number;
  721. /**
  722. * Creates a new Color4 copied from the current one
  723. * @returns a new Color4 object
  724. */
  725. clone(): Color4;
  726. /**
  727. * Copies the given Color4 values into the current one
  728. * @param source defines the source Color4 object
  729. * @returns the current updated Color4 object
  730. */
  731. copyFrom(source: Color4): Color4;
  732. /**
  733. * Copies the given float values into the current one
  734. * @param r defines the red component to read from
  735. * @param g defines the green component to read from
  736. * @param b defines the blue component to read from
  737. * @param a defines the alpha component to read from
  738. * @returns the current updated Color4 object
  739. */
  740. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  741. /**
  742. * Copies the given float values into the current one
  743. * @param r defines the red component to read from
  744. * @param g defines the green component to read from
  745. * @param b defines the blue component to read from
  746. * @param a defines the alpha component to read from
  747. * @returns the current updated Color4 object
  748. */
  749. set(r: number, g: number, b: number, a: number): Color4;
  750. /**
  751. * Compute the Color4 hexadecimal code as a string
  752. * @returns a string containing the hexadecimal representation of the Color4 object
  753. */
  754. toHexString(): string;
  755. /**
  756. * Computes a new Color4 converted from the current one to linear space
  757. * @returns a new Color4 object
  758. */
  759. toLinearSpace(): Color4;
  760. /**
  761. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  762. * @param convertedColor defines the Color4 object where to store the linear space version
  763. * @returns the unmodified Color4
  764. */
  765. toLinearSpaceToRef(convertedColor: Color4): Color4;
  766. /**
  767. * Computes a new Color4 converted from the current one to gamma space
  768. * @returns a new Color4 object
  769. */
  770. toGammaSpace(): Color4;
  771. /**
  772. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  773. * @param convertedColor defines the Color4 object where to store the gamma space version
  774. * @returns the unmodified Color4
  775. */
  776. toGammaSpaceToRef(convertedColor: Color4): Color4;
  777. /**
  778. * Creates a new Color4 from the string containing valid hexadecimal values
  779. * @param hex defines a string containing valid hexadecimal values
  780. * @returns a new Color4 object
  781. */
  782. static FromHexString(hex: string): Color4;
  783. /**
  784. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  785. * @param left defines the start value
  786. * @param right defines the end value
  787. * @param amount defines the gradient factor
  788. * @returns a new Color4 object
  789. */
  790. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  791. /**
  792. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  793. * @param left defines the start value
  794. * @param right defines the end value
  795. * @param amount defines the gradient factor
  796. * @param result defines the Color4 object where to store data
  797. */
  798. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  799. /**
  800. * Creates a new Color4 from a Color3 and an alpha value
  801. * @param color3 defines the source Color3 to read from
  802. * @param alpha defines the alpha component (1.0 by default)
  803. * @returns a new Color4 object
  804. */
  805. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  806. /**
  807. * Creates a new Color4 from the starting index element of the given array
  808. * @param array defines the source array to read from
  809. * @param offset defines the offset in the source array
  810. * @returns a new Color4 object
  811. */
  812. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  813. /**
  814. * Creates a new Color3 from integer values (< 256)
  815. * @param r defines the red component to read from (value between 0 and 255)
  816. * @param g defines the green component to read from (value between 0 and 255)
  817. * @param b defines the blue component to read from (value between 0 and 255)
  818. * @param a defines the alpha component to read from (value between 0 and 255)
  819. * @returns a new Color3 object
  820. */
  821. static FromInts(r: number, g: number, b: number, a: number): Color4;
  822. /**
  823. * Check the content of a given array and convert it to an array containing RGBA data
  824. * If the original array was already containing count * 4 values then it is returned directly
  825. * @param colors defines the array to check
  826. * @param count defines the number of RGBA data to expect
  827. * @returns an array containing count * 4 values (RGBA)
  828. */
  829. static CheckColors4(colors: number[], count: number): number[];
  830. }
  831. /**
  832. * Class representing a vector containing 2 coordinates
  833. */
  834. export class Vector2 {
  835. /** defines the first coordinate */
  836. x: number;
  837. /** defines the second coordinate */
  838. y: number;
  839. /**
  840. * Creates a new Vector2 from the given x and y coordinates
  841. * @param x defines the first coordinate
  842. * @param y defines the second coordinate
  843. */
  844. constructor(
  845. /** defines the first coordinate */
  846. x?: number,
  847. /** defines the second coordinate */
  848. y?: number);
  849. /**
  850. * Gets a string with the Vector2 coordinates
  851. * @returns a string with the Vector2 coordinates
  852. */
  853. toString(): string;
  854. /**
  855. * Gets class name
  856. * @returns the string "Vector2"
  857. */
  858. getClassName(): string;
  859. /**
  860. * Gets current vector hash code
  861. * @returns the Vector2 hash code as a number
  862. */
  863. getHashCode(): number;
  864. /**
  865. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  866. * @param array defines the source array
  867. * @param index defines the offset in source array
  868. * @returns the current Vector2
  869. */
  870. toArray(array: FloatArray, index?: number): Vector2;
  871. /**
  872. * Copy the current vector to an array
  873. * @returns a new array with 2 elements: the Vector2 coordinates.
  874. */
  875. asArray(): number[];
  876. /**
  877. * Sets the Vector2 coordinates with the given Vector2 coordinates
  878. * @param source defines the source Vector2
  879. * @returns the current updated Vector2
  880. */
  881. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  882. /**
  883. * Sets the Vector2 coordinates with the given floats
  884. * @param x defines the first coordinate
  885. * @param y defines the second coordinate
  886. * @returns the current updated Vector2
  887. */
  888. copyFromFloats(x: number, y: number): Vector2;
  889. /**
  890. * Sets the Vector2 coordinates with the given floats
  891. * @param x defines the first coordinate
  892. * @param y defines the second coordinate
  893. * @returns the current updated Vector2
  894. */
  895. set(x: number, y: number): Vector2;
  896. /**
  897. * Add another vector with the current one
  898. * @param otherVector defines the other vector
  899. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  900. */
  901. add(otherVector: DeepImmutable<Vector2>): Vector2;
  902. /**
  903. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  904. * @param otherVector defines the other vector
  905. * @param result defines the target vector
  906. * @returns the unmodified current Vector2
  907. */
  908. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  909. /**
  910. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  911. * @param otherVector defines the other vector
  912. * @returns the current updated Vector2
  913. */
  914. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  915. /**
  916. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  917. * @param otherVector defines the other vector
  918. * @returns a new Vector2
  919. */
  920. addVector3(otherVector: Vector3): Vector2;
  921. /**
  922. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  923. * @param otherVector defines the other vector
  924. * @returns a new Vector2
  925. */
  926. subtract(otherVector: Vector2): Vector2;
  927. /**
  928. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  929. * @param otherVector defines the other vector
  930. * @param result defines the target vector
  931. * @returns the unmodified current Vector2
  932. */
  933. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  934. /**
  935. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  936. * @param otherVector defines the other vector
  937. * @returns the current updated Vector2
  938. */
  939. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  940. /**
  941. * Multiplies in place the current Vector2 coordinates by the given ones
  942. * @param otherVector defines the other vector
  943. * @returns the current updated Vector2
  944. */
  945. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  946. /**
  947. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  948. * @param otherVector defines the other vector
  949. * @returns a new Vector2
  950. */
  951. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  952. /**
  953. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  954. * @param otherVector defines the other vector
  955. * @param result defines the target vector
  956. * @returns the unmodified current Vector2
  957. */
  958. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  959. /**
  960. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  961. * @param x defines the first coordinate
  962. * @param y defines the second coordinate
  963. * @returns a new Vector2
  964. */
  965. multiplyByFloats(x: number, y: number): Vector2;
  966. /**
  967. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  968. * @param otherVector defines the other vector
  969. * @returns a new Vector2
  970. */
  971. divide(otherVector: Vector2): Vector2;
  972. /**
  973. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  974. * @param otherVector defines the other vector
  975. * @param result defines the target vector
  976. * @returns the unmodified current Vector2
  977. */
  978. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  979. /**
  980. * Divides the current Vector2 coordinates by the given ones
  981. * @param otherVector defines the other vector
  982. * @returns the current updated Vector2
  983. */
  984. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  985. /**
  986. * Gets a new Vector2 with current Vector2 negated coordinates
  987. * @returns a new Vector2
  988. */
  989. negate(): Vector2;
  990. /**
  991. * Multiply the Vector2 coordinates by scale
  992. * @param scale defines the scaling factor
  993. * @returns the current updated Vector2
  994. */
  995. scaleInPlace(scale: number): Vector2;
  996. /**
  997. * Returns a new Vector2 scaled by "scale" from the current Vector2
  998. * @param scale defines the scaling factor
  999. * @returns a new Vector2
  1000. */
  1001. scale(scale: number): Vector2;
  1002. /**
  1003. * Scale the current Vector2 values by a factor to a given Vector2
  1004. * @param scale defines the scale factor
  1005. * @param result defines the Vector2 object where to store the result
  1006. * @returns the unmodified current Vector2
  1007. */
  1008. scaleToRef(scale: number, result: Vector2): Vector2;
  1009. /**
  1010. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1011. * @param scale defines the scale factor
  1012. * @param result defines the Vector2 object where to store the result
  1013. * @returns the unmodified current Vector2
  1014. */
  1015. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1016. /**
  1017. * Gets a boolean if two vectors are equals
  1018. * @param otherVector defines the other vector
  1019. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1020. */
  1021. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1022. /**
  1023. * Gets a boolean if two vectors are equals (using an epsilon value)
  1024. * @param otherVector defines the other vector
  1025. * @param epsilon defines the minimal distance to consider equality
  1026. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1027. */
  1028. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1029. /**
  1030. * Gets a new Vector2 from current Vector2 floored values
  1031. * @returns a new Vector2
  1032. */
  1033. floor(): Vector2;
  1034. /**
  1035. * Gets a new Vector2 from current Vector2 floored values
  1036. * @returns a new Vector2
  1037. */
  1038. fract(): Vector2;
  1039. /**
  1040. * Gets the length of the vector
  1041. * @returns the vector length (float)
  1042. */
  1043. length(): number;
  1044. /**
  1045. * Gets the vector squared length
  1046. * @returns the vector squared length (float)
  1047. */
  1048. lengthSquared(): number;
  1049. /**
  1050. * Normalize the vector
  1051. * @returns the current updated Vector2
  1052. */
  1053. normalize(): Vector2;
  1054. /**
  1055. * Gets a new Vector2 copied from the Vector2
  1056. * @returns a new Vector2
  1057. */
  1058. clone(): Vector2;
  1059. /**
  1060. * Gets a new Vector2(0, 0)
  1061. * @returns a new Vector2
  1062. */
  1063. static Zero(): Vector2;
  1064. /**
  1065. * Gets a new Vector2(1, 1)
  1066. * @returns a new Vector2
  1067. */
  1068. static One(): Vector2;
  1069. /**
  1070. * Gets a new Vector2 set from the given index element of the given array
  1071. * @param array defines the data source
  1072. * @param offset defines the offset in the data source
  1073. * @returns a new Vector2
  1074. */
  1075. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1076. /**
  1077. * Sets "result" from the given index element of the given array
  1078. * @param array defines the data source
  1079. * @param offset defines the offset in the data source
  1080. * @param result defines the target vector
  1081. */
  1082. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1083. /**
  1084. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1085. * @param value1 defines 1st point of control
  1086. * @param value2 defines 2nd point of control
  1087. * @param value3 defines 3rd point of control
  1088. * @param value4 defines 4th point of control
  1089. * @param amount defines the interpolation factor
  1090. * @returns a new Vector2
  1091. */
  1092. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1093. /**
  1094. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  1095. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1096. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1097. * @param value defines the value to clamp
  1098. * @param min defines the lower limit
  1099. * @param max defines the upper limit
  1100. * @returns a new Vector2
  1101. */
  1102. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1103. /**
  1104. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1105. * @param value1 defines the 1st control point
  1106. * @param tangent1 defines the outgoing tangent
  1107. * @param value2 defines the 2nd control point
  1108. * @param tangent2 defines the incoming tangent
  1109. * @param amount defines the interpolation factor
  1110. * @returns a new Vector2
  1111. */
  1112. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1113. /**
  1114. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1115. * @param start defines the start vector
  1116. * @param end defines the end vector
  1117. * @param amount defines the interpolation factor
  1118. * @returns a new Vector2
  1119. */
  1120. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1121. /**
  1122. * Gets the dot product of the vector "left" and the vector "right"
  1123. * @param left defines first vector
  1124. * @param right defines second vector
  1125. * @returns the dot product (float)
  1126. */
  1127. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1128. /**
  1129. * Returns a new Vector2 equal to the normalized given vector
  1130. * @param vector defines the vector to normalize
  1131. * @returns a new Vector2
  1132. */
  1133. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1134. /**
  1135. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1136. * @param left defines 1st vector
  1137. * @param right defines 2nd vector
  1138. * @returns a new Vector2
  1139. */
  1140. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1141. /**
  1142. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1143. * @param left defines 1st vector
  1144. * @param right defines 2nd vector
  1145. * @returns a new Vector2
  1146. */
  1147. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1148. /**
  1149. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1150. * @param vector defines the vector to transform
  1151. * @param transformation defines the matrix to apply
  1152. * @returns a new Vector2
  1153. */
  1154. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1155. /**
  1156. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1157. * @param vector defines the vector to transform
  1158. * @param transformation defines the matrix to apply
  1159. * @param result defines the target vector
  1160. */
  1161. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1162. /**
  1163. * Determines if a given vector is included in a triangle
  1164. * @param p defines the vector to test
  1165. * @param p0 defines 1st triangle point
  1166. * @param p1 defines 2nd triangle point
  1167. * @param p2 defines 3rd triangle point
  1168. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1169. */
  1170. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1171. /**
  1172. * Gets the distance between the vectors "value1" and "value2"
  1173. * @param value1 defines first vector
  1174. * @param value2 defines second vector
  1175. * @returns the distance between vectors
  1176. */
  1177. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1178. /**
  1179. * Returns the squared distance between the vectors "value1" and "value2"
  1180. * @param value1 defines first vector
  1181. * @param value2 defines second vector
  1182. * @returns the squared distance between vectors
  1183. */
  1184. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1185. /**
  1186. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1187. * @param value1 defines first vector
  1188. * @param value2 defines second vector
  1189. * @returns a new Vector2
  1190. */
  1191. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1192. /**
  1193. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1194. * @param p defines the middle point
  1195. * @param segA defines one point of the segment
  1196. * @param segB defines the other point of the segment
  1197. * @returns the shortest distance
  1198. */
  1199. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1200. }
  1201. /**
  1202. * Classed used to store (x,y,z) vector representation
  1203. * A Vector3 is the main object used in 3D geometry
  1204. * It can represent etiher the coordinates of a point the space, either a direction
  1205. * Reminder: js uses a left handed forward facing system
  1206. */
  1207. export class Vector3 {
  1208. /**
  1209. * Defines the first coordinates (on X axis)
  1210. */
  1211. x: number;
  1212. /**
  1213. * Defines the second coordinates (on Y axis)
  1214. */
  1215. y: number;
  1216. /**
  1217. * Defines the third coordinates (on Z axis)
  1218. */
  1219. z: number;
  1220. private static _UpReadOnly;
  1221. /**
  1222. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1223. * @param x defines the first coordinates (on X axis)
  1224. * @param y defines the second coordinates (on Y axis)
  1225. * @param z defines the third coordinates (on Z axis)
  1226. */
  1227. constructor(
  1228. /**
  1229. * Defines the first coordinates (on X axis)
  1230. */
  1231. x?: number,
  1232. /**
  1233. * Defines the second coordinates (on Y axis)
  1234. */
  1235. y?: number,
  1236. /**
  1237. * Defines the third coordinates (on Z axis)
  1238. */
  1239. z?: number);
  1240. /**
  1241. * Creates a string representation of the Vector3
  1242. * @returns a string with the Vector3 coordinates.
  1243. */
  1244. toString(): string;
  1245. /**
  1246. * Gets the class name
  1247. * @returns the string "Vector3"
  1248. */
  1249. getClassName(): string;
  1250. /**
  1251. * Creates the Vector3 hash code
  1252. * @returns a number which tends to be unique between Vector3 instances
  1253. */
  1254. getHashCode(): number;
  1255. /**
  1256. * Creates an array containing three elements : the coordinates of the Vector3
  1257. * @returns a new array of numbers
  1258. */
  1259. asArray(): number[];
  1260. /**
  1261. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1262. * @param array defines the destination array
  1263. * @param index defines the offset in the destination array
  1264. * @returns the current Vector3
  1265. */
  1266. toArray(array: FloatArray, index?: number): Vector3;
  1267. /**
  1268. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1269. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1270. */
  1271. toQuaternion(): Quaternion;
  1272. /**
  1273. * Adds the given vector to the current Vector3
  1274. * @param otherVector defines the second operand
  1275. * @returns the current updated Vector3
  1276. */
  1277. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1278. /**
  1279. * Adds the given coordinates to the current Vector3
  1280. * @param x defines the x coordinate of the operand
  1281. * @param y defines the y coordinate of the operand
  1282. * @param z defines the z coordinate of the operand
  1283. * @returns the current updated Vector3
  1284. */
  1285. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1286. /**
  1287. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1288. * @param otherVector defines the second operand
  1289. * @returns the resulting Vector3
  1290. */
  1291. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1292. /**
  1293. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1294. * @param otherVector defines the second operand
  1295. * @param result defines the Vector3 object where to store the result
  1296. * @returns the current Vector3
  1297. */
  1298. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1299. /**
  1300. * Subtract the given vector from the current Vector3
  1301. * @param otherVector defines the second operand
  1302. * @returns the current updated Vector3
  1303. */
  1304. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1305. /**
  1306. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1307. * @param otherVector defines the second operand
  1308. * @returns the resulting Vector3
  1309. */
  1310. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1311. /**
  1312. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1313. * @param otherVector defines the second operand
  1314. * @param result defines the Vector3 object where to store the result
  1315. * @returns the current Vector3
  1316. */
  1317. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1318. /**
  1319. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1320. * @param x defines the x coordinate of the operand
  1321. * @param y defines the y coordinate of the operand
  1322. * @param z defines the z coordinate of the operand
  1323. * @returns the resulting Vector3
  1324. */
  1325. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1326. /**
  1327. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1328. * @param x defines the x coordinate of the operand
  1329. * @param y defines the y coordinate of the operand
  1330. * @param z defines the z coordinate of the operand
  1331. * @param result defines the Vector3 object where to store the result
  1332. * @returns the current Vector3
  1333. */
  1334. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1335. /**
  1336. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1337. * @returns a new Vector3
  1338. */
  1339. negate(): Vector3;
  1340. /**
  1341. * Multiplies the Vector3 coordinates by the float "scale"
  1342. * @param scale defines the multiplier factor
  1343. * @returns the current updated Vector3
  1344. */
  1345. scaleInPlace(scale: number): Vector3;
  1346. /**
  1347. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1348. * @param scale defines the multiplier factor
  1349. * @returns a new Vector3
  1350. */
  1351. scale(scale: number): Vector3;
  1352. /**
  1353. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1354. * @param scale defines the multiplier factor
  1355. * @param result defines the Vector3 object where to store the result
  1356. * @returns the current Vector3
  1357. */
  1358. scaleToRef(scale: number, result: Vector3): Vector3;
  1359. /**
  1360. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1361. * @param scale defines the scale factor
  1362. * @param result defines the Vector3 object where to store the result
  1363. * @returns the unmodified current Vector3
  1364. */
  1365. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1366. /**
  1367. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1368. * @param otherVector defines the second operand
  1369. * @returns true if both vectors are equals
  1370. */
  1371. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1372. /**
  1373. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1374. * @param otherVector defines the second operand
  1375. * @param epsilon defines the minimal distance to define values as equals
  1376. * @returns true if both vectors are distant less than epsilon
  1377. */
  1378. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1379. /**
  1380. * Returns true if the current Vector3 coordinates equals the given floats
  1381. * @param x defines the x coordinate of the operand
  1382. * @param y defines the y coordinate of the operand
  1383. * @param z defines the z coordinate of the operand
  1384. * @returns true if both vectors are equals
  1385. */
  1386. equalsToFloats(x: number, y: number, z: number): boolean;
  1387. /**
  1388. * Multiplies the current Vector3 coordinates by the given ones
  1389. * @param otherVector defines the second operand
  1390. * @returns the current updated Vector3
  1391. */
  1392. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1393. /**
  1394. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1395. * @param otherVector defines the second operand
  1396. * @returns the new Vector3
  1397. */
  1398. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1399. /**
  1400. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1401. * @param otherVector defines the second operand
  1402. * @param result defines the Vector3 object where to store the result
  1403. * @returns the current Vector3
  1404. */
  1405. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1406. /**
  1407. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1408. * @param x defines the x coordinate of the operand
  1409. * @param y defines the y coordinate of the operand
  1410. * @param z defines the z coordinate of the operand
  1411. * @returns the new Vector3
  1412. */
  1413. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1414. /**
  1415. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1416. * @param otherVector defines the second operand
  1417. * @returns the new Vector3
  1418. */
  1419. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1420. /**
  1421. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1422. * @param otherVector defines the second operand
  1423. * @param result defines the Vector3 object where to store the result
  1424. * @returns the current Vector3
  1425. */
  1426. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1427. /**
  1428. * Divides the current Vector3 coordinates by the given ones.
  1429. * @param otherVector defines the second operand
  1430. * @returns the current updated Vector3
  1431. */
  1432. divideInPlace(otherVector: Vector3): Vector3;
  1433. /**
  1434. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1435. * @param other defines the second operand
  1436. * @returns the current updated Vector3
  1437. */
  1438. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1439. /**
  1440. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1441. * @param other defines the second operand
  1442. * @returns the current updated Vector3
  1443. */
  1444. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1445. /**
  1446. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1447. * @param x defines the x coordinate of the operand
  1448. * @param y defines the y coordinate of the operand
  1449. * @param z defines the z coordinate of the operand
  1450. * @returns the current updated Vector3
  1451. */
  1452. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1453. /**
  1454. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1455. * @param x defines the x coordinate of the operand
  1456. * @param y defines the y coordinate of the operand
  1457. * @param z defines the z coordinate of the operand
  1458. * @returns the current updated Vector3
  1459. */
  1460. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1461. /**
  1462. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1463. * Check if is non uniform within a certain amount of decimal places to account for this
  1464. * @param epsilon the amount the values can differ
  1465. * @returns if the the vector is non uniform to a certain number of decimal places
  1466. */
  1467. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1468. /**
  1469. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1470. */
  1471. readonly isNonUniform: boolean;
  1472. /**
  1473. * Gets a new Vector3 from current Vector3 floored values
  1474. * @returns a new Vector3
  1475. */
  1476. floor(): Vector3;
  1477. /**
  1478. * Gets a new Vector3 from current Vector3 floored values
  1479. * @returns a new Vector3
  1480. */
  1481. fract(): Vector3;
  1482. /**
  1483. * Gets the length of the Vector3
  1484. * @returns the length of the Vecto3
  1485. */
  1486. length(): number;
  1487. /**
  1488. * Gets the squared length of the Vector3
  1489. * @returns squared length of the Vector3
  1490. */
  1491. lengthSquared(): number;
  1492. /**
  1493. * Normalize the current Vector3.
  1494. * Please note that this is an in place operation.
  1495. * @returns the current updated Vector3
  1496. */
  1497. normalize(): Vector3;
  1498. /**
  1499. * Reorders the x y z properties of the vector in place
  1500. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1501. * @returns the current updated vector
  1502. */
  1503. reorderInPlace(order: string): this;
  1504. /**
  1505. * Rotates the vector around 0,0,0 by a quaternion
  1506. * @param quaternion the rotation quaternion
  1507. * @param result vector to store the result
  1508. * @returns the resulting vector
  1509. */
  1510. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1511. /**
  1512. * Rotates a vector around a given point
  1513. * @param quaternion the rotation quaternion
  1514. * @param point the point to rotate around
  1515. * @param result vector to store the result
  1516. * @returns the resulting vector
  1517. */
  1518. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1519. /**
  1520. * Normalize the current Vector3 with the given input length.
  1521. * Please note that this is an in place operation.
  1522. * @param len the length of the vector
  1523. * @returns the current updated Vector3
  1524. */
  1525. normalizeFromLength(len: number): Vector3;
  1526. /**
  1527. * Normalize the current Vector3 to a new vector
  1528. * @returns the new Vector3
  1529. */
  1530. normalizeToNew(): Vector3;
  1531. /**
  1532. * Normalize the current Vector3 to the reference
  1533. * @param reference define the Vector3 to update
  1534. * @returns the updated Vector3
  1535. */
  1536. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1537. /**
  1538. * Creates a new Vector3 copied from the current Vector3
  1539. * @returns the new Vector3
  1540. */
  1541. clone(): Vector3;
  1542. /**
  1543. * Copies the given vector coordinates to the current Vector3 ones
  1544. * @param source defines the source Vector3
  1545. * @returns the current updated Vector3
  1546. */
  1547. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1548. /**
  1549. * Copies the given floats to the current Vector3 coordinates
  1550. * @param x defines the x coordinate of the operand
  1551. * @param y defines the y coordinate of the operand
  1552. * @param z defines the z coordinate of the operand
  1553. * @returns the current updated Vector3
  1554. */
  1555. copyFromFloats(x: number, y: number, z: number): Vector3;
  1556. /**
  1557. * Copies the given floats to the current Vector3 coordinates
  1558. * @param x defines the x coordinate of the operand
  1559. * @param y defines the y coordinate of the operand
  1560. * @param z defines the z coordinate of the operand
  1561. * @returns the current updated Vector3
  1562. */
  1563. set(x: number, y: number, z: number): Vector3;
  1564. /**
  1565. * Copies the given float to the current Vector3 coordinates
  1566. * @param v defines the x, y and z coordinates of the operand
  1567. * @returns the current updated Vector3
  1568. */
  1569. setAll(v: number): Vector3;
  1570. /**
  1571. * Get the clip factor between two vectors
  1572. * @param vector0 defines the first operand
  1573. * @param vector1 defines the second operand
  1574. * @param axis defines the axis to use
  1575. * @param size defines the size along the axis
  1576. * @returns the clip factor
  1577. */
  1578. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1579. /**
  1580. * Get angle between two vectors
  1581. * @param vector0 angle between vector0 and vector1
  1582. * @param vector1 angle between vector0 and vector1
  1583. * @param normal direction of the normal
  1584. * @return the angle between vector0 and vector1
  1585. */
  1586. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1587. /**
  1588. * Returns a new Vector3 set from the index "offset" of the given array
  1589. * @param array defines the source array
  1590. * @param offset defines the offset in the source array
  1591. * @returns the new Vector3
  1592. */
  1593. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1594. /**
  1595. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1596. * This function is deprecated. Use FromArray instead
  1597. * @param array defines the source array
  1598. * @param offset defines the offset in the source array
  1599. * @returns the new Vector3
  1600. */
  1601. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1602. /**
  1603. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1604. * @param array defines the source array
  1605. * @param offset defines the offset in the source array
  1606. * @param result defines the Vector3 where to store the result
  1607. */
  1608. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1609. /**
  1610. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1611. * This function is deprecated. Use FromArrayToRef instead.
  1612. * @param array defines the source array
  1613. * @param offset defines the offset in the source array
  1614. * @param result defines the Vector3 where to store the result
  1615. */
  1616. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1617. /**
  1618. * Sets the given vector "result" with the given floats.
  1619. * @param x defines the x coordinate of the source
  1620. * @param y defines the y coordinate of the source
  1621. * @param z defines the z coordinate of the source
  1622. * @param result defines the Vector3 where to store the result
  1623. */
  1624. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1625. /**
  1626. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1627. * @returns a new empty Vector3
  1628. */
  1629. static Zero(): Vector3;
  1630. /**
  1631. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1632. * @returns a new unit Vector3
  1633. */
  1634. static One(): Vector3;
  1635. /**
  1636. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1637. * @returns a new up Vector3
  1638. */
  1639. static Up(): Vector3;
  1640. /**
  1641. * Gets a up Vector3 that must not be updated
  1642. */
  1643. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1644. /**
  1645. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1646. * @returns a new down Vector3
  1647. */
  1648. static Down(): Vector3;
  1649. /**
  1650. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1651. * @returns a new forward Vector3
  1652. */
  1653. static Forward(): Vector3;
  1654. /**
  1655. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1656. * @returns a new forward Vector3
  1657. */
  1658. static Backward(): Vector3;
  1659. /**
  1660. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1661. * @returns a new right Vector3
  1662. */
  1663. static Right(): Vector3;
  1664. /**
  1665. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1666. * @returns a new left Vector3
  1667. */
  1668. static Left(): Vector3;
  1669. /**
  1670. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1671. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1672. * @param vector defines the Vector3 to transform
  1673. * @param transformation defines the transformation matrix
  1674. * @returns the transformed Vector3
  1675. */
  1676. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1677. /**
  1678. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1679. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1680. * @param vector defines the Vector3 to transform
  1681. * @param transformation defines the transformation matrix
  1682. * @param result defines the Vector3 where to store the result
  1683. */
  1684. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1685. /**
  1686. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1687. * This method computes tranformed coordinates only, not transformed direction vectors
  1688. * @param x define the x coordinate of the source vector
  1689. * @param y define the y coordinate of the source vector
  1690. * @param z define the z coordinate of the source vector
  1691. * @param transformation defines the transformation matrix
  1692. * @param result defines the Vector3 where to store the result
  1693. */
  1694. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1695. /**
  1696. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1697. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1698. * @param vector defines the Vector3 to transform
  1699. * @param transformation defines the transformation matrix
  1700. * @returns the new Vector3
  1701. */
  1702. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1703. /**
  1704. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1705. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1706. * @param vector defines the Vector3 to transform
  1707. * @param transformation defines the transformation matrix
  1708. * @param result defines the Vector3 where to store the result
  1709. */
  1710. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1711. /**
  1712. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1713. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1714. * @param x define the x coordinate of the source vector
  1715. * @param y define the y coordinate of the source vector
  1716. * @param z define the z coordinate of the source vector
  1717. * @param transformation defines the transformation matrix
  1718. * @param result defines the Vector3 where to store the result
  1719. */
  1720. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1721. /**
  1722. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1723. * @param value1 defines the first control point
  1724. * @param value2 defines the second control point
  1725. * @param value3 defines the third control point
  1726. * @param value4 defines the fourth control point
  1727. * @param amount defines the amount on the spline to use
  1728. * @returns the new Vector3
  1729. */
  1730. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1731. /**
  1732. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1733. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1734. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1735. * @param value defines the current value
  1736. * @param min defines the lower range value
  1737. * @param max defines the upper range value
  1738. * @returns the new Vector3
  1739. */
  1740. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1741. /**
  1742. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1743. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1744. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1745. * @param value defines the current value
  1746. * @param min defines the lower range value
  1747. * @param max defines the upper range value
  1748. * @param result defines the Vector3 where to store the result
  1749. */
  1750. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1751. /**
  1752. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1753. * @param value1 defines the first control point
  1754. * @param tangent1 defines the first tangent vector
  1755. * @param value2 defines the second control point
  1756. * @param tangent2 defines the second tangent vector
  1757. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1758. * @returns the new Vector3
  1759. */
  1760. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1761. /**
  1762. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1763. * @param start defines the start value
  1764. * @param end defines the end value
  1765. * @param amount max defines amount between both (between 0 and 1)
  1766. * @returns the new Vector3
  1767. */
  1768. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1769. /**
  1770. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1771. * @param start defines the start value
  1772. * @param end defines the end value
  1773. * @param amount max defines amount between both (between 0 and 1)
  1774. * @param result defines the Vector3 where to store the result
  1775. */
  1776. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1777. /**
  1778. * Returns the dot product (float) between the vectors "left" and "right"
  1779. * @param left defines the left operand
  1780. * @param right defines the right operand
  1781. * @returns the dot product
  1782. */
  1783. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1784. /**
  1785. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1786. * The cross product is then orthogonal to both "left" and "right"
  1787. * @param left defines the left operand
  1788. * @param right defines the right operand
  1789. * @returns the cross product
  1790. */
  1791. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1792. /**
  1793. * Sets the given vector "result" with the cross product of "left" and "right"
  1794. * The cross product is then orthogonal to both "left" and "right"
  1795. * @param left defines the left operand
  1796. * @param right defines the right operand
  1797. * @param result defines the Vector3 where to store the result
  1798. */
  1799. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1800. /**
  1801. * Returns a new Vector3 as the normalization of the given vector
  1802. * @param vector defines the Vector3 to normalize
  1803. * @returns the new Vector3
  1804. */
  1805. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1806. /**
  1807. * Sets the given vector "result" with the normalization of the given first vector
  1808. * @param vector defines the Vector3 to normalize
  1809. * @param result defines the Vector3 where to store the result
  1810. */
  1811. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1812. /**
  1813. * Project a Vector3 onto screen space
  1814. * @param vector defines the Vector3 to project
  1815. * @param world defines the world matrix to use
  1816. * @param transform defines the transform (view x projection) matrix to use
  1817. * @param viewport defines the screen viewport to use
  1818. * @returns the new Vector3
  1819. */
  1820. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1821. /** @hidden */
  1822. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1823. /**
  1824. * Unproject from screen space to object space
  1825. * @param source defines the screen space Vector3 to use
  1826. * @param viewportWidth defines the current width of the viewport
  1827. * @param viewportHeight defines the current height of the viewport
  1828. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1829. * @param transform defines the transform (view x projection) matrix to use
  1830. * @returns the new Vector3
  1831. */
  1832. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1833. /**
  1834. * Unproject from screen space to object space
  1835. * @param source defines the screen space Vector3 to use
  1836. * @param viewportWidth defines the current width of the viewport
  1837. * @param viewportHeight defines the current height of the viewport
  1838. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1839. * @param view defines the view matrix to use
  1840. * @param projection defines the projection matrix to use
  1841. * @returns the new Vector3
  1842. */
  1843. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1844. /**
  1845. * Unproject from screen space to object space
  1846. * @param source defines the screen space Vector3 to use
  1847. * @param viewportWidth defines the current width of the viewport
  1848. * @param viewportHeight defines the current height of the viewport
  1849. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1850. * @param view defines the view matrix to use
  1851. * @param projection defines the projection matrix to use
  1852. * @param result defines the Vector3 where to store the result
  1853. */
  1854. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1855. /**
  1856. * Unproject from screen space to object space
  1857. * @param sourceX defines the screen space x coordinate to use
  1858. * @param sourceY defines the screen space y coordinate to use
  1859. * @param sourceZ defines the screen space z coordinate to use
  1860. * @param viewportWidth defines the current width of the viewport
  1861. * @param viewportHeight defines the current height of the viewport
  1862. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1863. * @param view defines the view matrix to use
  1864. * @param projection defines the projection matrix to use
  1865. * @param result defines the Vector3 where to store the result
  1866. */
  1867. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1868. /**
  1869. * Gets the minimal coordinate values between two Vector3
  1870. * @param left defines the first operand
  1871. * @param right defines the second operand
  1872. * @returns the new Vector3
  1873. */
  1874. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1875. /**
  1876. * Gets the maximal coordinate values between two Vector3
  1877. * @param left defines the first operand
  1878. * @param right defines the second operand
  1879. * @returns the new Vector3
  1880. */
  1881. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1882. /**
  1883. * Returns the distance between the vectors "value1" and "value2"
  1884. * @param value1 defines the first operand
  1885. * @param value2 defines the second operand
  1886. * @returns the distance
  1887. */
  1888. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1889. /**
  1890. * Returns the squared distance between the vectors "value1" and "value2"
  1891. * @param value1 defines the first operand
  1892. * @param value2 defines the second operand
  1893. * @returns the squared distance
  1894. */
  1895. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1896. /**
  1897. * Returns a new Vector3 located at the center between "value1" and "value2"
  1898. * @param value1 defines the first operand
  1899. * @param value2 defines the second operand
  1900. * @returns the new Vector3
  1901. */
  1902. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1903. /**
  1904. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1905. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1906. * to something in order to rotate it from its local system to the given target system
  1907. * Note: axis1, axis2 and axis3 are normalized during this operation
  1908. * @param axis1 defines the first axis
  1909. * @param axis2 defines the second axis
  1910. * @param axis3 defines the third axis
  1911. * @returns a new Vector3
  1912. */
  1913. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1914. /**
  1915. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1916. * @param axis1 defines the first axis
  1917. * @param axis2 defines the second axis
  1918. * @param axis3 defines the third axis
  1919. * @param ref defines the Vector3 where to store the result
  1920. */
  1921. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1922. }
  1923. /**
  1924. * Vector4 class created for EulerAngle class conversion to Quaternion
  1925. */
  1926. export class Vector4 {
  1927. /** x value of the vector */
  1928. x: number;
  1929. /** y value of the vector */
  1930. y: number;
  1931. /** z value of the vector */
  1932. z: number;
  1933. /** w value of the vector */
  1934. w: number;
  1935. /**
  1936. * Creates a Vector4 object from the given floats.
  1937. * @param x x value of the vector
  1938. * @param y y value of the vector
  1939. * @param z z value of the vector
  1940. * @param w w value of the vector
  1941. */
  1942. constructor(
  1943. /** x value of the vector */
  1944. x: number,
  1945. /** y value of the vector */
  1946. y: number,
  1947. /** z value of the vector */
  1948. z: number,
  1949. /** w value of the vector */
  1950. w: number);
  1951. /**
  1952. * Returns the string with the Vector4 coordinates.
  1953. * @returns a string containing all the vector values
  1954. */
  1955. toString(): string;
  1956. /**
  1957. * Returns the string "Vector4".
  1958. * @returns "Vector4"
  1959. */
  1960. getClassName(): string;
  1961. /**
  1962. * Returns the Vector4 hash code.
  1963. * @returns a unique hash code
  1964. */
  1965. getHashCode(): number;
  1966. /**
  1967. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1968. * @returns the resulting array
  1969. */
  1970. asArray(): number[];
  1971. /**
  1972. * Populates the given array from the given index with the Vector4 coordinates.
  1973. * @param array array to populate
  1974. * @param index index of the array to start at (default: 0)
  1975. * @returns the Vector4.
  1976. */
  1977. toArray(array: FloatArray, index?: number): Vector4;
  1978. /**
  1979. * Adds the given vector to the current Vector4.
  1980. * @param otherVector the vector to add
  1981. * @returns the updated Vector4.
  1982. */
  1983. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  1984. /**
  1985. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  1986. * @param otherVector the vector to add
  1987. * @returns the resulting vector
  1988. */
  1989. add(otherVector: DeepImmutable<Vector4>): Vector4;
  1990. /**
  1991. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  1992. * @param otherVector the vector to add
  1993. * @param result the vector to store the result
  1994. * @returns the current Vector4.
  1995. */
  1996. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  1997. /**
  1998. * Subtract in place the given vector from the current Vector4.
  1999. * @param otherVector the vector to subtract
  2000. * @returns the updated Vector4.
  2001. */
  2002. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2003. /**
  2004. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2005. * @param otherVector the vector to add
  2006. * @returns the new vector with the result
  2007. */
  2008. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2009. /**
  2010. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2011. * @param otherVector the vector to subtract
  2012. * @param result the vector to store the result
  2013. * @returns the current Vector4.
  2014. */
  2015. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2016. /**
  2017. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2018. */
  2019. /**
  2020. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2021. * @param x value to subtract
  2022. * @param y value to subtract
  2023. * @param z value to subtract
  2024. * @param w value to subtract
  2025. * @returns new vector containing the result
  2026. */
  2027. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2028. /**
  2029. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2030. * @param x value to subtract
  2031. * @param y value to subtract
  2032. * @param z value to subtract
  2033. * @param w value to subtract
  2034. * @param result the vector to store the result in
  2035. * @returns the current Vector4.
  2036. */
  2037. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2038. /**
  2039. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2040. * @returns a new vector with the negated values
  2041. */
  2042. negate(): Vector4;
  2043. /**
  2044. * Multiplies the current Vector4 coordinates by scale (float).
  2045. * @param scale the number to scale with
  2046. * @returns the updated Vector4.
  2047. */
  2048. scaleInPlace(scale: number): Vector4;
  2049. /**
  2050. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2051. * @param scale the number to scale with
  2052. * @returns a new vector with the result
  2053. */
  2054. scale(scale: number): Vector4;
  2055. /**
  2056. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2057. * @param scale the number to scale with
  2058. * @param result a vector to store the result in
  2059. * @returns the current Vector4.
  2060. */
  2061. scaleToRef(scale: number, result: Vector4): Vector4;
  2062. /**
  2063. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2064. * @param scale defines the scale factor
  2065. * @param result defines the Vector4 object where to store the result
  2066. * @returns the unmodified current Vector4
  2067. */
  2068. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2069. /**
  2070. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2071. * @param otherVector the vector to compare against
  2072. * @returns true if they are equal
  2073. */
  2074. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2075. /**
  2076. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2077. * @param otherVector vector to compare against
  2078. * @param epsilon (Default: very small number)
  2079. * @returns true if they are equal
  2080. */
  2081. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2082. /**
  2083. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2084. * @param x x value to compare against
  2085. * @param y y value to compare against
  2086. * @param z z value to compare against
  2087. * @param w w value to compare against
  2088. * @returns true if equal
  2089. */
  2090. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2091. /**
  2092. * Multiplies in place the current Vector4 by the given one.
  2093. * @param otherVector vector to multiple with
  2094. * @returns the updated Vector4.
  2095. */
  2096. multiplyInPlace(otherVector: Vector4): Vector4;
  2097. /**
  2098. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2099. * @param otherVector vector to multiple with
  2100. * @returns resulting new vector
  2101. */
  2102. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2103. /**
  2104. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2105. * @param otherVector vector to multiple with
  2106. * @param result vector to store the result
  2107. * @returns the current Vector4.
  2108. */
  2109. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2110. /**
  2111. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2112. * @param x x value multiply with
  2113. * @param y y value multiply with
  2114. * @param z z value multiply with
  2115. * @param w w value multiply with
  2116. * @returns resulting new vector
  2117. */
  2118. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2119. /**
  2120. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2121. * @param otherVector vector to devide with
  2122. * @returns resulting new vector
  2123. */
  2124. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2125. /**
  2126. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2127. * @param otherVector vector to devide with
  2128. * @param result vector to store the result
  2129. * @returns the current Vector4.
  2130. */
  2131. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2132. /**
  2133. * Divides the current Vector3 coordinates by the given ones.
  2134. * @param otherVector vector to devide with
  2135. * @returns the updated Vector3.
  2136. */
  2137. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2138. /**
  2139. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2140. * @param other defines the second operand
  2141. * @returns the current updated Vector4
  2142. */
  2143. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2144. /**
  2145. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2146. * @param other defines the second operand
  2147. * @returns the current updated Vector4
  2148. */
  2149. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2150. /**
  2151. * Gets a new Vector4 from current Vector4 floored values
  2152. * @returns a new Vector4
  2153. */
  2154. floor(): Vector4;
  2155. /**
  2156. * Gets a new Vector4 from current Vector3 floored values
  2157. * @returns a new Vector4
  2158. */
  2159. fract(): Vector4;
  2160. /**
  2161. * Returns the Vector4 length (float).
  2162. * @returns the length
  2163. */
  2164. length(): number;
  2165. /**
  2166. * Returns the Vector4 squared length (float).
  2167. * @returns the length squared
  2168. */
  2169. lengthSquared(): number;
  2170. /**
  2171. * Normalizes in place the Vector4.
  2172. * @returns the updated Vector4.
  2173. */
  2174. normalize(): Vector4;
  2175. /**
  2176. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2177. * @returns this converted to a new vector3
  2178. */
  2179. toVector3(): Vector3;
  2180. /**
  2181. * Returns a new Vector4 copied from the current one.
  2182. * @returns the new cloned vector
  2183. */
  2184. clone(): Vector4;
  2185. /**
  2186. * Updates the current Vector4 with the given one coordinates.
  2187. * @param source the source vector to copy from
  2188. * @returns the updated Vector4.
  2189. */
  2190. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2191. /**
  2192. * Updates the current Vector4 coordinates with the given floats.
  2193. * @param x float to copy from
  2194. * @param y float to copy from
  2195. * @param z float to copy from
  2196. * @param w float to copy from
  2197. * @returns the updated Vector4.
  2198. */
  2199. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2200. /**
  2201. * Updates the current Vector4 coordinates with the given floats.
  2202. * @param x float to set from
  2203. * @param y float to set from
  2204. * @param z float to set from
  2205. * @param w float to set from
  2206. * @returns the updated Vector4.
  2207. */
  2208. set(x: number, y: number, z: number, w: number): Vector4;
  2209. /**
  2210. * Copies the given float to the current Vector3 coordinates
  2211. * @param v defines the x, y, z and w coordinates of the operand
  2212. * @returns the current updated Vector3
  2213. */
  2214. setAll(v: number): Vector4;
  2215. /**
  2216. * Returns a new Vector4 set from the starting index of the given array.
  2217. * @param array the array to pull values from
  2218. * @param offset the offset into the array to start at
  2219. * @returns the new vector
  2220. */
  2221. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2222. /**
  2223. * Updates the given vector "result" from the starting index of the given array.
  2224. * @param array the array to pull values from
  2225. * @param offset the offset into the array to start at
  2226. * @param result the vector to store the result in
  2227. */
  2228. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2229. /**
  2230. * Updates the given vector "result" from the starting index of the given Float32Array.
  2231. * @param array the array to pull values from
  2232. * @param offset the offset into the array to start at
  2233. * @param result the vector to store the result in
  2234. */
  2235. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2236. /**
  2237. * Updates the given vector "result" coordinates from the given floats.
  2238. * @param x float to set from
  2239. * @param y float to set from
  2240. * @param z float to set from
  2241. * @param w float to set from
  2242. * @param result the vector to the floats in
  2243. */
  2244. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2245. /**
  2246. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2247. * @returns the new vector
  2248. */
  2249. static Zero(): Vector4;
  2250. /**
  2251. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2252. * @returns the new vector
  2253. */
  2254. static One(): Vector4;
  2255. /**
  2256. * Returns a new normalized Vector4 from the given one.
  2257. * @param vector the vector to normalize
  2258. * @returns the vector
  2259. */
  2260. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2261. /**
  2262. * Updates the given vector "result" from the normalization of the given one.
  2263. * @param vector the vector to normalize
  2264. * @param result the vector to store the result in
  2265. */
  2266. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2267. /**
  2268. * Returns a vector with the minimum values from the left and right vectors
  2269. * @param left left vector to minimize
  2270. * @param right right vector to minimize
  2271. * @returns a new vector with the minimum of the left and right vector values
  2272. */
  2273. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2274. /**
  2275. * Returns a vector with the maximum values from the left and right vectors
  2276. * @param left left vector to maximize
  2277. * @param right right vector to maximize
  2278. * @returns a new vector with the maximum of the left and right vector values
  2279. */
  2280. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2281. /**
  2282. * Returns the distance (float) between the vectors "value1" and "value2".
  2283. * @param value1 value to calulate the distance between
  2284. * @param value2 value to calulate the distance between
  2285. * @return the distance between the two vectors
  2286. */
  2287. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2288. /**
  2289. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2290. * @param value1 value to calulate the distance between
  2291. * @param value2 value to calulate the distance between
  2292. * @return the distance between the two vectors squared
  2293. */
  2294. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2295. /**
  2296. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2297. * @param value1 value to calulate the center between
  2298. * @param value2 value to calulate the center between
  2299. * @return the center between the two vectors
  2300. */
  2301. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2302. /**
  2303. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2304. * This methods computes transformed normalized direction vectors only.
  2305. * @param vector the vector to transform
  2306. * @param transformation the transformation matrix to apply
  2307. * @returns the new vector
  2308. */
  2309. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2310. /**
  2311. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2312. * This methods computes transformed normalized direction vectors only.
  2313. * @param vector the vector to transform
  2314. * @param transformation the transformation matrix to apply
  2315. * @param result the vector to store the result in
  2316. */
  2317. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2318. /**
  2319. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2320. * This methods computes transformed normalized direction vectors only.
  2321. * @param x value to transform
  2322. * @param y value to transform
  2323. * @param z value to transform
  2324. * @param w value to transform
  2325. * @param transformation the transformation matrix to apply
  2326. * @param result the vector to store the results in
  2327. */
  2328. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2329. /**
  2330. * Creates a new Vector4 from a Vector3
  2331. * @param source defines the source data
  2332. * @param w defines the 4th component (default is 0)
  2333. * @returns a new Vector4
  2334. */
  2335. static FromVector3(source: Vector3, w?: number): Vector4;
  2336. }
  2337. /**
  2338. * Interface for the size containing width and height
  2339. */
  2340. export interface ISize {
  2341. /**
  2342. * Width
  2343. */
  2344. width: number;
  2345. /**
  2346. * Heighht
  2347. */
  2348. height: number;
  2349. }
  2350. /**
  2351. * Size containing widht and height
  2352. */
  2353. export class Size implements ISize {
  2354. /**
  2355. * Width
  2356. */
  2357. width: number;
  2358. /**
  2359. * Height
  2360. */
  2361. height: number;
  2362. /**
  2363. * Creates a Size object from the given width and height (floats).
  2364. * @param width width of the new size
  2365. * @param height height of the new size
  2366. */
  2367. constructor(width: number, height: number);
  2368. /**
  2369. * Returns a string with the Size width and height
  2370. * @returns a string with the Size width and height
  2371. */
  2372. toString(): string;
  2373. /**
  2374. * "Size"
  2375. * @returns the string "Size"
  2376. */
  2377. getClassName(): string;
  2378. /**
  2379. * Returns the Size hash code.
  2380. * @returns a hash code for a unique width and height
  2381. */
  2382. getHashCode(): number;
  2383. /**
  2384. * Updates the current size from the given one.
  2385. * @param src the given size
  2386. */
  2387. copyFrom(src: Size): void;
  2388. /**
  2389. * Updates in place the current Size from the given floats.
  2390. * @param width width of the new size
  2391. * @param height height of the new size
  2392. * @returns the updated Size.
  2393. */
  2394. copyFromFloats(width: number, height: number): Size;
  2395. /**
  2396. * Updates in place the current Size from the given floats.
  2397. * @param width width to set
  2398. * @param height height to set
  2399. * @returns the updated Size.
  2400. */
  2401. set(width: number, height: number): Size;
  2402. /**
  2403. * Multiplies the width and height by numbers
  2404. * @param w factor to multiple the width by
  2405. * @param h factor to multiple the height by
  2406. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2407. */
  2408. multiplyByFloats(w: number, h: number): Size;
  2409. /**
  2410. * Clones the size
  2411. * @returns a new Size copied from the given one.
  2412. */
  2413. clone(): Size;
  2414. /**
  2415. * True if the current Size and the given one width and height are strictly equal.
  2416. * @param other the other size to compare against
  2417. * @returns True if the current Size and the given one width and height are strictly equal.
  2418. */
  2419. equals(other: Size): boolean;
  2420. /**
  2421. * The surface of the Size : width * height (float).
  2422. */
  2423. readonly surface: number;
  2424. /**
  2425. * Create a new size of zero
  2426. * @returns a new Size set to (0.0, 0.0)
  2427. */
  2428. static Zero(): Size;
  2429. /**
  2430. * Sums the width and height of two sizes
  2431. * @param otherSize size to add to this size
  2432. * @returns a new Size set as the addition result of the current Size and the given one.
  2433. */
  2434. add(otherSize: Size): Size;
  2435. /**
  2436. * Subtracts the width and height of two
  2437. * @param otherSize size to subtract to this size
  2438. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2439. */
  2440. subtract(otherSize: Size): Size;
  2441. /**
  2442. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2443. * @param start starting size to lerp between
  2444. * @param end end size to lerp between
  2445. * @param amount amount to lerp between the start and end values
  2446. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2447. */
  2448. static Lerp(start: Size, end: Size, amount: number): Size;
  2449. }
  2450. /**
  2451. * Class used to store quaternion data
  2452. * @see https://en.wikipedia.org/wiki/Quaternion
  2453. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2454. */
  2455. export class Quaternion {
  2456. /** defines the first component (0 by default) */
  2457. x: number;
  2458. /** defines the second component (0 by default) */
  2459. y: number;
  2460. /** defines the third component (0 by default) */
  2461. z: number;
  2462. /** defines the fourth component (1.0 by default) */
  2463. w: number;
  2464. /**
  2465. * Creates a new Quaternion from the given floats
  2466. * @param x defines the first component (0 by default)
  2467. * @param y defines the second component (0 by default)
  2468. * @param z defines the third component (0 by default)
  2469. * @param w defines the fourth component (1.0 by default)
  2470. */
  2471. constructor(
  2472. /** defines the first component (0 by default) */
  2473. x?: number,
  2474. /** defines the second component (0 by default) */
  2475. y?: number,
  2476. /** defines the third component (0 by default) */
  2477. z?: number,
  2478. /** defines the fourth component (1.0 by default) */
  2479. w?: number);
  2480. /**
  2481. * Gets a string representation for the current quaternion
  2482. * @returns a string with the Quaternion coordinates
  2483. */
  2484. toString(): string;
  2485. /**
  2486. * Gets the class name of the quaternion
  2487. * @returns the string "Quaternion"
  2488. */
  2489. getClassName(): string;
  2490. /**
  2491. * Gets a hash code for this quaternion
  2492. * @returns the quaternion hash code
  2493. */
  2494. getHashCode(): number;
  2495. /**
  2496. * Copy the quaternion to an array
  2497. * @returns a new array populated with 4 elements from the quaternion coordinates
  2498. */
  2499. asArray(): number[];
  2500. /**
  2501. * Check if two quaternions are equals
  2502. * @param otherQuaternion defines the second operand
  2503. * @return true if the current quaternion and the given one coordinates are strictly equals
  2504. */
  2505. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2506. /**
  2507. * Clone the current quaternion
  2508. * @returns a new quaternion copied from the current one
  2509. */
  2510. clone(): Quaternion;
  2511. /**
  2512. * Copy a quaternion to the current one
  2513. * @param other defines the other quaternion
  2514. * @returns the updated current quaternion
  2515. */
  2516. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2517. /**
  2518. * Updates the current quaternion with the given float coordinates
  2519. * @param x defines the x coordinate
  2520. * @param y defines the y coordinate
  2521. * @param z defines the z coordinate
  2522. * @param w defines the w coordinate
  2523. * @returns the updated current quaternion
  2524. */
  2525. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2526. /**
  2527. * Updates the current quaternion from the given float coordinates
  2528. * @param x defines the x coordinate
  2529. * @param y defines the y coordinate
  2530. * @param z defines the z coordinate
  2531. * @param w defines the w coordinate
  2532. * @returns the updated current quaternion
  2533. */
  2534. set(x: number, y: number, z: number, w: number): Quaternion;
  2535. /**
  2536. * Adds two quaternions
  2537. * @param other defines the second operand
  2538. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2539. */
  2540. add(other: DeepImmutable<Quaternion>): Quaternion;
  2541. /**
  2542. * Add a quaternion to the current one
  2543. * @param other defines the quaternion to add
  2544. * @returns the current quaternion
  2545. */
  2546. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2547. /**
  2548. * Subtract two quaternions
  2549. * @param other defines the second operand
  2550. * @returns a new quaternion as the subtraction result of the given one from the current one
  2551. */
  2552. subtract(other: Quaternion): Quaternion;
  2553. /**
  2554. * Multiplies the current quaternion by a scale factor
  2555. * @param value defines the scale factor
  2556. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2557. */
  2558. scale(value: number): Quaternion;
  2559. /**
  2560. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2561. * @param scale defines the scale factor
  2562. * @param result defines the Quaternion object where to store the result
  2563. * @returns the unmodified current quaternion
  2564. */
  2565. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2566. /**
  2567. * Multiplies in place the current quaternion by a scale factor
  2568. * @param value defines the scale factor
  2569. * @returns the current modified quaternion
  2570. */
  2571. scaleInPlace(value: number): Quaternion;
  2572. /**
  2573. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2574. * @param scale defines the scale factor
  2575. * @param result defines the Quaternion object where to store the result
  2576. * @returns the unmodified current quaternion
  2577. */
  2578. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2579. /**
  2580. * Multiplies two quaternions
  2581. * @param q1 defines the second operand
  2582. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2583. */
  2584. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2585. /**
  2586. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2587. * @param q1 defines the second operand
  2588. * @param result defines the target quaternion
  2589. * @returns the current quaternion
  2590. */
  2591. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2592. /**
  2593. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2594. * @param q1 defines the second operand
  2595. * @returns the currentupdated quaternion
  2596. */
  2597. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2598. /**
  2599. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2600. * @param ref defines the target quaternion
  2601. * @returns the current quaternion
  2602. */
  2603. conjugateToRef(ref: Quaternion): Quaternion;
  2604. /**
  2605. * Conjugates in place (1-q) the current quaternion
  2606. * @returns the current updated quaternion
  2607. */
  2608. conjugateInPlace(): Quaternion;
  2609. /**
  2610. * Conjugates in place (1-q) the current quaternion
  2611. * @returns a new quaternion
  2612. */
  2613. conjugate(): Quaternion;
  2614. /**
  2615. * Gets length of current quaternion
  2616. * @returns the quaternion length (float)
  2617. */
  2618. length(): number;
  2619. /**
  2620. * Normalize in place the current quaternion
  2621. * @returns the current updated quaternion
  2622. */
  2623. normalize(): Quaternion;
  2624. /**
  2625. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2626. * @param order is a reserved parameter and is ignore for now
  2627. * @returns a new Vector3 containing the Euler angles
  2628. */
  2629. toEulerAngles(order?: string): Vector3;
  2630. /**
  2631. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2632. * @param result defines the vector which will be filled with the Euler angles
  2633. * @param order is a reserved parameter and is ignore for now
  2634. * @returns the current unchanged quaternion
  2635. */
  2636. toEulerAnglesToRef(result: Vector3): Quaternion;
  2637. /**
  2638. * Updates the given rotation matrix with the current quaternion values
  2639. * @param result defines the target matrix
  2640. * @returns the current unchanged quaternion
  2641. */
  2642. toRotationMatrix(result: Matrix): Quaternion;
  2643. /**
  2644. * Updates the current quaternion from the given rotation matrix values
  2645. * @param matrix defines the source matrix
  2646. * @returns the current updated quaternion
  2647. */
  2648. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2649. /**
  2650. * Creates a new quaternion from a rotation matrix
  2651. * @param matrix defines the source matrix
  2652. * @returns a new quaternion created from the given rotation matrix values
  2653. */
  2654. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2655. /**
  2656. * Updates the given quaternion with the given rotation matrix values
  2657. * @param matrix defines the source matrix
  2658. * @param result defines the target quaternion
  2659. */
  2660. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2661. /**
  2662. * Returns the dot product (float) between the quaternions "left" and "right"
  2663. * @param left defines the left operand
  2664. * @param right defines the right operand
  2665. * @returns the dot product
  2666. */
  2667. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2668. /**
  2669. * Checks if the two quaternions are close to each other
  2670. * @param quat0 defines the first quaternion to check
  2671. * @param quat1 defines the second quaternion to check
  2672. * @returns true if the two quaternions are close to each other
  2673. */
  2674. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2675. /**
  2676. * Creates an empty quaternion
  2677. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2678. */
  2679. static Zero(): Quaternion;
  2680. /**
  2681. * Inverse a given quaternion
  2682. * @param q defines the source quaternion
  2683. * @returns a new quaternion as the inverted current quaternion
  2684. */
  2685. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2686. /**
  2687. * Inverse a given quaternion
  2688. * @param q defines the source quaternion
  2689. * @param result the quaternion the result will be stored in
  2690. * @returns the result quaternion
  2691. */
  2692. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2693. /**
  2694. * Creates an identity quaternion
  2695. * @returns the identity quaternion
  2696. */
  2697. static Identity(): Quaternion;
  2698. /**
  2699. * Gets a boolean indicating if the given quaternion is identity
  2700. * @param quaternion defines the quaternion to check
  2701. * @returns true if the quaternion is identity
  2702. */
  2703. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2704. /**
  2705. * Creates a quaternion from a rotation around an axis
  2706. * @param axis defines the axis to use
  2707. * @param angle defines the angle to use
  2708. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2709. */
  2710. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2711. /**
  2712. * Creates a rotation around an axis and stores it into the given quaternion
  2713. * @param axis defines the axis to use
  2714. * @param angle defines the angle to use
  2715. * @param result defines the target quaternion
  2716. * @returns the target quaternion
  2717. */
  2718. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2719. /**
  2720. * Creates a new quaternion from data stored into an array
  2721. * @param array defines the data source
  2722. * @param offset defines the offset in the source array where the data starts
  2723. * @returns a new quaternion
  2724. */
  2725. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2726. /**
  2727. * Create a quaternion from Euler rotation angles
  2728. * @param x Pitch
  2729. * @param y Yaw
  2730. * @param z Roll
  2731. * @returns the new Quaternion
  2732. */
  2733. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2734. /**
  2735. * Updates a quaternion from Euler rotation angles
  2736. * @param x Pitch
  2737. * @param y Yaw
  2738. * @param z Roll
  2739. * @param result the quaternion to store the result
  2740. * @returns the updated quaternion
  2741. */
  2742. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2743. /**
  2744. * Create a quaternion from Euler rotation vector
  2745. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2746. * @returns the new Quaternion
  2747. */
  2748. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2749. /**
  2750. * Updates a quaternion from Euler rotation vector
  2751. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2752. * @param result the quaternion to store the result
  2753. * @returns the updated quaternion
  2754. */
  2755. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2756. /**
  2757. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2758. * @param yaw defines the rotation around Y axis
  2759. * @param pitch defines the rotation around X axis
  2760. * @param roll defines the rotation around Z axis
  2761. * @returns the new quaternion
  2762. */
  2763. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2764. /**
  2765. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2766. * @param yaw defines the rotation around Y axis
  2767. * @param pitch defines the rotation around X axis
  2768. * @param roll defines the rotation around Z axis
  2769. * @param result defines the target quaternion
  2770. */
  2771. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2772. /**
  2773. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2774. * @param alpha defines the rotation around first axis
  2775. * @param beta defines the rotation around second axis
  2776. * @param gamma defines the rotation around third axis
  2777. * @returns the new quaternion
  2778. */
  2779. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2780. /**
  2781. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2782. * @param alpha defines the rotation around first axis
  2783. * @param beta defines the rotation around second axis
  2784. * @param gamma defines the rotation around third axis
  2785. * @param result defines the target quaternion
  2786. */
  2787. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2788. /**
  2789. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  2790. * @param axis1 defines the first axis
  2791. * @param axis2 defines the second axis
  2792. * @param axis3 defines the third axis
  2793. * @returns the new quaternion
  2794. */
  2795. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2796. /**
  2797. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  2798. * @param axis1 defines the first axis
  2799. * @param axis2 defines the second axis
  2800. * @param axis3 defines the third axis
  2801. * @param ref defines the target quaternion
  2802. */
  2803. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2804. /**
  2805. * Interpolates between two quaternions
  2806. * @param left defines first quaternion
  2807. * @param right defines second quaternion
  2808. * @param amount defines the gradient to use
  2809. * @returns the new interpolated quaternion
  2810. */
  2811. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2812. /**
  2813. * Interpolates between two quaternions and stores it into a target quaternion
  2814. * @param left defines first quaternion
  2815. * @param right defines second quaternion
  2816. * @param amount defines the gradient to use
  2817. * @param result defines the target quaternion
  2818. */
  2819. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2820. /**
  2821. * Interpolate between two quaternions using Hermite interpolation
  2822. * @param value1 defines first quaternion
  2823. * @param tangent1 defines the incoming tangent
  2824. * @param value2 defines second quaternion
  2825. * @param tangent2 defines the outgoing tangent
  2826. * @param amount defines the target quaternion
  2827. * @returns the new interpolated quaternion
  2828. */
  2829. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2830. }
  2831. /**
  2832. * Class used to store matrix data (4x4)
  2833. */
  2834. export class Matrix {
  2835. private static _updateFlagSeed;
  2836. private static _identityReadOnly;
  2837. private _isIdentity;
  2838. private _isIdentityDirty;
  2839. private _isIdentity3x2;
  2840. private _isIdentity3x2Dirty;
  2841. /**
  2842. * Gets the update flag of the matrix which is an unique number for the matrix.
  2843. * It will be incremented every time the matrix data change.
  2844. * You can use it to speed the comparison between two versions of the same matrix.
  2845. */
  2846. updateFlag: number;
  2847. private readonly _m;
  2848. /**
  2849. * Gets the internal data of the matrix
  2850. */
  2851. readonly m: DeepImmutable<Float32Array>;
  2852. /** @hidden */
  2853. _markAsUpdated(): void;
  2854. /** @hidden */
  2855. private _updateIdentityStatus;
  2856. /**
  2857. * Creates an empty matrix (filled with zeros)
  2858. */
  2859. constructor();
  2860. /**
  2861. * Check if the current matrix is identity
  2862. * @returns true is the matrix is the identity matrix
  2863. */
  2864. isIdentity(): boolean;
  2865. /**
  2866. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2867. * @returns true is the matrix is the identity matrix
  2868. */
  2869. isIdentityAs3x2(): boolean;
  2870. /**
  2871. * Gets the determinant of the matrix
  2872. * @returns the matrix determinant
  2873. */
  2874. determinant(): number;
  2875. /**
  2876. * Returns the matrix as a Float32Array
  2877. * @returns the matrix underlying array
  2878. */
  2879. toArray(): DeepImmutable<Float32Array>;
  2880. /**
  2881. * Returns the matrix as a Float32Array
  2882. * @returns the matrix underlying array.
  2883. */
  2884. asArray(): DeepImmutable<Float32Array>;
  2885. /**
  2886. * Inverts the current matrix in place
  2887. * @returns the current inverted matrix
  2888. */
  2889. invert(): Matrix;
  2890. /**
  2891. * Sets all the matrix elements to zero
  2892. * @returns the current matrix
  2893. */
  2894. reset(): Matrix;
  2895. /**
  2896. * Adds the current matrix with a second one
  2897. * @param other defines the matrix to add
  2898. * @returns a new matrix as the addition of the current matrix and the given one
  2899. */
  2900. add(other: DeepImmutable<Matrix>): Matrix;
  2901. /**
  2902. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2903. * @param other defines the matrix to add
  2904. * @param result defines the target matrix
  2905. * @returns the current matrix
  2906. */
  2907. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2908. /**
  2909. * Adds in place the given matrix to the current matrix
  2910. * @param other defines the second operand
  2911. * @returns the current updated matrix
  2912. */
  2913. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2914. /**
  2915. * Sets the given matrix to the current inverted Matrix
  2916. * @param other defines the target matrix
  2917. * @returns the unmodified current matrix
  2918. */
  2919. invertToRef(other: Matrix): Matrix;
  2920. /**
  2921. * add a value at the specified position in the current Matrix
  2922. * @param index the index of the value within the matrix. between 0 and 15.
  2923. * @param value the value to be added
  2924. * @returns the current updated matrix
  2925. */
  2926. addAtIndex(index: number, value: number): Matrix;
  2927. /**
  2928. * mutiply the specified position in the current Matrix by a value
  2929. * @param index the index of the value within the matrix. between 0 and 15.
  2930. * @param value the value to be added
  2931. * @returns the current updated matrix
  2932. */
  2933. multiplyAtIndex(index: number, value: number): Matrix;
  2934. /**
  2935. * Inserts the translation vector (using 3 floats) in the current matrix
  2936. * @param x defines the 1st component of the translation
  2937. * @param y defines the 2nd component of the translation
  2938. * @param z defines the 3rd component of the translation
  2939. * @returns the current updated matrix
  2940. */
  2941. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2942. /**
  2943. * Inserts the translation vector in the current matrix
  2944. * @param vector3 defines the translation to insert
  2945. * @returns the current updated matrix
  2946. */
  2947. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2948. /**
  2949. * Gets the translation value of the current matrix
  2950. * @returns a new Vector3 as the extracted translation from the matrix
  2951. */
  2952. getTranslation(): Vector3;
  2953. /**
  2954. * Fill a Vector3 with the extracted translation from the matrix
  2955. * @param result defines the Vector3 where to store the translation
  2956. * @returns the current matrix
  2957. */
  2958. getTranslationToRef(result: Vector3): Matrix;
  2959. /**
  2960. * Remove rotation and scaling part from the matrix
  2961. * @returns the updated matrix
  2962. */
  2963. removeRotationAndScaling(): Matrix;
  2964. /**
  2965. * Multiply two matrices
  2966. * @param other defines the second operand
  2967. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2968. */
  2969. multiply(other: DeepImmutable<Matrix>): Matrix;
  2970. /**
  2971. * Copy the current matrix from the given one
  2972. * @param other defines the source matrix
  2973. * @returns the current updated matrix
  2974. */
  2975. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2976. /**
  2977. * Populates the given array from the starting index with the current matrix values
  2978. * @param array defines the target array
  2979. * @param offset defines the offset in the target array where to start storing values
  2980. * @returns the current matrix
  2981. */
  2982. copyToArray(array: Float32Array, offset?: number): Matrix;
  2983. /**
  2984. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2985. * @param other defines the second operand
  2986. * @param result defines the matrix where to store the multiplication
  2987. * @returns the current matrix
  2988. */
  2989. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2990. /**
  2991. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2992. * @param other defines the second operand
  2993. * @param result defines the array where to store the multiplication
  2994. * @param offset defines the offset in the target array where to start storing values
  2995. * @returns the current matrix
  2996. */
  2997. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  2998. /**
  2999. * Check equality between this matrix and a second one
  3000. * @param value defines the second matrix to compare
  3001. * @returns true is the current matrix and the given one values are strictly equal
  3002. */
  3003. equals(value: DeepImmutable<Matrix>): boolean;
  3004. /**
  3005. * Clone the current matrix
  3006. * @returns a new matrix from the current matrix
  3007. */
  3008. clone(): Matrix;
  3009. /**
  3010. * Returns the name of the current matrix class
  3011. * @returns the string "Matrix"
  3012. */
  3013. getClassName(): string;
  3014. /**
  3015. * Gets the hash code of the current matrix
  3016. * @returns the hash code
  3017. */
  3018. getHashCode(): number;
  3019. /**
  3020. * Decomposes the current Matrix into a translation, rotation and scaling components
  3021. * @param scale defines the scale vector3 given as a reference to update
  3022. * @param rotation defines the rotation quaternion given as a reference to update
  3023. * @param translation defines the translation vector3 given as a reference to update
  3024. * @returns true if operation was successful
  3025. */
  3026. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3027. /**
  3028. * Gets specific row of the matrix
  3029. * @param index defines the number of the row to get
  3030. * @returns the index-th row of the current matrix as a new Vector4
  3031. */
  3032. getRow(index: number): Nullable<Vector4>;
  3033. /**
  3034. * Sets the index-th row of the current matrix to the vector4 values
  3035. * @param index defines the number of the row to set
  3036. * @param row defines the target vector4
  3037. * @returns the updated current matrix
  3038. */
  3039. setRow(index: number, row: Vector4): Matrix;
  3040. /**
  3041. * Compute the transpose of the matrix
  3042. * @returns the new transposed matrix
  3043. */
  3044. transpose(): Matrix;
  3045. /**
  3046. * Compute the transpose of the matrix and store it in a given matrix
  3047. * @param result defines the target matrix
  3048. * @returns the current matrix
  3049. */
  3050. transposeToRef(result: Matrix): Matrix;
  3051. /**
  3052. * Sets the index-th row of the current matrix with the given 4 x float values
  3053. * @param index defines the row index
  3054. * @param x defines the x component to set
  3055. * @param y defines the y component to set
  3056. * @param z defines the z component to set
  3057. * @param w defines the w component to set
  3058. * @returns the updated current matrix
  3059. */
  3060. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3061. /**
  3062. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3063. * @param scale defines the scale factor
  3064. * @returns a new matrix
  3065. */
  3066. scale(scale: number): Matrix;
  3067. /**
  3068. * Scale the current matrix values by a factor to a given result matrix
  3069. * @param scale defines the scale factor
  3070. * @param result defines the matrix to store the result
  3071. * @returns the current matrix
  3072. */
  3073. scaleToRef(scale: number, result: Matrix): Matrix;
  3074. /**
  3075. * Scale the current matrix values by a factor and add the result to a given matrix
  3076. * @param scale defines the scale factor
  3077. * @param result defines the Matrix to store the result
  3078. * @returns the current matrix
  3079. */
  3080. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3081. /**
  3082. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3083. * @param ref matrix to store the result
  3084. */
  3085. toNormalMatrix(ref: Matrix): void;
  3086. /**
  3087. * Gets only rotation part of the current matrix
  3088. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3089. */
  3090. getRotationMatrix(): Matrix;
  3091. /**
  3092. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3093. * @param result defines the target matrix to store data to
  3094. * @returns the current matrix
  3095. */
  3096. getRotationMatrixToRef(result: Matrix): Matrix;
  3097. /**
  3098. * Toggles model matrix from being right handed to left handed in place and vice versa
  3099. */
  3100. toggleModelMatrixHandInPlace(): void;
  3101. /**
  3102. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3103. */
  3104. toggleProjectionMatrixHandInPlace(): void;
  3105. /**
  3106. * Creates a matrix from an array
  3107. * @param array defines the source array
  3108. * @param offset defines an offset in the source array
  3109. * @returns a new Matrix set from the starting index of the given array
  3110. */
  3111. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3112. /**
  3113. * Copy the content of an array into a given matrix
  3114. * @param array defines the source array
  3115. * @param offset defines an offset in the source array
  3116. * @param result defines the target matrix
  3117. */
  3118. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3119. /**
  3120. * Stores an array into a matrix after having multiplied each component by a given factor
  3121. * @param array defines the source array
  3122. * @param offset defines the offset in the source array
  3123. * @param scale defines the scaling factor
  3124. * @param result defines the target matrix
  3125. */
  3126. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3127. /**
  3128. * Gets an identity matrix that must not be updated
  3129. */
  3130. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3131. /**
  3132. * Stores a list of values (16) inside a given matrix
  3133. * @param initialM11 defines 1st value of 1st row
  3134. * @param initialM12 defines 2nd value of 1st row
  3135. * @param initialM13 defines 3rd value of 1st row
  3136. * @param initialM14 defines 4th value of 1st row
  3137. * @param initialM21 defines 1st value of 2nd row
  3138. * @param initialM22 defines 2nd value of 2nd row
  3139. * @param initialM23 defines 3rd value of 2nd row
  3140. * @param initialM24 defines 4th value of 2nd row
  3141. * @param initialM31 defines 1st value of 3rd row
  3142. * @param initialM32 defines 2nd value of 3rd row
  3143. * @param initialM33 defines 3rd value of 3rd row
  3144. * @param initialM34 defines 4th value of 3rd row
  3145. * @param initialM41 defines 1st value of 4th row
  3146. * @param initialM42 defines 2nd value of 4th row
  3147. * @param initialM43 defines 3rd value of 4th row
  3148. * @param initialM44 defines 4th value of 4th row
  3149. * @param result defines the target matrix
  3150. */
  3151. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  3152. /**
  3153. * Creates new matrix from a list of values (16)
  3154. * @param initialM11 defines 1st value of 1st row
  3155. * @param initialM12 defines 2nd value of 1st row
  3156. * @param initialM13 defines 3rd value of 1st row
  3157. * @param initialM14 defines 4th value of 1st row
  3158. * @param initialM21 defines 1st value of 2nd row
  3159. * @param initialM22 defines 2nd value of 2nd row
  3160. * @param initialM23 defines 3rd value of 2nd row
  3161. * @param initialM24 defines 4th value of 2nd row
  3162. * @param initialM31 defines 1st value of 3rd row
  3163. * @param initialM32 defines 2nd value of 3rd row
  3164. * @param initialM33 defines 3rd value of 3rd row
  3165. * @param initialM34 defines 4th value of 3rd row
  3166. * @param initialM41 defines 1st value of 4th row
  3167. * @param initialM42 defines 2nd value of 4th row
  3168. * @param initialM43 defines 3rd value of 4th row
  3169. * @param initialM44 defines 4th value of 4th row
  3170. * @returns the new matrix
  3171. */
  3172. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  3173. /**
  3174. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3175. * @param scale defines the scale vector3
  3176. * @param rotation defines the rotation quaternion
  3177. * @param translation defines the translation vector3
  3178. * @returns a new matrix
  3179. */
  3180. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3181. /**
  3182. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3183. * @param scale defines the scale vector3
  3184. * @param rotation defines the rotation quaternion
  3185. * @param translation defines the translation vector3
  3186. * @param result defines the target matrix
  3187. */
  3188. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3189. /**
  3190. * Creates a new identity matrix
  3191. * @returns a new identity matrix
  3192. */
  3193. static Identity(): Matrix;
  3194. /**
  3195. * Creates a new identity matrix and stores the result in a given matrix
  3196. * @param result defines the target matrix
  3197. */
  3198. static IdentityToRef(result: Matrix): void;
  3199. /**
  3200. * Creates a new zero matrix
  3201. * @returns a new zero matrix
  3202. */
  3203. static Zero(): Matrix;
  3204. /**
  3205. * Creates a new rotation matrix for "angle" radians around the X axis
  3206. * @param angle defines the angle (in radians) to use
  3207. * @return the new matrix
  3208. */
  3209. static RotationX(angle: number): Matrix;
  3210. /**
  3211. * Creates a new matrix as the invert of a given matrix
  3212. * @param source defines the source matrix
  3213. * @returns the new matrix
  3214. */
  3215. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3216. /**
  3217. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3218. * @param angle defines the angle (in radians) to use
  3219. * @param result defines the target matrix
  3220. */
  3221. static RotationXToRef(angle: number, result: Matrix): void;
  3222. /**
  3223. * Creates a new rotation matrix for "angle" radians around the Y axis
  3224. * @param angle defines the angle (in radians) to use
  3225. * @return the new matrix
  3226. */
  3227. static RotationY(angle: number): Matrix;
  3228. /**
  3229. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3230. * @param angle defines the angle (in radians) to use
  3231. * @param result defines the target matrix
  3232. */
  3233. static RotationYToRef(angle: number, result: Matrix): void;
  3234. /**
  3235. * Creates a new rotation matrix for "angle" radians around the Z axis
  3236. * @param angle defines the angle (in radians) to use
  3237. * @return the new matrix
  3238. */
  3239. static RotationZ(angle: number): Matrix;
  3240. /**
  3241. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3242. * @param angle defines the angle (in radians) to use
  3243. * @param result defines the target matrix
  3244. */
  3245. static RotationZToRef(angle: number, result: Matrix): void;
  3246. /**
  3247. * Creates a new rotation matrix for "angle" radians around the given axis
  3248. * @param axis defines the axis to use
  3249. * @param angle defines the angle (in radians) to use
  3250. * @return the new matrix
  3251. */
  3252. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3253. /**
  3254. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3255. * @param axis defines the axis to use
  3256. * @param angle defines the angle (in radians) to use
  3257. * @param result defines the target matrix
  3258. */
  3259. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3260. /**
  3261. * Creates a rotation matrix
  3262. * @param yaw defines the yaw angle in radians (Y axis)
  3263. * @param pitch defines the pitch angle in radians (X axis)
  3264. * @param roll defines the roll angle in radians (X axis)
  3265. * @returns the new rotation matrix
  3266. */
  3267. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3268. /**
  3269. * Creates a rotation matrix and stores it in a given matrix
  3270. * @param yaw defines the yaw angle in radians (Y axis)
  3271. * @param pitch defines the pitch angle in radians (X axis)
  3272. * @param roll defines the roll angle in radians (X axis)
  3273. * @param result defines the target matrix
  3274. */
  3275. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3276. /**
  3277. * Creates a scaling matrix
  3278. * @param x defines the scale factor on X axis
  3279. * @param y defines the scale factor on Y axis
  3280. * @param z defines the scale factor on Z axis
  3281. * @returns the new matrix
  3282. */
  3283. static Scaling(x: number, y: number, z: number): Matrix;
  3284. /**
  3285. * Creates a scaling matrix and stores it in a given matrix
  3286. * @param x defines the scale factor on X axis
  3287. * @param y defines the scale factor on Y axis
  3288. * @param z defines the scale factor on Z axis
  3289. * @param result defines the target matrix
  3290. */
  3291. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3292. /**
  3293. * Creates a translation matrix
  3294. * @param x defines the translation on X axis
  3295. * @param y defines the translation on Y axis
  3296. * @param z defines the translationon Z axis
  3297. * @returns the new matrix
  3298. */
  3299. static Translation(x: number, y: number, z: number): Matrix;
  3300. /**
  3301. * Creates a translation matrix and stores it in a given matrix
  3302. * @param x defines the translation on X axis
  3303. * @param y defines the translation on Y axis
  3304. * @param z defines the translationon Z axis
  3305. * @param result defines the target matrix
  3306. */
  3307. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3308. /**
  3309. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3310. * @param startValue defines the start value
  3311. * @param endValue defines the end value
  3312. * @param gradient defines the gradient factor
  3313. * @returns the new matrix
  3314. */
  3315. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3316. /**
  3317. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3318. * @param startValue defines the start value
  3319. * @param endValue defines the end value
  3320. * @param gradient defines the gradient factor
  3321. * @param result defines the Matrix object where to store data
  3322. */
  3323. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3324. /**
  3325. * Builds a new matrix whose values are computed by:
  3326. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3327. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3328. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3329. * @param startValue defines the first matrix
  3330. * @param endValue defines the second matrix
  3331. * @param gradient defines the gradient between the two matrices
  3332. * @returns the new matrix
  3333. */
  3334. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3335. /**
  3336. * Update a matrix to values which are computed by:
  3337. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3338. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3339. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3340. * @param startValue defines the first matrix
  3341. * @param endValue defines the second matrix
  3342. * @param gradient defines the gradient between the two matrices
  3343. * @param result defines the target matrix
  3344. */
  3345. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3346. /**
  3347. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3348. * This function works in left handed mode
  3349. * @param eye defines the final position of the entity
  3350. * @param target defines where the entity should look at
  3351. * @param up defines the up vector for the entity
  3352. * @returns the new matrix
  3353. */
  3354. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3355. /**
  3356. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3357. * This function works in left handed mode
  3358. * @param eye defines the final position of the entity
  3359. * @param target defines where the entity should look at
  3360. * @param up defines the up vector for the entity
  3361. * @param result defines the target matrix
  3362. */
  3363. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3364. /**
  3365. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3366. * This function works in right handed mode
  3367. * @param eye defines the final position of the entity
  3368. * @param target defines where the entity should look at
  3369. * @param up defines the up vector for the entity
  3370. * @returns the new matrix
  3371. */
  3372. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3373. /**
  3374. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3375. * This function works in right handed mode
  3376. * @param eye defines the final position of the entity
  3377. * @param target defines where the entity should look at
  3378. * @param up defines the up vector for the entity
  3379. * @param result defines the target matrix
  3380. */
  3381. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3382. /**
  3383. * Create a left-handed orthographic projection matrix
  3384. * @param width defines the viewport width
  3385. * @param height defines the viewport height
  3386. * @param znear defines the near clip plane
  3387. * @param zfar defines the far clip plane
  3388. * @returns a new matrix as a left-handed orthographic projection matrix
  3389. */
  3390. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3391. /**
  3392. * Store a left-handed orthographic projection to a given matrix
  3393. * @param width defines the viewport width
  3394. * @param height defines the viewport height
  3395. * @param znear defines the near clip plane
  3396. * @param zfar defines the far clip plane
  3397. * @param result defines the target matrix
  3398. */
  3399. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3400. /**
  3401. * Create a left-handed orthographic projection matrix
  3402. * @param left defines the viewport left coordinate
  3403. * @param right defines the viewport right coordinate
  3404. * @param bottom defines the viewport bottom coordinate
  3405. * @param top defines the viewport top coordinate
  3406. * @param znear defines the near clip plane
  3407. * @param zfar defines the far clip plane
  3408. * @returns a new matrix as a left-handed orthographic projection matrix
  3409. */
  3410. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3411. /**
  3412. * Stores a left-handed orthographic projection into a given matrix
  3413. * @param left defines the viewport left coordinate
  3414. * @param right defines the viewport right coordinate
  3415. * @param bottom defines the viewport bottom coordinate
  3416. * @param top defines the viewport top coordinate
  3417. * @param znear defines the near clip plane
  3418. * @param zfar defines the far clip plane
  3419. * @param result defines the target matrix
  3420. */
  3421. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3422. /**
  3423. * Creates a right-handed orthographic projection matrix
  3424. * @param left defines the viewport left coordinate
  3425. * @param right defines the viewport right coordinate
  3426. * @param bottom defines the viewport bottom coordinate
  3427. * @param top defines the viewport top coordinate
  3428. * @param znear defines the near clip plane
  3429. * @param zfar defines the far clip plane
  3430. * @returns a new matrix as a right-handed orthographic projection matrix
  3431. */
  3432. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3433. /**
  3434. * Stores a right-handed orthographic projection into a given matrix
  3435. * @param left defines the viewport left coordinate
  3436. * @param right defines the viewport right coordinate
  3437. * @param bottom defines the viewport bottom coordinate
  3438. * @param top defines the viewport top coordinate
  3439. * @param znear defines the near clip plane
  3440. * @param zfar defines the far clip plane
  3441. * @param result defines the target matrix
  3442. */
  3443. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3444. /**
  3445. * Creates a left-handed perspective projection matrix
  3446. * @param width defines the viewport width
  3447. * @param height defines the viewport height
  3448. * @param znear defines the near clip plane
  3449. * @param zfar defines the far clip plane
  3450. * @returns a new matrix as a left-handed perspective projection matrix
  3451. */
  3452. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3453. /**
  3454. * Creates a left-handed perspective projection matrix
  3455. * @param fov defines the horizontal field of view
  3456. * @param aspect defines the aspect ratio
  3457. * @param znear defines the near clip plane
  3458. * @param zfar defines the far clip plane
  3459. * @returns a new matrix as a left-handed perspective projection matrix
  3460. */
  3461. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3462. /**
  3463. * Stores a left-handed perspective projection into a given matrix
  3464. * @param fov defines the horizontal field of view
  3465. * @param aspect defines the aspect ratio
  3466. * @param znear defines the near clip plane
  3467. * @param zfar defines the far clip plane
  3468. * @param result defines the target matrix
  3469. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3470. */
  3471. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3472. /**
  3473. * Creates a right-handed perspective projection matrix
  3474. * @param fov defines the horizontal field of view
  3475. * @param aspect defines the aspect ratio
  3476. * @param znear defines the near clip plane
  3477. * @param zfar defines the far clip plane
  3478. * @returns a new matrix as a right-handed perspective projection matrix
  3479. */
  3480. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3481. /**
  3482. * Stores a right-handed perspective projection into a given matrix
  3483. * @param fov defines the horizontal field of view
  3484. * @param aspect defines the aspect ratio
  3485. * @param znear defines the near clip plane
  3486. * @param zfar defines the far clip plane
  3487. * @param result defines the target matrix
  3488. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3489. */
  3490. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3491. /**
  3492. * Stores a perspective projection for WebVR info a given matrix
  3493. * @param fov defines the field of view
  3494. * @param znear defines the near clip plane
  3495. * @param zfar defines the far clip plane
  3496. * @param result defines the target matrix
  3497. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3498. */
  3499. static PerspectiveFovWebVRToRef(fov: {
  3500. upDegrees: number;
  3501. downDegrees: number;
  3502. leftDegrees: number;
  3503. rightDegrees: number;
  3504. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3505. /**
  3506. * Computes a complete transformation matrix
  3507. * @param viewport defines the viewport to use
  3508. * @param world defines the world matrix
  3509. * @param view defines the view matrix
  3510. * @param projection defines the projection matrix
  3511. * @param zmin defines the near clip plane
  3512. * @param zmax defines the far clip plane
  3513. * @returns the transformation matrix
  3514. */
  3515. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3516. /**
  3517. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3518. * @param matrix defines the matrix to use
  3519. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3520. */
  3521. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3522. /**
  3523. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3524. * @param matrix defines the matrix to use
  3525. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3526. */
  3527. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3528. /**
  3529. * Compute the transpose of a given matrix
  3530. * @param matrix defines the matrix to transpose
  3531. * @returns the new matrix
  3532. */
  3533. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3534. /**
  3535. * Compute the transpose of a matrix and store it in a target matrix
  3536. * @param matrix defines the matrix to transpose
  3537. * @param result defines the target matrix
  3538. */
  3539. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3540. /**
  3541. * Computes a reflection matrix from a plane
  3542. * @param plane defines the reflection plane
  3543. * @returns a new matrix
  3544. */
  3545. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3546. /**
  3547. * Computes a reflection matrix from a plane
  3548. * @param plane defines the reflection plane
  3549. * @param result defines the target matrix
  3550. */
  3551. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3552. /**
  3553. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3554. * @param xaxis defines the value of the 1st axis
  3555. * @param yaxis defines the value of the 2nd axis
  3556. * @param zaxis defines the value of the 3rd axis
  3557. * @param result defines the target matrix
  3558. */
  3559. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3560. /**
  3561. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3562. * @param quat defines the quaternion to use
  3563. * @param result defines the target matrix
  3564. */
  3565. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3566. }
  3567. /**
  3568. * Represens a plane by the equation ax + by + cz + d = 0
  3569. */
  3570. export class Plane {
  3571. /**
  3572. * Normal of the plane (a,b,c)
  3573. */
  3574. normal: Vector3;
  3575. /**
  3576. * d component of the plane
  3577. */
  3578. d: number;
  3579. /**
  3580. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3581. * @param a a component of the plane
  3582. * @param b b component of the plane
  3583. * @param c c component of the plane
  3584. * @param d d component of the plane
  3585. */
  3586. constructor(a: number, b: number, c: number, d: number);
  3587. /**
  3588. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3589. */
  3590. asArray(): number[];
  3591. /**
  3592. * @returns a new plane copied from the current Plane.
  3593. */
  3594. clone(): Plane;
  3595. /**
  3596. * @returns the string "Plane".
  3597. */
  3598. getClassName(): string;
  3599. /**
  3600. * @returns the Plane hash code.
  3601. */
  3602. getHashCode(): number;
  3603. /**
  3604. * Normalize the current Plane in place.
  3605. * @returns the updated Plane.
  3606. */
  3607. normalize(): Plane;
  3608. /**
  3609. * Applies a transformation the plane and returns the result
  3610. * @param transformation the transformation matrix to be applied to the plane
  3611. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3612. */
  3613. transform(transformation: DeepImmutable<Matrix>): Plane;
  3614. /**
  3615. * Calcualtte the dot product between the point and the plane normal
  3616. * @param point point to calculate the dot product with
  3617. * @returns the dot product (float) of the point coordinates and the plane normal.
  3618. */
  3619. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3620. /**
  3621. * Updates the current Plane from the plane defined by the three given points.
  3622. * @param point1 one of the points used to contruct the plane
  3623. * @param point2 one of the points used to contruct the plane
  3624. * @param point3 one of the points used to contruct the plane
  3625. * @returns the updated Plane.
  3626. */
  3627. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3628. /**
  3629. * Checks if the plane is facing a given direction
  3630. * @param direction the direction to check if the plane is facing
  3631. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3632. * @returns True is the vector "direction" is the same side than the plane normal.
  3633. */
  3634. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3635. /**
  3636. * Calculates the distance to a point
  3637. * @param point point to calculate distance to
  3638. * @returns the signed distance (float) from the given point to the Plane.
  3639. */
  3640. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3641. /**
  3642. * Creates a plane from an array
  3643. * @param array the array to create a plane from
  3644. * @returns a new Plane from the given array.
  3645. */
  3646. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3647. /**
  3648. * Creates a plane from three points
  3649. * @param point1 point used to create the plane
  3650. * @param point2 point used to create the plane
  3651. * @param point3 point used to create the plane
  3652. * @returns a new Plane defined by the three given points.
  3653. */
  3654. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3655. /**
  3656. * Creates a plane from an origin point and a normal
  3657. * @param origin origin of the plane to be constructed
  3658. * @param normal normal of the plane to be constructed
  3659. * @returns a new Plane the normal vector to this plane at the given origin point.
  3660. * Note : the vector "normal" is updated because normalized.
  3661. */
  3662. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3663. /**
  3664. * Calculates the distance from a plane and a point
  3665. * @param origin origin of the plane to be constructed
  3666. * @param normal normal of the plane to be constructed
  3667. * @param point point to calculate distance to
  3668. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3669. */
  3670. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3671. }
  3672. /**
  3673. * Class used to represent a viewport on screen
  3674. */
  3675. export class Viewport {
  3676. /** viewport left coordinate */
  3677. x: number;
  3678. /** viewport top coordinate */
  3679. y: number;
  3680. /**viewport width */
  3681. width: number;
  3682. /** viewport height */
  3683. height: number;
  3684. /**
  3685. * Creates a Viewport object located at (x, y) and sized (width, height)
  3686. * @param x defines viewport left coordinate
  3687. * @param y defines viewport top coordinate
  3688. * @param width defines the viewport width
  3689. * @param height defines the viewport height
  3690. */
  3691. constructor(
  3692. /** viewport left coordinate */
  3693. x: number,
  3694. /** viewport top coordinate */
  3695. y: number,
  3696. /**viewport width */
  3697. width: number,
  3698. /** viewport height */
  3699. height: number);
  3700. /**
  3701. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3702. * @param renderWidth defines the rendering width
  3703. * @param renderHeight defines the rendering height
  3704. * @returns a new Viewport
  3705. */
  3706. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3707. /**
  3708. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3709. * @param renderWidth defines the rendering width
  3710. * @param renderHeight defines the rendering height
  3711. * @param ref defines the target viewport
  3712. * @returns the current viewport
  3713. */
  3714. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3715. /**
  3716. * Returns a new Viewport copied from the current one
  3717. * @returns a new Viewport
  3718. */
  3719. clone(): Viewport;
  3720. }
  3721. /**
  3722. * Reprasents a camera frustum
  3723. */
  3724. export class Frustum {
  3725. /**
  3726. * Gets the planes representing the frustum
  3727. * @param transform matrix to be applied to the returned planes
  3728. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3729. */
  3730. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3731. /**
  3732. * Gets the near frustum plane transformed by the transform matrix
  3733. * @param transform transformation matrix to be applied to the resulting frustum plane
  3734. * @param frustumPlane the resuling frustum plane
  3735. */
  3736. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3737. /**
  3738. * Gets the far frustum plane transformed by the transform matrix
  3739. * @param transform transformation matrix to be applied to the resulting frustum plane
  3740. * @param frustumPlane the resuling frustum plane
  3741. */
  3742. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3743. /**
  3744. * Gets the left frustum plane transformed by the transform matrix
  3745. * @param transform transformation matrix to be applied to the resulting frustum plane
  3746. * @param frustumPlane the resuling frustum plane
  3747. */
  3748. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3749. /**
  3750. * Gets the right frustum plane transformed by the transform matrix
  3751. * @param transform transformation matrix to be applied to the resulting frustum plane
  3752. * @param frustumPlane the resuling frustum plane
  3753. */
  3754. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3755. /**
  3756. * Gets the top frustum plane transformed by the transform matrix
  3757. * @param transform transformation matrix to be applied to the resulting frustum plane
  3758. * @param frustumPlane the resuling frustum plane
  3759. */
  3760. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3761. /**
  3762. * Gets the bottom frustum plane transformed by the transform matrix
  3763. * @param transform transformation matrix to be applied to the resulting frustum plane
  3764. * @param frustumPlane the resuling frustum plane
  3765. */
  3766. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3767. /**
  3768. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3769. * @param transform transformation matrix to be applied to the resulting frustum planes
  3770. * @param frustumPlanes the resuling frustum planes
  3771. */
  3772. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3773. }
  3774. /** Defines supported spaces */
  3775. export enum Space {
  3776. /** Local (object) space */
  3777. LOCAL = 0,
  3778. /** World space */
  3779. WORLD = 1,
  3780. /** Bone space */
  3781. BONE = 2
  3782. }
  3783. /** Defines the 3 main axes */
  3784. export class Axis {
  3785. /** X axis */
  3786. static X: Vector3;
  3787. /** Y axis */
  3788. static Y: Vector3;
  3789. /** Z axis */
  3790. static Z: Vector3;
  3791. }
  3792. /** Class used to represent a Bezier curve */
  3793. export class BezierCurve {
  3794. /**
  3795. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3796. * @param t defines the time
  3797. * @param x1 defines the left coordinate on X axis
  3798. * @param y1 defines the left coordinate on Y axis
  3799. * @param x2 defines the right coordinate on X axis
  3800. * @param y2 defines the right coordinate on Y axis
  3801. * @returns the interpolated value
  3802. */
  3803. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3804. }
  3805. /**
  3806. * Defines potential orientation for back face culling
  3807. */
  3808. export enum Orientation {
  3809. /**
  3810. * Clockwise
  3811. */
  3812. CW = 0,
  3813. /** Counter clockwise */
  3814. CCW = 1
  3815. }
  3816. /**
  3817. * Defines angle representation
  3818. */
  3819. export class Angle {
  3820. private _radians;
  3821. /**
  3822. * Creates an Angle object of "radians" radians (float).
  3823. * @param radians the angle in radians
  3824. */
  3825. constructor(radians: number);
  3826. /**
  3827. * Get value in degrees
  3828. * @returns the Angle value in degrees (float)
  3829. */
  3830. degrees(): number;
  3831. /**
  3832. * Get value in radians
  3833. * @returns the Angle value in radians (float)
  3834. */
  3835. radians(): number;
  3836. /**
  3837. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3838. * @param a defines first vector
  3839. * @param b defines second vector
  3840. * @returns a new Angle
  3841. */
  3842. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3843. /**
  3844. * Gets a new Angle object from the given float in radians
  3845. * @param radians defines the angle value in radians
  3846. * @returns a new Angle
  3847. */
  3848. static FromRadians(radians: number): Angle;
  3849. /**
  3850. * Gets a new Angle object from the given float in degrees
  3851. * @param degrees defines the angle value in degrees
  3852. * @returns a new Angle
  3853. */
  3854. static FromDegrees(degrees: number): Angle;
  3855. }
  3856. /**
  3857. * This represents an arc in a 2d space.
  3858. */
  3859. export class Arc2 {
  3860. /** Defines the start point of the arc */
  3861. startPoint: Vector2;
  3862. /** Defines the mid point of the arc */
  3863. midPoint: Vector2;
  3864. /** Defines the end point of the arc */
  3865. endPoint: Vector2;
  3866. /**
  3867. * Defines the center point of the arc.
  3868. */
  3869. centerPoint: Vector2;
  3870. /**
  3871. * Defines the radius of the arc.
  3872. */
  3873. radius: number;
  3874. /**
  3875. * Defines the angle of the arc (from mid point to end point).
  3876. */
  3877. angle: Angle;
  3878. /**
  3879. * Defines the start angle of the arc (from start point to middle point).
  3880. */
  3881. startAngle: Angle;
  3882. /**
  3883. * Defines the orientation of the arc (clock wise/counter clock wise).
  3884. */
  3885. orientation: Orientation;
  3886. /**
  3887. * Creates an Arc object from the three given points : start, middle and end.
  3888. * @param startPoint Defines the start point of the arc
  3889. * @param midPoint Defines the midlle point of the arc
  3890. * @param endPoint Defines the end point of the arc
  3891. */
  3892. constructor(
  3893. /** Defines the start point of the arc */
  3894. startPoint: Vector2,
  3895. /** Defines the mid point of the arc */
  3896. midPoint: Vector2,
  3897. /** Defines the end point of the arc */
  3898. endPoint: Vector2);
  3899. }
  3900. /**
  3901. * Represents a 2D path made up of multiple 2D points
  3902. */
  3903. export class Path2 {
  3904. private _points;
  3905. private _length;
  3906. /**
  3907. * If the path start and end point are the same
  3908. */
  3909. closed: boolean;
  3910. /**
  3911. * Creates a Path2 object from the starting 2D coordinates x and y.
  3912. * @param x the starting points x value
  3913. * @param y the starting points y value
  3914. */
  3915. constructor(x: number, y: number);
  3916. /**
  3917. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3918. * @param x the added points x value
  3919. * @param y the added points y value
  3920. * @returns the updated Path2.
  3921. */
  3922. addLineTo(x: number, y: number): Path2;
  3923. /**
  3924. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  3925. * @param midX middle point x value
  3926. * @param midY middle point y value
  3927. * @param endX end point x value
  3928. * @param endY end point y value
  3929. * @param numberOfSegments (default: 36)
  3930. * @returns the updated Path2.
  3931. */
  3932. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3933. /**
  3934. * Closes the Path2.
  3935. * @returns the Path2.
  3936. */
  3937. close(): Path2;
  3938. /**
  3939. * Gets the sum of the distance between each sequential point in the path
  3940. * @returns the Path2 total length (float).
  3941. */
  3942. length(): number;
  3943. /**
  3944. * Gets the points which construct the path
  3945. * @returns the Path2 internal array of points.
  3946. */
  3947. getPoints(): Vector2[];
  3948. /**
  3949. * Retreives the point at the distance aways from the starting point
  3950. * @param normalizedLengthPosition the length along the path to retreive the point from
  3951. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3952. */
  3953. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3954. /**
  3955. * Creates a new path starting from an x and y position
  3956. * @param x starting x value
  3957. * @param y starting y value
  3958. * @returns a new Path2 starting at the coordinates (x, y).
  3959. */
  3960. static StartingAt(x: number, y: number): Path2;
  3961. }
  3962. /**
  3963. * Represents a 3D path made up of multiple 3D points
  3964. */
  3965. export class Path3D {
  3966. /**
  3967. * an array of Vector3, the curve axis of the Path3D
  3968. */
  3969. path: Vector3[];
  3970. private _curve;
  3971. private _distances;
  3972. private _tangents;
  3973. private _normals;
  3974. private _binormals;
  3975. private _raw;
  3976. /**
  3977. * new Path3D(path, normal, raw)
  3978. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3979. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3980. * @param path an array of Vector3, the curve axis of the Path3D
  3981. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3982. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  3983. */
  3984. constructor(
  3985. /**
  3986. * an array of Vector3, the curve axis of the Path3D
  3987. */
  3988. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  3989. /**
  3990. * Returns the Path3D array of successive Vector3 designing its curve.
  3991. * @returns the Path3D array of successive Vector3 designing its curve.
  3992. */
  3993. getCurve(): Vector3[];
  3994. /**
  3995. * Returns an array populated with tangent vectors on each Path3D curve point.
  3996. * @returns an array populated with tangent vectors on each Path3D curve point.
  3997. */
  3998. getTangents(): Vector3[];
  3999. /**
  4000. * Returns an array populated with normal vectors on each Path3D curve point.
  4001. * @returns an array populated with normal vectors on each Path3D curve point.
  4002. */
  4003. getNormals(): Vector3[];
  4004. /**
  4005. * Returns an array populated with binormal vectors on each Path3D curve point.
  4006. * @returns an array populated with binormal vectors on each Path3D curve point.
  4007. */
  4008. getBinormals(): Vector3[];
  4009. /**
  4010. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4011. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4012. */
  4013. getDistances(): number[];
  4014. /**
  4015. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4016. * @param path path which all values are copied into the curves points
  4017. * @param firstNormal which should be projected onto the curve
  4018. * @returns the same object updated.
  4019. */
  4020. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4021. private _compute;
  4022. private _getFirstNonNullVector;
  4023. private _getLastNonNullVector;
  4024. private _normalVector;
  4025. }
  4026. /**
  4027. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4028. * A Curve3 is designed from a series of successive Vector3.
  4029. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4030. */
  4031. export class Curve3 {
  4032. private _points;
  4033. private _length;
  4034. /**
  4035. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4036. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4037. * @param v1 (Vector3) the control point
  4038. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4039. * @param nbPoints (integer) the wanted number of points in the curve
  4040. * @returns the created Curve3
  4041. */
  4042. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4043. /**
  4044. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4045. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4046. * @param v1 (Vector3) the first control point
  4047. * @param v2 (Vector3) the second control point
  4048. * @param v3 (Vector3) the end point of the Cubic Bezier
  4049. * @param nbPoints (integer) the wanted number of points in the curve
  4050. * @returns the created Curve3
  4051. */
  4052. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4053. /**
  4054. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4055. * @param p1 (Vector3) the origin point of the Hermite Spline
  4056. * @param t1 (Vector3) the tangent vector at the origin point
  4057. * @param p2 (Vector3) the end point of the Hermite Spline
  4058. * @param t2 (Vector3) the tangent vector at the end point
  4059. * @param nbPoints (integer) the wanted number of points in the curve
  4060. * @returns the created Curve3
  4061. */
  4062. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4063. /**
  4064. * Returns a Curve3 object along a CatmullRom Spline curve :
  4065. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4066. * @param nbPoints (integer) the wanted number of points between each curve control points
  4067. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4068. * @returns the created Curve3
  4069. */
  4070. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4071. /**
  4072. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4073. * A Curve3 is designed from a series of successive Vector3.
  4074. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4075. * @param points points which make up the curve
  4076. */
  4077. constructor(points: Vector3[]);
  4078. /**
  4079. * @returns the Curve3 stored array of successive Vector3
  4080. */
  4081. getPoints(): Vector3[];
  4082. /**
  4083. * @returns the computed length (float) of the curve.
  4084. */
  4085. length(): number;
  4086. /**
  4087. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4088. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4089. * curveA and curveB keep unchanged.
  4090. * @param curve the curve to continue from this curve
  4091. * @returns the newly constructed curve
  4092. */
  4093. continue(curve: DeepImmutable<Curve3>): Curve3;
  4094. private _computeLength;
  4095. }
  4096. /**
  4097. * Contains position and normal vectors for a vertex
  4098. */
  4099. export class PositionNormalVertex {
  4100. /** the position of the vertex (defaut: 0,0,0) */
  4101. position: Vector3;
  4102. /** the normal of the vertex (defaut: 0,1,0) */
  4103. normal: Vector3;
  4104. /**
  4105. * Creates a PositionNormalVertex
  4106. * @param position the position of the vertex (defaut: 0,0,0)
  4107. * @param normal the normal of the vertex (defaut: 0,1,0)
  4108. */
  4109. constructor(
  4110. /** the position of the vertex (defaut: 0,0,0) */
  4111. position?: Vector3,
  4112. /** the normal of the vertex (defaut: 0,1,0) */
  4113. normal?: Vector3);
  4114. /**
  4115. * Clones the PositionNormalVertex
  4116. * @returns the cloned PositionNormalVertex
  4117. */
  4118. clone(): PositionNormalVertex;
  4119. }
  4120. /**
  4121. * Contains position, normal and uv vectors for a vertex
  4122. */
  4123. export class PositionNormalTextureVertex {
  4124. /** the position of the vertex (defaut: 0,0,0) */
  4125. position: Vector3;
  4126. /** the normal of the vertex (defaut: 0,1,0) */
  4127. normal: Vector3;
  4128. /** the uv of the vertex (default: 0,0) */
  4129. uv: Vector2;
  4130. /**
  4131. * Creates a PositionNormalTextureVertex
  4132. * @param position the position of the vertex (defaut: 0,0,0)
  4133. * @param normal the normal of the vertex (defaut: 0,1,0)
  4134. * @param uv the uv of the vertex (default: 0,0)
  4135. */
  4136. constructor(
  4137. /** the position of the vertex (defaut: 0,0,0) */
  4138. position?: Vector3,
  4139. /** the normal of the vertex (defaut: 0,1,0) */
  4140. normal?: Vector3,
  4141. /** the uv of the vertex (default: 0,0) */
  4142. uv?: Vector2);
  4143. /**
  4144. * Clones the PositionNormalTextureVertex
  4145. * @returns the cloned PositionNormalTextureVertex
  4146. */
  4147. clone(): PositionNormalTextureVertex;
  4148. }
  4149. /**
  4150. * @hidden
  4151. */
  4152. export class Tmp {
  4153. static Color3: Color3[];
  4154. static Color4: Color4[];
  4155. static Vector2: Vector2[];
  4156. static Vector3: Vector3[];
  4157. static Vector4: Vector4[];
  4158. static Quaternion: Quaternion[];
  4159. static Matrix: Matrix[];
  4160. }
  4161. }
  4162. declare module "babylonjs/Offline/IOfflineProvider" {
  4163. /**
  4164. * Class used to enable access to offline support
  4165. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4166. */
  4167. export interface IOfflineProvider {
  4168. /**
  4169. * Gets a boolean indicating if scene must be saved in the database
  4170. */
  4171. enableSceneOffline: boolean;
  4172. /**
  4173. * Gets a boolean indicating if textures must be saved in the database
  4174. */
  4175. enableTexturesOffline: boolean;
  4176. /**
  4177. * Open the offline support and make it available
  4178. * @param successCallback defines the callback to call on success
  4179. * @param errorCallback defines the callback to call on error
  4180. */
  4181. open(successCallback: () => void, errorCallback: () => void): void;
  4182. /**
  4183. * Loads an image from the offline support
  4184. * @param url defines the url to load from
  4185. * @param image defines the target DOM image
  4186. */
  4187. loadImage(url: string, image: HTMLImageElement): void;
  4188. /**
  4189. * Loads a file from offline support
  4190. * @param url defines the URL to load from
  4191. * @param sceneLoaded defines a callback to call on success
  4192. * @param progressCallBack defines a callback to call when progress changed
  4193. * @param errorCallback defines a callback to call on error
  4194. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4195. */
  4196. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4197. }
  4198. }
  4199. declare module "babylonjs/Misc/observable" {
  4200. import { Nullable } from "babylonjs/types";
  4201. /**
  4202. * A class serves as a medium between the observable and its observers
  4203. */
  4204. export class EventState {
  4205. /**
  4206. * Create a new EventState
  4207. * @param mask defines the mask associated with this state
  4208. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4209. * @param target defines the original target of the state
  4210. * @param currentTarget defines the current target of the state
  4211. */
  4212. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4213. /**
  4214. * Initialize the current event state
  4215. * @param mask defines the mask associated with this state
  4216. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4217. * @param target defines the original target of the state
  4218. * @param currentTarget defines the current target of the state
  4219. * @returns the current event state
  4220. */
  4221. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4222. /**
  4223. * An Observer can set this property to true to prevent subsequent observers of being notified
  4224. */
  4225. skipNextObservers: boolean;
  4226. /**
  4227. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4228. */
  4229. mask: number;
  4230. /**
  4231. * The object that originally notified the event
  4232. */
  4233. target?: any;
  4234. /**
  4235. * The current object in the bubbling phase
  4236. */
  4237. currentTarget?: any;
  4238. /**
  4239. * This will be populated with the return value of the last function that was executed.
  4240. * If it is the first function in the callback chain it will be the event data.
  4241. */
  4242. lastReturnValue?: any;
  4243. }
  4244. /**
  4245. * Represent an Observer registered to a given Observable object.
  4246. */
  4247. export class Observer<T> {
  4248. /**
  4249. * Defines the callback to call when the observer is notified
  4250. */
  4251. callback: (eventData: T, eventState: EventState) => void;
  4252. /**
  4253. * Defines the mask of the observer (used to filter notifications)
  4254. */
  4255. mask: number;
  4256. /**
  4257. * Defines the current scope used to restore the JS context
  4258. */
  4259. scope: any;
  4260. /** @hidden */
  4261. _willBeUnregistered: boolean;
  4262. /**
  4263. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4264. */
  4265. unregisterOnNextCall: boolean;
  4266. /**
  4267. * Creates a new observer
  4268. * @param callback defines the callback to call when the observer is notified
  4269. * @param mask defines the mask of the observer (used to filter notifications)
  4270. * @param scope defines the current scope used to restore the JS context
  4271. */
  4272. constructor(
  4273. /**
  4274. * Defines the callback to call when the observer is notified
  4275. */
  4276. callback: (eventData: T, eventState: EventState) => void,
  4277. /**
  4278. * Defines the mask of the observer (used to filter notifications)
  4279. */
  4280. mask: number,
  4281. /**
  4282. * Defines the current scope used to restore the JS context
  4283. */
  4284. scope?: any);
  4285. }
  4286. /**
  4287. * Represent a list of observers registered to multiple Observables object.
  4288. */
  4289. export class MultiObserver<T> {
  4290. private _observers;
  4291. private _observables;
  4292. /**
  4293. * Release associated resources
  4294. */
  4295. dispose(): void;
  4296. /**
  4297. * Raise a callback when one of the observable will notify
  4298. * @param observables defines a list of observables to watch
  4299. * @param callback defines the callback to call on notification
  4300. * @param mask defines the mask used to filter notifications
  4301. * @param scope defines the current scope used to restore the JS context
  4302. * @returns the new MultiObserver
  4303. */
  4304. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4305. }
  4306. /**
  4307. * The Observable class is a simple implementation of the Observable pattern.
  4308. *
  4309. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  4310. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4311. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  4312. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  4313. */
  4314. export class Observable<T> {
  4315. private _observers;
  4316. private _eventState;
  4317. private _onObserverAdded;
  4318. /**
  4319. * Creates a new observable
  4320. * @param onObserverAdded defines a callback to call when a new observer is added
  4321. */
  4322. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4323. /**
  4324. * Create a new Observer with the specified callback
  4325. * @param callback the callback that will be executed for that Observer
  4326. * @param mask the mask used to filter observers
  4327. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  4328. * @param scope optional scope for the callback to be called from
  4329. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4330. * @returns the new observer created for the callback
  4331. */
  4332. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4333. /**
  4334. * Create a new Observer with the specified callback and unregisters after the next notification
  4335. * @param callback the callback that will be executed for that Observer
  4336. * @returns the new observer created for the callback
  4337. */
  4338. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4339. /**
  4340. * Remove an Observer from the Observable object
  4341. * @param observer the instance of the Observer to remove
  4342. * @returns false if it doesn't belong to this Observable
  4343. */
  4344. remove(observer: Nullable<Observer<T>>): boolean;
  4345. /**
  4346. * Remove a callback from the Observable object
  4347. * @param callback the callback to remove
  4348. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4349. * @returns false if it doesn't belong to this Observable
  4350. */
  4351. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4352. private _deferUnregister;
  4353. private _remove;
  4354. /**
  4355. * Notify all Observers by calling their respective callback with the given data
  4356. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4357. * @param eventData defines the data to send to all observers
  4358. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4359. * @param target defines the original target of the state
  4360. * @param currentTarget defines the current target of the state
  4361. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4362. */
  4363. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4364. /**
  4365. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4366. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4367. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4368. * and it is crucial that all callbacks will be executed.
  4369. * The order of the callbacks is kept, callbacks are not executed parallel.
  4370. *
  4371. * @param eventData The data to be sent to each callback
  4372. * @param mask is used to filter observers defaults to -1
  4373. * @param target defines the callback target (see EventState)
  4374. * @param currentTarget defines he current object in the bubbling phase
  4375. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4376. */
  4377. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4378. /**
  4379. * Notify a specific observer
  4380. * @param observer defines the observer to notify
  4381. * @param eventData defines the data to be sent to each callback
  4382. * @param mask is used to filter observers defaults to -1
  4383. */
  4384. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4385. /**
  4386. * Gets a boolean indicating if the observable has at least one observer
  4387. * @returns true is the Observable has at least one Observer registered
  4388. */
  4389. hasObservers(): boolean;
  4390. /**
  4391. * Clear the list of observers
  4392. */
  4393. clear(): void;
  4394. /**
  4395. * Clone the current observable
  4396. * @returns a new observable
  4397. */
  4398. clone(): Observable<T>;
  4399. /**
  4400. * Does this observable handles observer registered with a given mask
  4401. * @param mask defines the mask to be tested
  4402. * @return whether or not one observer registered with the given mask is handeled
  4403. **/
  4404. hasSpecificMask(mask?: number): boolean;
  4405. }
  4406. }
  4407. declare module "babylonjs/Misc/filesInputStore" {
  4408. /**
  4409. * Class used to help managing file picking and drag'n'drop
  4410. * File Storage
  4411. */
  4412. export class FilesInputStore {
  4413. /**
  4414. * List of files ready to be loaded
  4415. */
  4416. static FilesToLoad: {
  4417. [key: string]: File;
  4418. };
  4419. }
  4420. }
  4421. declare module "babylonjs/Engines/constants" {
  4422. /** Defines the cross module used constants to avoid circular dependncies */
  4423. export class Constants {
  4424. /** Defines that alpha blending is disabled */
  4425. static readonly ALPHA_DISABLE: number;
  4426. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4427. static readonly ALPHA_ADD: number;
  4428. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4429. static readonly ALPHA_COMBINE: number;
  4430. /** Defines that alpha blending to DEST - SRC * DEST */
  4431. static readonly ALPHA_SUBTRACT: number;
  4432. /** Defines that alpha blending to SRC * DEST */
  4433. static readonly ALPHA_MULTIPLY: number;
  4434. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4435. static readonly ALPHA_MAXIMIZED: number;
  4436. /** Defines that alpha blending to SRC + DEST */
  4437. static readonly ALPHA_ONEONE: number;
  4438. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4439. static readonly ALPHA_PREMULTIPLIED: number;
  4440. /**
  4441. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4442. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4443. */
  4444. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4445. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4446. static readonly ALPHA_INTERPOLATE: number;
  4447. /**
  4448. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4449. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4450. */
  4451. static readonly ALPHA_SCREENMODE: number;
  4452. /** Defines that the ressource is not delayed*/
  4453. static readonly DELAYLOADSTATE_NONE: number;
  4454. /** Defines that the ressource was successfully delay loaded */
  4455. static readonly DELAYLOADSTATE_LOADED: number;
  4456. /** Defines that the ressource is currently delay loading */
  4457. static readonly DELAYLOADSTATE_LOADING: number;
  4458. /** Defines that the ressource is delayed and has not started loading */
  4459. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4460. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4461. static readonly NEVER: number;
  4462. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  4463. static readonly ALWAYS: number;
  4464. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4465. static readonly LESS: number;
  4466. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4467. static readonly EQUAL: number;
  4468. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  4469. static readonly LEQUAL: number;
  4470. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4471. static readonly GREATER: number;
  4472. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  4473. static readonly GEQUAL: number;
  4474. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  4475. static readonly NOTEQUAL: number;
  4476. /** Passed to stencilOperation to specify that stencil value must be kept */
  4477. static readonly KEEP: number;
  4478. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4479. static readonly REPLACE: number;
  4480. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4481. static readonly INCR: number;
  4482. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4483. static readonly DECR: number;
  4484. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4485. static readonly INVERT: number;
  4486. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4487. static readonly INCR_WRAP: number;
  4488. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4489. static readonly DECR_WRAP: number;
  4490. /** Texture is not repeating outside of 0..1 UVs */
  4491. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4492. /** Texture is repeating outside of 0..1 UVs */
  4493. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4494. /** Texture is repeating and mirrored */
  4495. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4496. /** ALPHA */
  4497. static readonly TEXTUREFORMAT_ALPHA: number;
  4498. /** LUMINANCE */
  4499. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4500. /** LUMINANCE_ALPHA */
  4501. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4502. /** RGB */
  4503. static readonly TEXTUREFORMAT_RGB: number;
  4504. /** RGBA */
  4505. static readonly TEXTUREFORMAT_RGBA: number;
  4506. /** RED */
  4507. static readonly TEXTUREFORMAT_RED: number;
  4508. /** RED (2nd reference) */
  4509. static readonly TEXTUREFORMAT_R: number;
  4510. /** RG */
  4511. static readonly TEXTUREFORMAT_RG: number;
  4512. /** RED_INTEGER */
  4513. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4514. /** RED_INTEGER (2nd reference) */
  4515. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4516. /** RG_INTEGER */
  4517. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4518. /** RGB_INTEGER */
  4519. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4520. /** RGBA_INTEGER */
  4521. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4522. /** UNSIGNED_BYTE */
  4523. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4524. /** UNSIGNED_BYTE (2nd reference) */
  4525. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4526. /** FLOAT */
  4527. static readonly TEXTURETYPE_FLOAT: number;
  4528. /** HALF_FLOAT */
  4529. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4530. /** BYTE */
  4531. static readonly TEXTURETYPE_BYTE: number;
  4532. /** SHORT */
  4533. static readonly TEXTURETYPE_SHORT: number;
  4534. /** UNSIGNED_SHORT */
  4535. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4536. /** INT */
  4537. static readonly TEXTURETYPE_INT: number;
  4538. /** UNSIGNED_INT */
  4539. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4540. /** UNSIGNED_SHORT_4_4_4_4 */
  4541. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4542. /** UNSIGNED_SHORT_5_5_5_1 */
  4543. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4544. /** UNSIGNED_SHORT_5_6_5 */
  4545. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4546. /** UNSIGNED_INT_2_10_10_10_REV */
  4547. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4548. /** UNSIGNED_INT_24_8 */
  4549. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4550. /** UNSIGNED_INT_10F_11F_11F_REV */
  4551. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4552. /** UNSIGNED_INT_5_9_9_9_REV */
  4553. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4554. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4555. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4556. /** nearest is mag = nearest and min = nearest and mip = linear */
  4557. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4558. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4559. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4560. /** Trilinear is mag = linear and min = linear and mip = linear */
  4561. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4562. /** nearest is mag = nearest and min = nearest and mip = linear */
  4563. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4564. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4565. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4566. /** Trilinear is mag = linear and min = linear and mip = linear */
  4567. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4568. /** mag = nearest and min = nearest and mip = nearest */
  4569. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4570. /** mag = nearest and min = linear and mip = nearest */
  4571. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4572. /** mag = nearest and min = linear and mip = linear */
  4573. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4574. /** mag = nearest and min = linear and mip = none */
  4575. static readonly TEXTURE_NEAREST_LINEAR: number;
  4576. /** mag = nearest and min = nearest and mip = none */
  4577. static readonly TEXTURE_NEAREST_NEAREST: number;
  4578. /** mag = linear and min = nearest and mip = nearest */
  4579. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4580. /** mag = linear and min = nearest and mip = linear */
  4581. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4582. /** mag = linear and min = linear and mip = none */
  4583. static readonly TEXTURE_LINEAR_LINEAR: number;
  4584. /** mag = linear and min = nearest and mip = none */
  4585. static readonly TEXTURE_LINEAR_NEAREST: number;
  4586. /** Explicit coordinates mode */
  4587. static readonly TEXTURE_EXPLICIT_MODE: number;
  4588. /** Spherical coordinates mode */
  4589. static readonly TEXTURE_SPHERICAL_MODE: number;
  4590. /** Planar coordinates mode */
  4591. static readonly TEXTURE_PLANAR_MODE: number;
  4592. /** Cubic coordinates mode */
  4593. static readonly TEXTURE_CUBIC_MODE: number;
  4594. /** Projection coordinates mode */
  4595. static readonly TEXTURE_PROJECTION_MODE: number;
  4596. /** Skybox coordinates mode */
  4597. static readonly TEXTURE_SKYBOX_MODE: number;
  4598. /** Inverse Cubic coordinates mode */
  4599. static readonly TEXTURE_INVCUBIC_MODE: number;
  4600. /** Equirectangular coordinates mode */
  4601. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4602. /** Equirectangular Fixed coordinates mode */
  4603. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4604. /** Equirectangular Fixed Mirrored coordinates mode */
  4605. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4606. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4607. static readonly SCALEMODE_FLOOR: number;
  4608. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4609. static readonly SCALEMODE_NEAREST: number;
  4610. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4611. static readonly SCALEMODE_CEILING: number;
  4612. /**
  4613. * The dirty texture flag value
  4614. */
  4615. static readonly MATERIAL_TextureDirtyFlag: number;
  4616. /**
  4617. * The dirty light flag value
  4618. */
  4619. static readonly MATERIAL_LightDirtyFlag: number;
  4620. /**
  4621. * The dirty fresnel flag value
  4622. */
  4623. static readonly MATERIAL_FresnelDirtyFlag: number;
  4624. /**
  4625. * The dirty attribute flag value
  4626. */
  4627. static readonly MATERIAL_AttributesDirtyFlag: number;
  4628. /**
  4629. * The dirty misc flag value
  4630. */
  4631. static readonly MATERIAL_MiscDirtyFlag: number;
  4632. /**
  4633. * The all dirty flag value
  4634. */
  4635. static readonly MATERIAL_AllDirtyFlag: number;
  4636. /**
  4637. * Returns the triangle fill mode
  4638. */
  4639. static readonly MATERIAL_TriangleFillMode: number;
  4640. /**
  4641. * Returns the wireframe mode
  4642. */
  4643. static readonly MATERIAL_WireFrameFillMode: number;
  4644. /**
  4645. * Returns the point fill mode
  4646. */
  4647. static readonly MATERIAL_PointFillMode: number;
  4648. /**
  4649. * Returns the point list draw mode
  4650. */
  4651. static readonly MATERIAL_PointListDrawMode: number;
  4652. /**
  4653. * Returns the line list draw mode
  4654. */
  4655. static readonly MATERIAL_LineListDrawMode: number;
  4656. /**
  4657. * Returns the line loop draw mode
  4658. */
  4659. static readonly MATERIAL_LineLoopDrawMode: number;
  4660. /**
  4661. * Returns the line strip draw mode
  4662. */
  4663. static readonly MATERIAL_LineStripDrawMode: number;
  4664. /**
  4665. * Returns the triangle strip draw mode
  4666. */
  4667. static readonly MATERIAL_TriangleStripDrawMode: number;
  4668. /**
  4669. * Returns the triangle fan draw mode
  4670. */
  4671. static readonly MATERIAL_TriangleFanDrawMode: number;
  4672. /**
  4673. * Stores the clock-wise side orientation
  4674. */
  4675. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4676. /**
  4677. * Stores the counter clock-wise side orientation
  4678. */
  4679. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4680. /**
  4681. * Nothing
  4682. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4683. */
  4684. static readonly ACTION_NothingTrigger: number;
  4685. /**
  4686. * On pick
  4687. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4688. */
  4689. static readonly ACTION_OnPickTrigger: number;
  4690. /**
  4691. * On left pick
  4692. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4693. */
  4694. static readonly ACTION_OnLeftPickTrigger: number;
  4695. /**
  4696. * On right pick
  4697. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4698. */
  4699. static readonly ACTION_OnRightPickTrigger: number;
  4700. /**
  4701. * On center pick
  4702. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4703. */
  4704. static readonly ACTION_OnCenterPickTrigger: number;
  4705. /**
  4706. * On pick down
  4707. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4708. */
  4709. static readonly ACTION_OnPickDownTrigger: number;
  4710. /**
  4711. * On double pick
  4712. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4713. */
  4714. static readonly ACTION_OnDoublePickTrigger: number;
  4715. /**
  4716. * On pick up
  4717. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4718. */
  4719. static readonly ACTION_OnPickUpTrigger: number;
  4720. /**
  4721. * On pick out.
  4722. * This trigger will only be raised if you also declared a OnPickDown
  4723. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4724. */
  4725. static readonly ACTION_OnPickOutTrigger: number;
  4726. /**
  4727. * On long press
  4728. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4729. */
  4730. static readonly ACTION_OnLongPressTrigger: number;
  4731. /**
  4732. * On pointer over
  4733. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4734. */
  4735. static readonly ACTION_OnPointerOverTrigger: number;
  4736. /**
  4737. * On pointer out
  4738. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4739. */
  4740. static readonly ACTION_OnPointerOutTrigger: number;
  4741. /**
  4742. * On every frame
  4743. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4744. */
  4745. static readonly ACTION_OnEveryFrameTrigger: number;
  4746. /**
  4747. * On intersection enter
  4748. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4749. */
  4750. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4751. /**
  4752. * On intersection exit
  4753. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4754. */
  4755. static readonly ACTION_OnIntersectionExitTrigger: number;
  4756. /**
  4757. * On key down
  4758. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4759. */
  4760. static readonly ACTION_OnKeyDownTrigger: number;
  4761. /**
  4762. * On key up
  4763. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4764. */
  4765. static readonly ACTION_OnKeyUpTrigger: number;
  4766. /**
  4767. * Billboard mode will only apply to Y axis
  4768. */
  4769. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4770. /**
  4771. * Billboard mode will apply to all axes
  4772. */
  4773. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4774. /**
  4775. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4776. */
  4777. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4778. /**
  4779. * Gets or sets base Assets URL
  4780. */
  4781. static readonly PARTICLES_BaseAssetsUrl: string;
  4782. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4783. * Test order :
  4784. * Is the bounding sphere outside the frustum ?
  4785. * If not, are the bounding box vertices outside the frustum ?
  4786. * It not, then the cullable object is in the frustum.
  4787. */
  4788. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4789. /** Culling strategy : Bounding Sphere Only.
  4790. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4791. * It's also less accurate than the standard because some not visible objects can still be selected.
  4792. * Test : is the bounding sphere outside the frustum ?
  4793. * If not, then the cullable object is in the frustum.
  4794. */
  4795. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4796. /** Culling strategy : Optimistic Inclusion.
  4797. * This in an inclusion test first, then the standard exclusion test.
  4798. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4799. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  4800. * Anyway, it's as accurate as the standard strategy.
  4801. * Test :
  4802. * Is the cullable object bounding sphere center in the frustum ?
  4803. * If not, apply the default culling strategy.
  4804. */
  4805. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4806. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4807. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4808. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4809. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  4810. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4811. * Test :
  4812. * Is the cullable object bounding sphere center in the frustum ?
  4813. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4814. */
  4815. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4816. /**
  4817. * No logging while loading
  4818. */
  4819. static readonly SCENELOADER_NO_LOGGING: number;
  4820. /**
  4821. * Minimal logging while loading
  4822. */
  4823. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4824. /**
  4825. * Summary logging while loading
  4826. */
  4827. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4828. /**
  4829. * Detailled logging while loading
  4830. */
  4831. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4832. }
  4833. }
  4834. declare module "babylonjs/Misc/domManagement" {
  4835. /**
  4836. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4837. * Babylon.js
  4838. */
  4839. export class DomManagement {
  4840. /**
  4841. * Checks if the window object exists
  4842. * @returns true if the window object exists
  4843. */
  4844. static IsWindowObjectExist(): boolean;
  4845. /**
  4846. * Extracts text content from a DOM element hierarchy
  4847. * @param element defines the root element
  4848. * @returns a string
  4849. */
  4850. static GetDOMTextContent(element: HTMLElement): string;
  4851. }
  4852. }
  4853. declare module "babylonjs/Misc/logger" {
  4854. /**
  4855. * Logger used througouht the application to allow configuration of
  4856. * the log level required for the messages.
  4857. */
  4858. export class Logger {
  4859. /**
  4860. * No log
  4861. */
  4862. static readonly NoneLogLevel: number;
  4863. /**
  4864. * Only message logs
  4865. */
  4866. static readonly MessageLogLevel: number;
  4867. /**
  4868. * Only warning logs
  4869. */
  4870. static readonly WarningLogLevel: number;
  4871. /**
  4872. * Only error logs
  4873. */
  4874. static readonly ErrorLogLevel: number;
  4875. /**
  4876. * All logs
  4877. */
  4878. static readonly AllLogLevel: number;
  4879. private static _LogCache;
  4880. /**
  4881. * Gets a value indicating the number of loading errors
  4882. * @ignorenaming
  4883. */
  4884. static errorsCount: number;
  4885. /**
  4886. * Callback called when a new log is added
  4887. */
  4888. static OnNewCacheEntry: (entry: string) => void;
  4889. private static _AddLogEntry;
  4890. private static _FormatMessage;
  4891. private static _LogDisabled;
  4892. private static _LogEnabled;
  4893. private static _WarnDisabled;
  4894. private static _WarnEnabled;
  4895. private static _ErrorDisabled;
  4896. private static _ErrorEnabled;
  4897. /**
  4898. * Log a message to the console
  4899. */
  4900. static Log: (message: string) => void;
  4901. /**
  4902. * Write a warning message to the console
  4903. */
  4904. static Warn: (message: string) => void;
  4905. /**
  4906. * Write an error message to the console
  4907. */
  4908. static Error: (message: string) => void;
  4909. /**
  4910. * Gets current log cache (list of logs)
  4911. */
  4912. static readonly LogCache: string;
  4913. /**
  4914. * Clears the log cache
  4915. */
  4916. static ClearLogCache(): void;
  4917. /**
  4918. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4919. */
  4920. static LogLevels: number;
  4921. }
  4922. }
  4923. declare module "babylonjs/Misc/typeStore" {
  4924. /** @hidden */
  4925. export class _TypeStore {
  4926. /** @hidden */
  4927. static RegisteredTypes: {
  4928. [key: string]: Object;
  4929. };
  4930. /** @hidden */
  4931. static GetClass(fqdn: string): any;
  4932. }
  4933. }
  4934. declare module "babylonjs/Misc/deepCopier" {
  4935. /**
  4936. * Class containing a set of static utilities functions for deep copy.
  4937. */
  4938. export class DeepCopier {
  4939. /**
  4940. * Tries to copy an object by duplicating every property
  4941. * @param source defines the source object
  4942. * @param destination defines the target object
  4943. * @param doNotCopyList defines a list of properties to avoid
  4944. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4945. */
  4946. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4947. }
  4948. }
  4949. declare module "babylonjs/Misc/precisionDate" {
  4950. /**
  4951. * Class containing a set of static utilities functions for precision date
  4952. */
  4953. export class PrecisionDate {
  4954. /**
  4955. * Gets either window.performance.now() if supported or Date.now() else
  4956. */
  4957. static readonly Now: number;
  4958. }
  4959. }
  4960. declare module "babylonjs/Misc/devTools" {
  4961. /** @hidden */
  4962. export class _DevTools {
  4963. static WarnImport(name: string): string;
  4964. }
  4965. }
  4966. declare module "babylonjs/Misc/andOrNotEvaluator" {
  4967. /**
  4968. * Class used to evalaute queries containing `and` and `or` operators
  4969. */
  4970. export class AndOrNotEvaluator {
  4971. /**
  4972. * Evaluate a query
  4973. * @param query defines the query to evaluate
  4974. * @param evaluateCallback defines the callback used to filter result
  4975. * @returns true if the query matches
  4976. */
  4977. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  4978. private static _HandleParenthesisContent;
  4979. private static _SimplifyNegation;
  4980. }
  4981. }
  4982. declare module "babylonjs/Misc/tags" {
  4983. /**
  4984. * Class used to store custom tags
  4985. */
  4986. export class Tags {
  4987. /**
  4988. * Adds support for tags on the given object
  4989. * @param obj defines the object to use
  4990. */
  4991. static EnableFor(obj: any): void;
  4992. /**
  4993. * Removes tags support
  4994. * @param obj defines the object to use
  4995. */
  4996. static DisableFor(obj: any): void;
  4997. /**
  4998. * Gets a boolean indicating if the given object has tags
  4999. * @param obj defines the object to use
  5000. * @returns a boolean
  5001. */
  5002. static HasTags(obj: any): boolean;
  5003. /**
  5004. * Gets the tags available on a given object
  5005. * @param obj defines the object to use
  5006. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5007. * @returns the tags
  5008. */
  5009. static GetTags(obj: any, asString?: boolean): any;
  5010. /**
  5011. * Adds tags to an object
  5012. * @param obj defines the object to use
  5013. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5014. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5015. */
  5016. static AddTagsTo(obj: any, tagsString: string): void;
  5017. /**
  5018. * @hidden
  5019. */
  5020. static _AddTagTo(obj: any, tag: string): void;
  5021. /**
  5022. * Removes specific tags from a specific object
  5023. * @param obj defines the object to use
  5024. * @param tagsString defines the tags to remove
  5025. */
  5026. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5027. /**
  5028. * @hidden
  5029. */
  5030. static _RemoveTagFrom(obj: any, tag: string): void;
  5031. /**
  5032. * Defines if tags hosted on an object match a given query
  5033. * @param obj defines the object to use
  5034. * @param tagsQuery defines the tag query
  5035. * @returns a boolean
  5036. */
  5037. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5038. }
  5039. }
  5040. declare module "babylonjs/Materials/materialDefines" {
  5041. /**
  5042. * Manages the defines for the Material
  5043. */
  5044. export class MaterialDefines {
  5045. private _keys;
  5046. private _isDirty;
  5047. /** @hidden */
  5048. _renderId: number;
  5049. /** @hidden */
  5050. _areLightsDirty: boolean;
  5051. /** @hidden */
  5052. _areAttributesDirty: boolean;
  5053. /** @hidden */
  5054. _areTexturesDirty: boolean;
  5055. /** @hidden */
  5056. _areFresnelDirty: boolean;
  5057. /** @hidden */
  5058. _areMiscDirty: boolean;
  5059. /** @hidden */
  5060. _areImageProcessingDirty: boolean;
  5061. /** @hidden */
  5062. _normals: boolean;
  5063. /** @hidden */
  5064. _uvs: boolean;
  5065. /** @hidden */
  5066. _needNormals: boolean;
  5067. /** @hidden */
  5068. _needUVs: boolean;
  5069. /**
  5070. * Specifies if the material needs to be re-calculated
  5071. */
  5072. readonly isDirty: boolean;
  5073. /**
  5074. * Marks the material to indicate that it has been re-calculated
  5075. */
  5076. markAsProcessed(): void;
  5077. /**
  5078. * Marks the material to indicate that it needs to be re-calculated
  5079. */
  5080. markAsUnprocessed(): void;
  5081. /**
  5082. * Marks the material to indicate all of its defines need to be re-calculated
  5083. */
  5084. markAllAsDirty(): void;
  5085. /**
  5086. * Marks the material to indicate that image processing needs to be re-calculated
  5087. */
  5088. markAsImageProcessingDirty(): void;
  5089. /**
  5090. * Marks the material to indicate the lights need to be re-calculated
  5091. */
  5092. markAsLightDirty(): void;
  5093. /**
  5094. * Marks the attribute state as changed
  5095. */
  5096. markAsAttributesDirty(): void;
  5097. /**
  5098. * Marks the texture state as changed
  5099. */
  5100. markAsTexturesDirty(): void;
  5101. /**
  5102. * Marks the fresnel state as changed
  5103. */
  5104. markAsFresnelDirty(): void;
  5105. /**
  5106. * Marks the misc state as changed
  5107. */
  5108. markAsMiscDirty(): void;
  5109. /**
  5110. * Rebuilds the material defines
  5111. */
  5112. rebuild(): void;
  5113. /**
  5114. * Specifies if two material defines are equal
  5115. * @param other - A material define instance to compare to
  5116. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5117. */
  5118. isEqual(other: MaterialDefines): boolean;
  5119. /**
  5120. * Clones this instance's defines to another instance
  5121. * @param other - material defines to clone values to
  5122. */
  5123. cloneTo(other: MaterialDefines): void;
  5124. /**
  5125. * Resets the material define values
  5126. */
  5127. reset(): void;
  5128. /**
  5129. * Converts the material define values to a string
  5130. * @returns - String of material define information
  5131. */
  5132. toString(): string;
  5133. }
  5134. }
  5135. declare module "babylonjs/Misc/performanceMonitor" {
  5136. /**
  5137. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5138. */
  5139. export class PerformanceMonitor {
  5140. private _enabled;
  5141. private _rollingFrameTime;
  5142. private _lastFrameTimeMs;
  5143. /**
  5144. * constructor
  5145. * @param frameSampleSize The number of samples required to saturate the sliding window
  5146. */
  5147. constructor(frameSampleSize?: number);
  5148. /**
  5149. * Samples current frame
  5150. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5151. */
  5152. sampleFrame(timeMs?: number): void;
  5153. /**
  5154. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5155. */
  5156. readonly averageFrameTime: number;
  5157. /**
  5158. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5159. */
  5160. readonly averageFrameTimeVariance: number;
  5161. /**
  5162. * Returns the frame time of the most recent frame
  5163. */
  5164. readonly instantaneousFrameTime: number;
  5165. /**
  5166. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5167. */
  5168. readonly averageFPS: number;
  5169. /**
  5170. * Returns the average framerate in frames per second using the most recent frame time
  5171. */
  5172. readonly instantaneousFPS: number;
  5173. /**
  5174. * Returns true if enough samples have been taken to completely fill the sliding window
  5175. */
  5176. readonly isSaturated: boolean;
  5177. /**
  5178. * Enables contributions to the sliding window sample set
  5179. */
  5180. enable(): void;
  5181. /**
  5182. * Disables contributions to the sliding window sample set
  5183. * Samples will not be interpolated over the disabled period
  5184. */
  5185. disable(): void;
  5186. /**
  5187. * Returns true if sampling is enabled
  5188. */
  5189. readonly isEnabled: boolean;
  5190. /**
  5191. * Resets performance monitor
  5192. */
  5193. reset(): void;
  5194. }
  5195. /**
  5196. * RollingAverage
  5197. *
  5198. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5199. */
  5200. export class RollingAverage {
  5201. /**
  5202. * Current average
  5203. */
  5204. average: number;
  5205. /**
  5206. * Current variance
  5207. */
  5208. variance: number;
  5209. protected _samples: Array<number>;
  5210. protected _sampleCount: number;
  5211. protected _pos: number;
  5212. protected _m2: number;
  5213. /**
  5214. * constructor
  5215. * @param length The number of samples required to saturate the sliding window
  5216. */
  5217. constructor(length: number);
  5218. /**
  5219. * Adds a sample to the sample set
  5220. * @param v The sample value
  5221. */
  5222. add(v: number): void;
  5223. /**
  5224. * Returns previously added values or null if outside of history or outside the sliding window domain
  5225. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5226. * @return Value previously recorded with add() or null if outside of range
  5227. */
  5228. history(i: number): number;
  5229. /**
  5230. * Returns true if enough samples have been taken to completely fill the sliding window
  5231. * @return true if sample-set saturated
  5232. */
  5233. isSaturated(): boolean;
  5234. /**
  5235. * Resets the rolling average (equivalent to 0 samples taken so far)
  5236. */
  5237. reset(): void;
  5238. /**
  5239. * Wraps a value around the sample range boundaries
  5240. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5241. * @return Wrapped position in sample range
  5242. */
  5243. protected _wrapPosition(i: number): number;
  5244. }
  5245. }
  5246. declare module "babylonjs/Misc/stringDictionary" {
  5247. import { Nullable } from "babylonjs/types";
  5248. /**
  5249. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5250. * The underlying implementation relies on an associative array to ensure the best performances.
  5251. * The value can be anything including 'null' but except 'undefined'
  5252. */
  5253. export class StringDictionary<T> {
  5254. /**
  5255. * This will clear this dictionary and copy the content from the 'source' one.
  5256. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5257. * @param source the dictionary to take the content from and copy to this dictionary
  5258. */
  5259. copyFrom(source: StringDictionary<T>): void;
  5260. /**
  5261. * Get a value based from its key
  5262. * @param key the given key to get the matching value from
  5263. * @return the value if found, otherwise undefined is returned
  5264. */
  5265. get(key: string): T | undefined;
  5266. /**
  5267. * Get a value from its key or add it if it doesn't exist.
  5268. * This method will ensure you that a given key/data will be present in the dictionary.
  5269. * @param key the given key to get the matching value from
  5270. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5271. * The factory will only be invoked if there's no data for the given key.
  5272. * @return the value corresponding to the key.
  5273. */
  5274. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5275. /**
  5276. * Get a value from its key if present in the dictionary otherwise add it
  5277. * @param key the key to get the value from
  5278. * @param val if there's no such key/value pair in the dictionary add it with this value
  5279. * @return the value corresponding to the key
  5280. */
  5281. getOrAdd(key: string, val: T): T;
  5282. /**
  5283. * Check if there's a given key in the dictionary
  5284. * @param key the key to check for
  5285. * @return true if the key is present, false otherwise
  5286. */
  5287. contains(key: string): boolean;
  5288. /**
  5289. * Add a new key and its corresponding value
  5290. * @param key the key to add
  5291. * @param value the value corresponding to the key
  5292. * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary
  5293. */
  5294. add(key: string, value: T): boolean;
  5295. /**
  5296. * Update a specific value associated to a key
  5297. * @param key defines the key to use
  5298. * @param value defines the value to store
  5299. * @returns true if the value was updated (or false if the key was not found)
  5300. */
  5301. set(key: string, value: T): boolean;
  5302. /**
  5303. * Get the element of the given key and remove it from the dictionary
  5304. * @param key defines the key to search
  5305. * @returns the value associated with the key or null if not found
  5306. */
  5307. getAndRemove(key: string): Nullable<T>;
  5308. /**
  5309. * Remove a key/value from the dictionary.
  5310. * @param key the key to remove
  5311. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5312. */
  5313. remove(key: string): boolean;
  5314. /**
  5315. * Clear the whole content of the dictionary
  5316. */
  5317. clear(): void;
  5318. /**
  5319. * Gets the current count
  5320. */
  5321. readonly count: number;
  5322. /**
  5323. * Execute a callback on each key/val of the dictionary.
  5324. * Note that you can remove any element in this dictionary in the callback implementation
  5325. * @param callback the callback to execute on a given key/value pair
  5326. */
  5327. forEach(callback: (key: string, val: T) => void): void;
  5328. /**
  5329. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5330. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5331. * Note that you can remove any element in this dictionary in the callback implementation
  5332. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5333. * @returns the first item
  5334. */
  5335. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5336. private _count;
  5337. private _data;
  5338. }
  5339. }
  5340. declare module "babylonjs/Misc/promise" {
  5341. /**
  5342. * Helper class that provides a small promise polyfill
  5343. */
  5344. export class PromisePolyfill {
  5345. /**
  5346. * Static function used to check if the polyfill is required
  5347. * If this is the case then the function will inject the polyfill to window.Promise
  5348. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5349. */
  5350. static Apply(force?: boolean): void;
  5351. }
  5352. }
  5353. declare module "babylonjs/Meshes/buffer" {
  5354. import { Nullable, DataArray } from "babylonjs/types";
  5355. /**
  5356. * Class used to store data that will be store in GPU memory
  5357. */
  5358. export class Buffer {
  5359. private _engine;
  5360. private _buffer;
  5361. /** @hidden */
  5362. _data: Nullable<DataArray>;
  5363. private _updatable;
  5364. private _instanced;
  5365. /**
  5366. * Gets the byte stride.
  5367. */
  5368. readonly byteStride: number;
  5369. /**
  5370. * Constructor
  5371. * @param engine the engine
  5372. * @param data the data to use for this buffer
  5373. * @param updatable whether the data is updatable
  5374. * @param stride the stride (optional)
  5375. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5376. * @param instanced whether the buffer is instanced (optional)
  5377. * @param useBytes set to true if the stride in in bytes (optional)
  5378. */
  5379. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5380. /**
  5381. * Create a new VertexBuffer based on the current buffer
  5382. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5383. * @param offset defines offset in the buffer (0 by default)
  5384. * @param size defines the size in floats of attributes (position is 3 for instance)
  5385. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5386. * @param instanced defines if the vertex buffer contains indexed data
  5387. * @param useBytes defines if the offset and stride are in bytes
  5388. * @returns the new vertex buffer
  5389. */
  5390. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5391. /**
  5392. * Gets a boolean indicating if the Buffer is updatable?
  5393. * @returns true if the buffer is updatable
  5394. */
  5395. isUpdatable(): boolean;
  5396. /**
  5397. * Gets current buffer's data
  5398. * @returns a DataArray or null
  5399. */
  5400. getData(): Nullable<DataArray>;
  5401. /**
  5402. * Gets underlying native buffer
  5403. * @returns underlying native buffer
  5404. */
  5405. getBuffer(): Nullable<WebGLBuffer>;
  5406. /**
  5407. * Gets the stride in float32 units (i.e. byte stride / 4).
  5408. * May not be an integer if the byte stride is not divisible by 4.
  5409. * DEPRECATED. Use byteStride instead.
  5410. * @returns the stride in float32 units
  5411. */
  5412. getStrideSize(): number;
  5413. /**
  5414. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5415. * @param data defines the data to store
  5416. */
  5417. create(data?: Nullable<DataArray>): void;
  5418. /** @hidden */
  5419. _rebuild(): void;
  5420. /**
  5421. * Update current buffer data
  5422. * @param data defines the data to store
  5423. */
  5424. update(data: DataArray): void;
  5425. /**
  5426. * Updates the data directly.
  5427. * @param data the new data
  5428. * @param offset the new offset
  5429. * @param vertexCount the vertex count (optional)
  5430. * @param useBytes set to true if the offset is in bytes
  5431. */
  5432. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5433. /**
  5434. * Release all resources
  5435. */
  5436. dispose(): void;
  5437. }
  5438. /**
  5439. * Specialized buffer used to store vertex data
  5440. */
  5441. export class VertexBuffer {
  5442. /** @hidden */
  5443. _buffer: Buffer;
  5444. private _kind;
  5445. private _size;
  5446. private _ownsBuffer;
  5447. private _instanced;
  5448. private _instanceDivisor;
  5449. /**
  5450. * The byte type.
  5451. */
  5452. static readonly BYTE: number;
  5453. /**
  5454. * The unsigned byte type.
  5455. */
  5456. static readonly UNSIGNED_BYTE: number;
  5457. /**
  5458. * The short type.
  5459. */
  5460. static readonly SHORT: number;
  5461. /**
  5462. * The unsigned short type.
  5463. */
  5464. static readonly UNSIGNED_SHORT: number;
  5465. /**
  5466. * The integer type.
  5467. */
  5468. static readonly INT: number;
  5469. /**
  5470. * The unsigned integer type.
  5471. */
  5472. static readonly UNSIGNED_INT: number;
  5473. /**
  5474. * The float type.
  5475. */
  5476. static readonly FLOAT: number;
  5477. /**
  5478. * Gets or sets the instance divisor when in instanced mode
  5479. */
  5480. instanceDivisor: number;
  5481. /**
  5482. * Gets the byte stride.
  5483. */
  5484. readonly byteStride: number;
  5485. /**
  5486. * Gets the byte offset.
  5487. */
  5488. readonly byteOffset: number;
  5489. /**
  5490. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5491. */
  5492. readonly normalized: boolean;
  5493. /**
  5494. * Gets the data type of each component in the array.
  5495. */
  5496. readonly type: number;
  5497. /**
  5498. * Constructor
  5499. * @param engine the engine
  5500. * @param data the data to use for this vertex buffer
  5501. * @param kind the vertex buffer kind
  5502. * @param updatable whether the data is updatable
  5503. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5504. * @param stride the stride (optional)
  5505. * @param instanced whether the buffer is instanced (optional)
  5506. * @param offset the offset of the data (optional)
  5507. * @param size the number of components (optional)
  5508. * @param type the type of the component (optional)
  5509. * @param normalized whether the data contains normalized data (optional)
  5510. * @param useBytes set to true if stride and offset are in bytes (optional)
  5511. */
  5512. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean);
  5513. /** @hidden */
  5514. _rebuild(): void;
  5515. /**
  5516. * Returns the kind of the VertexBuffer (string)
  5517. * @returns a string
  5518. */
  5519. getKind(): string;
  5520. /**
  5521. * Gets a boolean indicating if the VertexBuffer is updatable?
  5522. * @returns true if the buffer is updatable
  5523. */
  5524. isUpdatable(): boolean;
  5525. /**
  5526. * Gets current buffer's data
  5527. * @returns a DataArray or null
  5528. */
  5529. getData(): Nullable<DataArray>;
  5530. /**
  5531. * Gets underlying native buffer
  5532. * @returns underlying native buffer
  5533. */
  5534. getBuffer(): Nullable<WebGLBuffer>;
  5535. /**
  5536. * Gets the stride in float32 units (i.e. byte stride / 4).
  5537. * May not be an integer if the byte stride is not divisible by 4.
  5538. * DEPRECATED. Use byteStride instead.
  5539. * @returns the stride in float32 units
  5540. */
  5541. getStrideSize(): number;
  5542. /**
  5543. * Returns the offset as a multiple of the type byte length.
  5544. * DEPRECATED. Use byteOffset instead.
  5545. * @returns the offset in bytes
  5546. */
  5547. getOffset(): number;
  5548. /**
  5549. * Returns the number of components per vertex attribute (integer)
  5550. * @returns the size in float
  5551. */
  5552. getSize(): number;
  5553. /**
  5554. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5555. * @returns true if this buffer is instanced
  5556. */
  5557. getIsInstanced(): boolean;
  5558. /**
  5559. * Returns the instancing divisor, zero for non-instanced (integer).
  5560. * @returns a number
  5561. */
  5562. getInstanceDivisor(): number;
  5563. /**
  5564. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5565. * @param data defines the data to store
  5566. */
  5567. create(data?: DataArray): void;
  5568. /**
  5569. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5570. * This function will create a new buffer if the current one is not updatable
  5571. * @param data defines the data to store
  5572. */
  5573. update(data: DataArray): void;
  5574. /**
  5575. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5576. * Returns the directly updated WebGLBuffer.
  5577. * @param data the new data
  5578. * @param offset the new offset
  5579. * @param useBytes set to true if the offset is in bytes
  5580. */
  5581. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5582. /**
  5583. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5584. */
  5585. dispose(): void;
  5586. /**
  5587. * Enumerates each value of this vertex buffer as numbers.
  5588. * @param count the number of values to enumerate
  5589. * @param callback the callback function called for each value
  5590. */
  5591. forEach(count: number, callback: (value: number, index: number) => void): void;
  5592. /**
  5593. * Positions
  5594. */
  5595. static readonly PositionKind: string;
  5596. /**
  5597. * Normals
  5598. */
  5599. static readonly NormalKind: string;
  5600. /**
  5601. * Tangents
  5602. */
  5603. static readonly TangentKind: string;
  5604. /**
  5605. * Texture coordinates
  5606. */
  5607. static readonly UVKind: string;
  5608. /**
  5609. * Texture coordinates 2
  5610. */
  5611. static readonly UV2Kind: string;
  5612. /**
  5613. * Texture coordinates 3
  5614. */
  5615. static readonly UV3Kind: string;
  5616. /**
  5617. * Texture coordinates 4
  5618. */
  5619. static readonly UV4Kind: string;
  5620. /**
  5621. * Texture coordinates 5
  5622. */
  5623. static readonly UV5Kind: string;
  5624. /**
  5625. * Texture coordinates 6
  5626. */
  5627. static readonly UV6Kind: string;
  5628. /**
  5629. * Colors
  5630. */
  5631. static readonly ColorKind: string;
  5632. /**
  5633. * Matrix indices (for bones)
  5634. */
  5635. static readonly MatricesIndicesKind: string;
  5636. /**
  5637. * Matrix weights (for bones)
  5638. */
  5639. static readonly MatricesWeightsKind: string;
  5640. /**
  5641. * Additional matrix indices (for bones)
  5642. */
  5643. static readonly MatricesIndicesExtraKind: string;
  5644. /**
  5645. * Additional matrix weights (for bones)
  5646. */
  5647. static readonly MatricesWeightsExtraKind: string;
  5648. /**
  5649. * Deduces the stride given a kind.
  5650. * @param kind The kind string to deduce
  5651. * @returns The deduced stride
  5652. */
  5653. static DeduceStride(kind: string): number;
  5654. /**
  5655. * Gets the byte length of the given type.
  5656. * @param type the type
  5657. * @returns the number of bytes
  5658. */
  5659. static GetTypeByteLength(type: number): number;
  5660. /**
  5661. * Enumerates each value of the given parameters as numbers.
  5662. * @param data the data to enumerate
  5663. * @param byteOffset the byte offset of the data
  5664. * @param byteStride the byte stride of the data
  5665. * @param componentCount the number of components per element
  5666. * @param componentType the type of the component
  5667. * @param count the total number of components
  5668. * @param normalized whether the data is normalized
  5669. * @param callback the callback function called for each value
  5670. */
  5671. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5672. private static _GetFloatValue;
  5673. }
  5674. }
  5675. declare module "babylonjs/Maths/sphericalPolynomial" {
  5676. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5677. /**
  5678. * Class representing spherical polynomial coefficients to the 3rd degree
  5679. */
  5680. export class SphericalPolynomial {
  5681. /**
  5682. * The x coefficients of the spherical polynomial
  5683. */
  5684. x: Vector3;
  5685. /**
  5686. * The y coefficients of the spherical polynomial
  5687. */
  5688. y: Vector3;
  5689. /**
  5690. * The z coefficients of the spherical polynomial
  5691. */
  5692. z: Vector3;
  5693. /**
  5694. * The xx coefficients of the spherical polynomial
  5695. */
  5696. xx: Vector3;
  5697. /**
  5698. * The yy coefficients of the spherical polynomial
  5699. */
  5700. yy: Vector3;
  5701. /**
  5702. * The zz coefficients of the spherical polynomial
  5703. */
  5704. zz: Vector3;
  5705. /**
  5706. * The xy coefficients of the spherical polynomial
  5707. */
  5708. xy: Vector3;
  5709. /**
  5710. * The yz coefficients of the spherical polynomial
  5711. */
  5712. yz: Vector3;
  5713. /**
  5714. * The zx coefficients of the spherical polynomial
  5715. */
  5716. zx: Vector3;
  5717. /**
  5718. * Adds an ambient color to the spherical polynomial
  5719. * @param color the color to add
  5720. */
  5721. addAmbient(color: Color3): void;
  5722. /**
  5723. * Scales the spherical polynomial by the given amount
  5724. * @param scale the amount to scale
  5725. */
  5726. scale(scale: number): void;
  5727. /**
  5728. * Gets the spherical polynomial from harmonics
  5729. * @param harmonics the spherical harmonics
  5730. * @returns the spherical polynomial
  5731. */
  5732. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5733. /**
  5734. * Constructs a spherical polynomial from an array.
  5735. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5736. * @returns the spherical polynomial
  5737. */
  5738. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5739. }
  5740. /**
  5741. * Class representing spherical harmonics coefficients to the 3rd degree
  5742. */
  5743. export class SphericalHarmonics {
  5744. /**
  5745. * The l0,0 coefficients of the spherical harmonics
  5746. */
  5747. l00: Vector3;
  5748. /**
  5749. * The l1,-1 coefficients of the spherical harmonics
  5750. */
  5751. l1_1: Vector3;
  5752. /**
  5753. * The l1,0 coefficients of the spherical harmonics
  5754. */
  5755. l10: Vector3;
  5756. /**
  5757. * The l1,1 coefficients of the spherical harmonics
  5758. */
  5759. l11: Vector3;
  5760. /**
  5761. * The l2,-2 coefficients of the spherical harmonics
  5762. */
  5763. l2_2: Vector3;
  5764. /**
  5765. * The l2,-1 coefficients of the spherical harmonics
  5766. */
  5767. l2_1: Vector3;
  5768. /**
  5769. * The l2,0 coefficients of the spherical harmonics
  5770. */
  5771. l20: Vector3;
  5772. /**
  5773. * The l2,1 coefficients of the spherical harmonics
  5774. */
  5775. l21: Vector3;
  5776. /**
  5777. * The l2,2 coefficients of the spherical harmonics
  5778. */
  5779. lL22: Vector3;
  5780. /**
  5781. * Adds a light to the spherical harmonics
  5782. * @param direction the direction of the light
  5783. * @param color the color of the light
  5784. * @param deltaSolidAngle the delta solid angle of the light
  5785. */
  5786. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5787. /**
  5788. * Scales the spherical harmonics by the given amount
  5789. * @param scale the amount to scale
  5790. */
  5791. scale(scale: number): void;
  5792. /**
  5793. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5794. *
  5795. * ```
  5796. * E_lm = A_l * L_lm
  5797. * ```
  5798. *
  5799. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5800. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5801. * the scaling factors are given in equation 9.
  5802. */
  5803. convertIncidentRadianceToIrradiance(): void;
  5804. /**
  5805. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5806. *
  5807. * ```
  5808. * L = (1/pi) * E * rho
  5809. * ```
  5810. *
  5811. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5812. */
  5813. convertIrradianceToLambertianRadiance(): void;
  5814. /**
  5815. * Gets the spherical harmonics from polynomial
  5816. * @param polynomial the spherical polynomial
  5817. * @returns the spherical harmonics
  5818. */
  5819. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5820. /**
  5821. * Constructs a spherical harmonics from an array.
  5822. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5823. * @returns the spherical harmonics
  5824. */
  5825. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5826. }
  5827. }
  5828. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  5829. import { Nullable } from "babylonjs/types";
  5830. /**
  5831. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5832. */
  5833. export interface CubeMapInfo {
  5834. /**
  5835. * The pixel array for the front face.
  5836. * This is stored in format, left to right, up to down format.
  5837. */
  5838. front: Nullable<ArrayBufferView>;
  5839. /**
  5840. * The pixel array for the back face.
  5841. * This is stored in format, left to right, up to down format.
  5842. */
  5843. back: Nullable<ArrayBufferView>;
  5844. /**
  5845. * The pixel array for the left face.
  5846. * This is stored in format, left to right, up to down format.
  5847. */
  5848. left: Nullable<ArrayBufferView>;
  5849. /**
  5850. * The pixel array for the right face.
  5851. * This is stored in format, left to right, up to down format.
  5852. */
  5853. right: Nullable<ArrayBufferView>;
  5854. /**
  5855. * The pixel array for the up face.
  5856. * This is stored in format, left to right, up to down format.
  5857. */
  5858. up: Nullable<ArrayBufferView>;
  5859. /**
  5860. * The pixel array for the down face.
  5861. * This is stored in format, left to right, up to down format.
  5862. */
  5863. down: Nullable<ArrayBufferView>;
  5864. /**
  5865. * The size of the cubemap stored.
  5866. *
  5867. * Each faces will be size * size pixels.
  5868. */
  5869. size: number;
  5870. /**
  5871. * The format of the texture.
  5872. *
  5873. * RGBA, RGB.
  5874. */
  5875. format: number;
  5876. /**
  5877. * The type of the texture data.
  5878. *
  5879. * UNSIGNED_INT, FLOAT.
  5880. */
  5881. type: number;
  5882. /**
  5883. * Specifies whether the texture is in gamma space.
  5884. */
  5885. gammaSpace: boolean;
  5886. }
  5887. /**
  5888. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5889. */
  5890. export class PanoramaToCubeMapTools {
  5891. private static FACE_FRONT;
  5892. private static FACE_BACK;
  5893. private static FACE_RIGHT;
  5894. private static FACE_LEFT;
  5895. private static FACE_DOWN;
  5896. private static FACE_UP;
  5897. /**
  5898. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  5899. *
  5900. * @param float32Array The source data.
  5901. * @param inputWidth The width of the input panorama.
  5902. * @param inputHeight The height of the input panorama.
  5903. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  5904. * @return The cubemap data
  5905. */
  5906. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  5907. private static CreateCubemapTexture;
  5908. private static CalcProjectionSpherical;
  5909. }
  5910. }
  5911. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  5912. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  5913. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  5914. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  5915. /**
  5916. * Helper class dealing with the extraction of spherical polynomial dataArray
  5917. * from a cube map.
  5918. */
  5919. export class CubeMapToSphericalPolynomialTools {
  5920. private static FileFaces;
  5921. /**
  5922. * Converts a texture to the according Spherical Polynomial data.
  5923. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5924. *
  5925. * @param texture The texture to extract the information from.
  5926. * @return The Spherical Polynomial data.
  5927. */
  5928. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  5929. /**
  5930. * Converts a cubemap to the according Spherical Polynomial data.
  5931. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5932. *
  5933. * @param cubeInfo The Cube map to extract the information from.
  5934. * @return The Spherical Polynomial data.
  5935. */
  5936. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  5937. }
  5938. }
  5939. declare module "babylonjs/Engines/engineStore" {
  5940. import { Nullable } from "babylonjs/types";
  5941. import { Engine } from "babylonjs/Engines/engine";
  5942. import { Scene } from "babylonjs/scene";
  5943. /**
  5944. * The engine store class is responsible to hold all the instances of Engine and Scene created
  5945. * during the life time of the application.
  5946. */
  5947. export class EngineStore {
  5948. /** Gets the list of created engines */
  5949. static Instances: import("babylonjs/Engines/engine").Engine[];
  5950. /**
  5951. * Gets the latest created engine
  5952. */
  5953. static readonly LastCreatedEngine: Nullable<Engine>;
  5954. /**
  5955. * Gets the latest created scene
  5956. */
  5957. static readonly LastCreatedScene: Nullable<Scene>;
  5958. }
  5959. }
  5960. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  5961. /**
  5962. * Define options used to create a render target texture
  5963. */
  5964. export class RenderTargetCreationOptions {
  5965. /**
  5966. * Specifies is mipmaps must be generated
  5967. */
  5968. generateMipMaps?: boolean;
  5969. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5970. generateDepthBuffer?: boolean;
  5971. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5972. generateStencilBuffer?: boolean;
  5973. /** Defines texture type (int by default) */
  5974. type?: number;
  5975. /** Defines sampling mode (trilinear by default) */
  5976. samplingMode?: number;
  5977. /** Defines format (RGBA by default) */
  5978. format?: number;
  5979. }
  5980. }
  5981. declare module "babylonjs/States/alphaCullingState" {
  5982. /**
  5983. * @hidden
  5984. **/
  5985. export class _AlphaState {
  5986. private _isAlphaBlendDirty;
  5987. private _isBlendFunctionParametersDirty;
  5988. private _isBlendEquationParametersDirty;
  5989. private _isBlendConstantsDirty;
  5990. private _alphaBlend;
  5991. private _blendFunctionParameters;
  5992. private _blendEquationParameters;
  5993. private _blendConstants;
  5994. /**
  5995. * Initializes the state.
  5996. */
  5997. constructor();
  5998. readonly isDirty: boolean;
  5999. alphaBlend: boolean;
  6000. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6001. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6002. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6003. reset(): void;
  6004. apply(gl: WebGLRenderingContext): void;
  6005. }
  6006. }
  6007. declare module "babylonjs/States/depthCullingState" {
  6008. import { Nullable } from "babylonjs/types";
  6009. /**
  6010. * @hidden
  6011. **/
  6012. export class _DepthCullingState {
  6013. private _isDepthTestDirty;
  6014. private _isDepthMaskDirty;
  6015. private _isDepthFuncDirty;
  6016. private _isCullFaceDirty;
  6017. private _isCullDirty;
  6018. private _isZOffsetDirty;
  6019. private _isFrontFaceDirty;
  6020. private _depthTest;
  6021. private _depthMask;
  6022. private _depthFunc;
  6023. private _cull;
  6024. private _cullFace;
  6025. private _zOffset;
  6026. private _frontFace;
  6027. /**
  6028. * Initializes the state.
  6029. */
  6030. constructor();
  6031. readonly isDirty: boolean;
  6032. zOffset: number;
  6033. cullFace: Nullable<number>;
  6034. cull: Nullable<boolean>;
  6035. depthFunc: Nullable<number>;
  6036. depthMask: boolean;
  6037. depthTest: boolean;
  6038. frontFace: Nullable<number>;
  6039. reset(): void;
  6040. apply(gl: WebGLRenderingContext): void;
  6041. }
  6042. }
  6043. declare module "babylonjs/States/stencilState" {
  6044. /**
  6045. * @hidden
  6046. **/
  6047. export class _StencilState {
  6048. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  6049. static readonly ALWAYS: number;
  6050. /** Passed to stencilOperation to specify that stencil value must be kept */
  6051. static readonly KEEP: number;
  6052. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6053. static readonly REPLACE: number;
  6054. private _isStencilTestDirty;
  6055. private _isStencilMaskDirty;
  6056. private _isStencilFuncDirty;
  6057. private _isStencilOpDirty;
  6058. private _stencilTest;
  6059. private _stencilMask;
  6060. private _stencilFunc;
  6061. private _stencilFuncRef;
  6062. private _stencilFuncMask;
  6063. private _stencilOpStencilFail;
  6064. private _stencilOpDepthFail;
  6065. private _stencilOpStencilDepthPass;
  6066. readonly isDirty: boolean;
  6067. stencilFunc: number;
  6068. stencilFuncRef: number;
  6069. stencilFuncMask: number;
  6070. stencilOpStencilFail: number;
  6071. stencilOpDepthFail: number;
  6072. stencilOpStencilDepthPass: number;
  6073. stencilMask: number;
  6074. stencilTest: boolean;
  6075. constructor();
  6076. reset(): void;
  6077. apply(gl: WebGLRenderingContext): void;
  6078. }
  6079. }
  6080. declare module "babylonjs/States/index" {
  6081. export * from "babylonjs/States/alphaCullingState";
  6082. export * from "babylonjs/States/depthCullingState";
  6083. export * from "babylonjs/States/stencilState";
  6084. }
  6085. declare module "babylonjs/Instrumentation/timeToken" {
  6086. import { Nullable } from "babylonjs/types";
  6087. /**
  6088. * @hidden
  6089. **/
  6090. export class _TimeToken {
  6091. _startTimeQuery: Nullable<WebGLQuery>;
  6092. _endTimeQuery: Nullable<WebGLQuery>;
  6093. _timeElapsedQuery: Nullable<WebGLQuery>;
  6094. _timeElapsedQueryEnded: boolean;
  6095. }
  6096. }
  6097. declare module "babylonjs/Materials/Textures/internalTextureTracker" {
  6098. import { Nullable } from "babylonjs/types";
  6099. /**
  6100. * Internal interface used to track InternalTexture already bound to the GL context
  6101. */
  6102. export interface IInternalTextureTracker {
  6103. /**
  6104. * Gets or set the previous tracker in the list
  6105. */
  6106. previous: Nullable<IInternalTextureTracker>;
  6107. /**
  6108. * Gets or set the next tracker in the list
  6109. */
  6110. next: Nullable<IInternalTextureTracker>;
  6111. }
  6112. /**
  6113. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  6114. */
  6115. export class DummyInternalTextureTracker {
  6116. /**
  6117. * Gets or set the previous tracker in the list
  6118. */
  6119. previous: Nullable<IInternalTextureTracker>;
  6120. /**
  6121. * Gets or set the next tracker in the list
  6122. */
  6123. next: Nullable<IInternalTextureTracker>;
  6124. }
  6125. }
  6126. declare module "babylonjs/Materials/Textures/internalTexture" {
  6127. import { Observable } from "babylonjs/Misc/observable";
  6128. import { Nullable, int } from "babylonjs/types";
  6129. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6130. import { IInternalTextureTracker } from "babylonjs/Materials/Textures/internalTextureTracker";
  6131. import { Engine } from "babylonjs/Engines/engine";
  6132. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6133. /**
  6134. * Class used to store data associated with WebGL texture data for the engine
  6135. * This class should not be used directly
  6136. */
  6137. export class InternalTexture implements IInternalTextureTracker {
  6138. /** hidden */
  6139. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6140. /**
  6141. * The source of the texture data is unknown
  6142. */
  6143. static DATASOURCE_UNKNOWN: number;
  6144. /**
  6145. * Texture data comes from an URL
  6146. */
  6147. static DATASOURCE_URL: number;
  6148. /**
  6149. * Texture data is only used for temporary storage
  6150. */
  6151. static DATASOURCE_TEMP: number;
  6152. /**
  6153. * Texture data comes from raw data (ArrayBuffer)
  6154. */
  6155. static DATASOURCE_RAW: number;
  6156. /**
  6157. * Texture content is dynamic (video or dynamic texture)
  6158. */
  6159. static DATASOURCE_DYNAMIC: number;
  6160. /**
  6161. * Texture content is generated by rendering to it
  6162. */
  6163. static DATASOURCE_RENDERTARGET: number;
  6164. /**
  6165. * Texture content is part of a multi render target process
  6166. */
  6167. static DATASOURCE_MULTIRENDERTARGET: number;
  6168. /**
  6169. * Texture data comes from a cube data file
  6170. */
  6171. static DATASOURCE_CUBE: number;
  6172. /**
  6173. * Texture data comes from a raw cube data
  6174. */
  6175. static DATASOURCE_CUBERAW: number;
  6176. /**
  6177. * Texture data come from a prefiltered cube data file
  6178. */
  6179. static DATASOURCE_CUBEPREFILTERED: number;
  6180. /**
  6181. * Texture content is raw 3D data
  6182. */
  6183. static DATASOURCE_RAW3D: number;
  6184. /**
  6185. * Texture content is a depth texture
  6186. */
  6187. static DATASOURCE_DEPTHTEXTURE: number;
  6188. /**
  6189. * Texture data comes from a raw cube data encoded with RGBD
  6190. */
  6191. static DATASOURCE_CUBERAW_RGBD: number;
  6192. /**
  6193. * Defines if the texture is ready
  6194. */
  6195. isReady: boolean;
  6196. /**
  6197. * Defines if the texture is a cube texture
  6198. */
  6199. isCube: boolean;
  6200. /**
  6201. * Defines if the texture contains 3D data
  6202. */
  6203. is3D: boolean;
  6204. /**
  6205. * Gets the URL used to load this texture
  6206. */
  6207. url: string;
  6208. /**
  6209. * Gets the sampling mode of the texture
  6210. */
  6211. samplingMode: number;
  6212. /**
  6213. * Gets a boolean indicating if the texture needs mipmaps generation
  6214. */
  6215. generateMipMaps: boolean;
  6216. /**
  6217. * Gets the number of samples used by the texture (WebGL2+ only)
  6218. */
  6219. samples: number;
  6220. /**
  6221. * Gets the type of the texture (int, float...)
  6222. */
  6223. type: number;
  6224. /**
  6225. * Gets the format of the texture (RGB, RGBA...)
  6226. */
  6227. format: number;
  6228. /**
  6229. * Observable called when the texture is loaded
  6230. */
  6231. onLoadedObservable: Observable<InternalTexture>;
  6232. /**
  6233. * Gets the width of the texture
  6234. */
  6235. width: number;
  6236. /**
  6237. * Gets the height of the texture
  6238. */
  6239. height: number;
  6240. /**
  6241. * Gets the depth of the texture
  6242. */
  6243. depth: number;
  6244. /**
  6245. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6246. */
  6247. baseWidth: number;
  6248. /**
  6249. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6250. */
  6251. baseHeight: number;
  6252. /**
  6253. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6254. */
  6255. baseDepth: number;
  6256. /**
  6257. * Gets a boolean indicating if the texture is inverted on Y axis
  6258. */
  6259. invertY: boolean;
  6260. /**
  6261. * Gets or set the previous tracker in the list
  6262. */
  6263. previous: Nullable<IInternalTextureTracker>;
  6264. /**
  6265. * Gets or set the next tracker in the list
  6266. */
  6267. next: Nullable<IInternalTextureTracker>;
  6268. /** @hidden */
  6269. _invertVScale: boolean;
  6270. /** @hidden */
  6271. _initialSlot: number;
  6272. /** @hidden */
  6273. _designatedSlot: number;
  6274. /** @hidden */
  6275. _dataSource: number;
  6276. /** @hidden */
  6277. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6278. /** @hidden */
  6279. _bufferView: Nullable<ArrayBufferView>;
  6280. /** @hidden */
  6281. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6282. /** @hidden */
  6283. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6284. /** @hidden */
  6285. _size: number;
  6286. /** @hidden */
  6287. _extension: string;
  6288. /** @hidden */
  6289. _files: Nullable<string[]>;
  6290. /** @hidden */
  6291. _workingCanvas: HTMLCanvasElement;
  6292. /** @hidden */
  6293. _workingContext: CanvasRenderingContext2D;
  6294. /** @hidden */
  6295. _framebuffer: Nullable<WebGLFramebuffer>;
  6296. /** @hidden */
  6297. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6298. /** @hidden */
  6299. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6300. /** @hidden */
  6301. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6302. /** @hidden */
  6303. _attachments: Nullable<number[]>;
  6304. /** @hidden */
  6305. _cachedCoordinatesMode: Nullable<number>;
  6306. /** @hidden */
  6307. _cachedWrapU: Nullable<number>;
  6308. /** @hidden */
  6309. _cachedWrapV: Nullable<number>;
  6310. /** @hidden */
  6311. _cachedWrapR: Nullable<number>;
  6312. /** @hidden */
  6313. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6314. /** @hidden */
  6315. _isDisabled: boolean;
  6316. /** @hidden */
  6317. _compression: Nullable<string>;
  6318. /** @hidden */
  6319. _generateStencilBuffer: boolean;
  6320. /** @hidden */
  6321. _generateDepthBuffer: boolean;
  6322. /** @hidden */
  6323. _comparisonFunction: number;
  6324. /** @hidden */
  6325. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6326. /** @hidden */
  6327. _lodGenerationScale: number;
  6328. /** @hidden */
  6329. _lodGenerationOffset: number;
  6330. /** @hidden */
  6331. _lodTextureHigh: BaseTexture;
  6332. /** @hidden */
  6333. _lodTextureMid: BaseTexture;
  6334. /** @hidden */
  6335. _lodTextureLow: BaseTexture;
  6336. /** @hidden */
  6337. _isRGBD: boolean;
  6338. /** @hidden */
  6339. _webGLTexture: Nullable<WebGLTexture>;
  6340. /** @hidden */
  6341. _references: number;
  6342. private _engine;
  6343. /**
  6344. * Gets the Engine the texture belongs to.
  6345. * @returns The babylon engine
  6346. */
  6347. getEngine(): Engine;
  6348. /**
  6349. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6350. */
  6351. readonly dataSource: number;
  6352. /**
  6353. * Creates a new InternalTexture
  6354. * @param engine defines the engine to use
  6355. * @param dataSource defines the type of data that will be used
  6356. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6357. */
  6358. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6359. /**
  6360. * Increments the number of references (ie. the number of Texture that point to it)
  6361. */
  6362. incrementReferences(): void;
  6363. /**
  6364. * Change the size of the texture (not the size of the content)
  6365. * @param width defines the new width
  6366. * @param height defines the new height
  6367. * @param depth defines the new depth (1 by default)
  6368. */
  6369. updateSize(width: int, height: int, depth?: int): void;
  6370. /** @hidden */
  6371. _rebuild(): void;
  6372. /** @hidden */
  6373. _swapAndDie(target: InternalTexture): void;
  6374. /**
  6375. * Dispose the current allocated resources
  6376. */
  6377. dispose(): void;
  6378. }
  6379. }
  6380. declare module "babylonjs/Animations/easing" {
  6381. /**
  6382. * This represents the main contract an easing function should follow.
  6383. * Easing functions are used throughout the animation system.
  6384. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6385. */
  6386. export interface IEasingFunction {
  6387. /**
  6388. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6389. * of the easing function.
  6390. * The link below provides some of the most common examples of easing functions.
  6391. * @see https://easings.net/
  6392. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6393. * @returns the corresponding value on the curve defined by the easing function
  6394. */
  6395. ease(gradient: number): number;
  6396. }
  6397. /**
  6398. * Base class used for every default easing function.
  6399. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6400. */
  6401. export class EasingFunction implements IEasingFunction {
  6402. /**
  6403. * Interpolation follows the mathematical formula associated with the easing function.
  6404. */
  6405. static readonly EASINGMODE_EASEIN: number;
  6406. /**
  6407. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6408. */
  6409. static readonly EASINGMODE_EASEOUT: number;
  6410. /**
  6411. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6412. */
  6413. static readonly EASINGMODE_EASEINOUT: number;
  6414. private _easingMode;
  6415. /**
  6416. * Sets the easing mode of the current function.
  6417. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6418. */
  6419. setEasingMode(easingMode: number): void;
  6420. /**
  6421. * Gets the current easing mode.
  6422. * @returns the easing mode
  6423. */
  6424. getEasingMode(): number;
  6425. /**
  6426. * @hidden
  6427. */
  6428. easeInCore(gradient: number): number;
  6429. /**
  6430. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6431. * of the easing function.
  6432. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6433. * @returns the corresponding value on the curve defined by the easing function
  6434. */
  6435. ease(gradient: number): number;
  6436. }
  6437. /**
  6438. * Easing function with a circle shape (see link below).
  6439. * @see https://easings.net/#easeInCirc
  6440. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6441. */
  6442. export class CircleEase extends EasingFunction implements IEasingFunction {
  6443. /** @hidden */
  6444. easeInCore(gradient: number): number;
  6445. }
  6446. /**
  6447. * Easing function with a ease back shape (see link below).
  6448. * @see https://easings.net/#easeInBack
  6449. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6450. */
  6451. export class BackEase extends EasingFunction implements IEasingFunction {
  6452. /** Defines the amplitude of the function */
  6453. amplitude: number;
  6454. /**
  6455. * Instantiates a back ease easing
  6456. * @see https://easings.net/#easeInBack
  6457. * @param amplitude Defines the amplitude of the function
  6458. */
  6459. constructor(
  6460. /** Defines the amplitude of the function */
  6461. amplitude?: number);
  6462. /** @hidden */
  6463. easeInCore(gradient: number): number;
  6464. }
  6465. /**
  6466. * Easing function with a bouncing shape (see link below).
  6467. * @see https://easings.net/#easeInBounce
  6468. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6469. */
  6470. export class BounceEase extends EasingFunction implements IEasingFunction {
  6471. /** Defines the number of bounces */
  6472. bounces: number;
  6473. /** Defines the amplitude of the bounce */
  6474. bounciness: number;
  6475. /**
  6476. * Instantiates a bounce easing
  6477. * @see https://easings.net/#easeInBounce
  6478. * @param bounces Defines the number of bounces
  6479. * @param bounciness Defines the amplitude of the bounce
  6480. */
  6481. constructor(
  6482. /** Defines the number of bounces */
  6483. bounces?: number,
  6484. /** Defines the amplitude of the bounce */
  6485. bounciness?: number);
  6486. /** @hidden */
  6487. easeInCore(gradient: number): number;
  6488. }
  6489. /**
  6490. * Easing function with a power of 3 shape (see link below).
  6491. * @see https://easings.net/#easeInCubic
  6492. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6493. */
  6494. export class CubicEase extends EasingFunction implements IEasingFunction {
  6495. /** @hidden */
  6496. easeInCore(gradient: number): number;
  6497. }
  6498. /**
  6499. * Easing function with an elastic shape (see link below).
  6500. * @see https://easings.net/#easeInElastic
  6501. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6502. */
  6503. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6504. /** Defines the number of oscillations*/
  6505. oscillations: number;
  6506. /** Defines the amplitude of the oscillations*/
  6507. springiness: number;
  6508. /**
  6509. * Instantiates an elastic easing function
  6510. * @see https://easings.net/#easeInElastic
  6511. * @param oscillations Defines the number of oscillations
  6512. * @param springiness Defines the amplitude of the oscillations
  6513. */
  6514. constructor(
  6515. /** Defines the number of oscillations*/
  6516. oscillations?: number,
  6517. /** Defines the amplitude of the oscillations*/
  6518. springiness?: number);
  6519. /** @hidden */
  6520. easeInCore(gradient: number): number;
  6521. }
  6522. /**
  6523. * Easing function with an exponential shape (see link below).
  6524. * @see https://easings.net/#easeInExpo
  6525. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6526. */
  6527. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6528. /** Defines the exponent of the function */
  6529. exponent: number;
  6530. /**
  6531. * Instantiates an exponential easing function
  6532. * @see https://easings.net/#easeInExpo
  6533. * @param exponent Defines the exponent of the function
  6534. */
  6535. constructor(
  6536. /** Defines the exponent of the function */
  6537. exponent?: number);
  6538. /** @hidden */
  6539. easeInCore(gradient: number): number;
  6540. }
  6541. /**
  6542. * Easing function with a power shape (see link below).
  6543. * @see https://easings.net/#easeInQuad
  6544. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6545. */
  6546. export class PowerEase extends EasingFunction implements IEasingFunction {
  6547. /** Defines the power of the function */
  6548. power: number;
  6549. /**
  6550. * Instantiates an power base easing function
  6551. * @see https://easings.net/#easeInQuad
  6552. * @param power Defines the power of the function
  6553. */
  6554. constructor(
  6555. /** Defines the power of the function */
  6556. power?: number);
  6557. /** @hidden */
  6558. easeInCore(gradient: number): number;
  6559. }
  6560. /**
  6561. * Easing function with a power of 2 shape (see link below).
  6562. * @see https://easings.net/#easeInQuad
  6563. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6564. */
  6565. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6566. /** @hidden */
  6567. easeInCore(gradient: number): number;
  6568. }
  6569. /**
  6570. * Easing function with a power of 4 shape (see link below).
  6571. * @see https://easings.net/#easeInQuart
  6572. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6573. */
  6574. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6575. /** @hidden */
  6576. easeInCore(gradient: number): number;
  6577. }
  6578. /**
  6579. * Easing function with a power of 5 shape (see link below).
  6580. * @see https://easings.net/#easeInQuint
  6581. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6582. */
  6583. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6584. /** @hidden */
  6585. easeInCore(gradient: number): number;
  6586. }
  6587. /**
  6588. * Easing function with a sin shape (see link below).
  6589. * @see https://easings.net/#easeInSine
  6590. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6591. */
  6592. export class SineEase extends EasingFunction implements IEasingFunction {
  6593. /** @hidden */
  6594. easeInCore(gradient: number): number;
  6595. }
  6596. /**
  6597. * Easing function with a bezier shape (see link below).
  6598. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6599. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6600. */
  6601. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6602. /** Defines the x component of the start tangent in the bezier curve */
  6603. x1: number;
  6604. /** Defines the y component of the start tangent in the bezier curve */
  6605. y1: number;
  6606. /** Defines the x component of the end tangent in the bezier curve */
  6607. x2: number;
  6608. /** Defines the y component of the end tangent in the bezier curve */
  6609. y2: number;
  6610. /**
  6611. * Instantiates a bezier function
  6612. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6613. * @param x1 Defines the x component of the start tangent in the bezier curve
  6614. * @param y1 Defines the y component of the start tangent in the bezier curve
  6615. * @param x2 Defines the x component of the end tangent in the bezier curve
  6616. * @param y2 Defines the y component of the end tangent in the bezier curve
  6617. */
  6618. constructor(
  6619. /** Defines the x component of the start tangent in the bezier curve */
  6620. x1?: number,
  6621. /** Defines the y component of the start tangent in the bezier curve */
  6622. y1?: number,
  6623. /** Defines the x component of the end tangent in the bezier curve */
  6624. x2?: number,
  6625. /** Defines the y component of the end tangent in the bezier curve */
  6626. y2?: number);
  6627. /** @hidden */
  6628. easeInCore(gradient: number): number;
  6629. }
  6630. }
  6631. declare module "babylonjs/Animations/animationKey" {
  6632. /**
  6633. * Defines an interface which represents an animation key frame
  6634. */
  6635. export interface IAnimationKey {
  6636. /**
  6637. * Frame of the key frame
  6638. */
  6639. frame: number;
  6640. /**
  6641. * Value at the specifies key frame
  6642. */
  6643. value: any;
  6644. /**
  6645. * The input tangent for the cubic hermite spline
  6646. */
  6647. inTangent?: any;
  6648. /**
  6649. * The output tangent for the cubic hermite spline
  6650. */
  6651. outTangent?: any;
  6652. /**
  6653. * The animation interpolation type
  6654. */
  6655. interpolation?: AnimationKeyInterpolation;
  6656. }
  6657. /**
  6658. * Enum for the animation key frame interpolation type
  6659. */
  6660. export enum AnimationKeyInterpolation {
  6661. /**
  6662. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6663. */
  6664. STEP = 1
  6665. }
  6666. }
  6667. declare module "babylonjs/Animations/animationRange" {
  6668. /**
  6669. * Represents the range of an animation
  6670. */
  6671. export class AnimationRange {
  6672. /**The name of the animation range**/
  6673. name: string;
  6674. /**The starting frame of the animation */
  6675. from: number;
  6676. /**The ending frame of the animation*/
  6677. to: number;
  6678. /**
  6679. * Initializes the range of an animation
  6680. * @param name The name of the animation range
  6681. * @param from The starting frame of the animation
  6682. * @param to The ending frame of the animation
  6683. */
  6684. constructor(
  6685. /**The name of the animation range**/
  6686. name: string,
  6687. /**The starting frame of the animation */
  6688. from: number,
  6689. /**The ending frame of the animation*/
  6690. to: number);
  6691. /**
  6692. * Makes a copy of the animation range
  6693. * @returns A copy of the animation range
  6694. */
  6695. clone(): AnimationRange;
  6696. }
  6697. }
  6698. declare module "babylonjs/Animations/animationEvent" {
  6699. /**
  6700. * Composed of a frame, and an action function
  6701. */
  6702. export class AnimationEvent {
  6703. /** The frame for which the event is triggered **/
  6704. frame: number;
  6705. /** The event to perform when triggered **/
  6706. action: (currentFrame: number) => void;
  6707. /** Specifies if the event should be triggered only once**/
  6708. onlyOnce?: boolean | undefined;
  6709. /**
  6710. * Specifies if the animation event is done
  6711. */
  6712. isDone: boolean;
  6713. /**
  6714. * Initializes the animation event
  6715. * @param frame The frame for which the event is triggered
  6716. * @param action The event to perform when triggered
  6717. * @param onlyOnce Specifies if the event should be triggered only once
  6718. */
  6719. constructor(
  6720. /** The frame for which the event is triggered **/
  6721. frame: number,
  6722. /** The event to perform when triggered **/
  6723. action: (currentFrame: number) => void,
  6724. /** Specifies if the event should be triggered only once**/
  6725. onlyOnce?: boolean | undefined);
  6726. /** @hidden */
  6727. _clone(): AnimationEvent;
  6728. }
  6729. }
  6730. declare module "babylonjs/Behaviors/behavior" {
  6731. import { Nullable } from "babylonjs/types";
  6732. /**
  6733. * Interface used to define a behavior
  6734. */
  6735. export interface Behavior<T> {
  6736. /** gets or sets behavior's name */
  6737. name: string;
  6738. /**
  6739. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6740. */
  6741. init(): void;
  6742. /**
  6743. * Called when the behavior is attached to a target
  6744. * @param target defines the target where the behavior is attached to
  6745. */
  6746. attach(target: T): void;
  6747. /**
  6748. * Called when the behavior is detached from its target
  6749. */
  6750. detach(): void;
  6751. }
  6752. /**
  6753. * Interface implemented by classes supporting behaviors
  6754. */
  6755. export interface IBehaviorAware<T> {
  6756. /**
  6757. * Attach a behavior
  6758. * @param behavior defines the behavior to attach
  6759. * @returns the current host
  6760. */
  6761. addBehavior(behavior: Behavior<T>): T;
  6762. /**
  6763. * Remove a behavior from the current object
  6764. * @param behavior defines the behavior to detach
  6765. * @returns the current host
  6766. */
  6767. removeBehavior(behavior: Behavior<T>): T;
  6768. /**
  6769. * Gets a behavior using its name to search
  6770. * @param name defines the name to search
  6771. * @returns the behavior or null if not found
  6772. */
  6773. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6774. }
  6775. }
  6776. declare module "babylonjs/Collisions/intersectionInfo" {
  6777. import { Nullable } from "babylonjs/types";
  6778. /**
  6779. * @hidden
  6780. */
  6781. export class IntersectionInfo {
  6782. bu: Nullable<number>;
  6783. bv: Nullable<number>;
  6784. distance: number;
  6785. faceId: number;
  6786. subMeshId: number;
  6787. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6788. }
  6789. }
  6790. declare module "babylonjs/Culling/boundingSphere" {
  6791. import { DeepImmutable } from "babylonjs/types";
  6792. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6793. /**
  6794. * Class used to store bounding sphere information
  6795. */
  6796. export class BoundingSphere {
  6797. /**
  6798. * Gets the center of the bounding sphere in local space
  6799. */
  6800. readonly center: Vector3;
  6801. /**
  6802. * Radius of the bounding sphere in local space
  6803. */
  6804. radius: number;
  6805. /**
  6806. * Gets the center of the bounding sphere in world space
  6807. */
  6808. readonly centerWorld: Vector3;
  6809. /**
  6810. * Radius of the bounding sphere in world space
  6811. */
  6812. radiusWorld: number;
  6813. /**
  6814. * Gets the minimum vector in local space
  6815. */
  6816. readonly minimum: Vector3;
  6817. /**
  6818. * Gets the maximum vector in local space
  6819. */
  6820. readonly maximum: Vector3;
  6821. private _worldMatrix;
  6822. private static readonly TmpVector3;
  6823. /**
  6824. * Creates a new bounding sphere
  6825. * @param min defines the minimum vector (in local space)
  6826. * @param max defines the maximum vector (in local space)
  6827. * @param worldMatrix defines the new world matrix
  6828. */
  6829. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6830. /**
  6831. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6832. * @param min defines the new minimum vector (in local space)
  6833. * @param max defines the new maximum vector (in local space)
  6834. * @param worldMatrix defines the new world matrix
  6835. */
  6836. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6837. /**
  6838. * Scale the current bounding sphere by applying a scale factor
  6839. * @param factor defines the scale factor to apply
  6840. * @returns the current bounding box
  6841. */
  6842. scale(factor: number): BoundingSphere;
  6843. /**
  6844. * Gets the world matrix of the bounding box
  6845. * @returns a matrix
  6846. */
  6847. getWorldMatrix(): DeepImmutable<Matrix>;
  6848. /** @hidden */
  6849. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6850. /**
  6851. * Tests if the bounding sphere is intersecting the frustum planes
  6852. * @param frustumPlanes defines the frustum planes to test
  6853. * @returns true if there is an intersection
  6854. */
  6855. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6856. /**
  6857. * Tests if the bounding sphere center is in between the frustum planes.
  6858. * Used for optimistic fast inclusion.
  6859. * @param frustumPlanes defines the frustum planes to test
  6860. * @returns true if the sphere center is in between the frustum planes
  6861. */
  6862. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6863. /**
  6864. * Tests if a point is inside the bounding sphere
  6865. * @param point defines the point to test
  6866. * @returns true if the point is inside the bounding sphere
  6867. */
  6868. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6869. /**
  6870. * Checks if two sphere intersct
  6871. * @param sphere0 sphere 0
  6872. * @param sphere1 sphere 1
  6873. * @returns true if the speres intersect
  6874. */
  6875. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6876. }
  6877. }
  6878. declare module "babylonjs/Culling/boundingBox" {
  6879. import { DeepImmutable } from "babylonjs/types";
  6880. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6881. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6882. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6883. /**
  6884. * Class used to store bounding box information
  6885. */
  6886. export class BoundingBox implements ICullable {
  6887. /**
  6888. * Gets the 8 vectors representing the bounding box in local space
  6889. */
  6890. readonly vectors: Vector3[];
  6891. /**
  6892. * Gets the center of the bounding box in local space
  6893. */
  6894. readonly center: Vector3;
  6895. /**
  6896. * Gets the center of the bounding box in world space
  6897. */
  6898. readonly centerWorld: Vector3;
  6899. /**
  6900. * Gets the extend size in local space
  6901. */
  6902. readonly extendSize: Vector3;
  6903. /**
  6904. * Gets the extend size in world space
  6905. */
  6906. readonly extendSizeWorld: Vector3;
  6907. /**
  6908. * Gets the OBB (object bounding box) directions
  6909. */
  6910. readonly directions: Vector3[];
  6911. /**
  6912. * Gets the 8 vectors representing the bounding box in world space
  6913. */
  6914. readonly vectorsWorld: Vector3[];
  6915. /**
  6916. * Gets the minimum vector in world space
  6917. */
  6918. readonly minimumWorld: Vector3;
  6919. /**
  6920. * Gets the maximum vector in world space
  6921. */
  6922. readonly maximumWorld: Vector3;
  6923. /**
  6924. * Gets the minimum vector in local space
  6925. */
  6926. readonly minimum: Vector3;
  6927. /**
  6928. * Gets the maximum vector in local space
  6929. */
  6930. readonly maximum: Vector3;
  6931. private _worldMatrix;
  6932. private static readonly TmpVector3;
  6933. /**
  6934. * @hidden
  6935. */
  6936. _tag: number;
  6937. /**
  6938. * Creates a new bounding box
  6939. * @param min defines the minimum vector (in local space)
  6940. * @param max defines the maximum vector (in local space)
  6941. * @param worldMatrix defines the new world matrix
  6942. */
  6943. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6944. /**
  6945. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6946. * @param min defines the new minimum vector (in local space)
  6947. * @param max defines the new maximum vector (in local space)
  6948. * @param worldMatrix defines the new world matrix
  6949. */
  6950. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6951. /**
  6952. * Scale the current bounding box by applying a scale factor
  6953. * @param factor defines the scale factor to apply
  6954. * @returns the current bounding box
  6955. */
  6956. scale(factor: number): BoundingBox;
  6957. /**
  6958. * Gets the world matrix of the bounding box
  6959. * @returns a matrix
  6960. */
  6961. getWorldMatrix(): DeepImmutable<Matrix>;
  6962. /** @hidden */
  6963. _update(world: DeepImmutable<Matrix>): void;
  6964. /**
  6965. * Tests if the bounding box is intersecting the frustum planes
  6966. * @param frustumPlanes defines the frustum planes to test
  6967. * @returns true if there is an intersection
  6968. */
  6969. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6970. /**
  6971. * Tests if the bounding box is entirely inside the frustum planes
  6972. * @param frustumPlanes defines the frustum planes to test
  6973. * @returns true if there is an inclusion
  6974. */
  6975. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6976. /**
  6977. * Tests if a point is inside the bounding box
  6978. * @param point defines the point to test
  6979. * @returns true if the point is inside the bounding box
  6980. */
  6981. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6982. /**
  6983. * Tests if the bounding box intersects with a bounding sphere
  6984. * @param sphere defines the sphere to test
  6985. * @returns true if there is an intersection
  6986. */
  6987. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6988. /**
  6989. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6990. * @param min defines the min vector to use
  6991. * @param max defines the max vector to use
  6992. * @returns true if there is an intersection
  6993. */
  6994. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6995. /**
  6996. * Tests if two bounding boxes are intersections
  6997. * @param box0 defines the first box to test
  6998. * @param box1 defines the second box to test
  6999. * @returns true if there is an intersection
  7000. */
  7001. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7002. /**
  7003. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7004. * @param minPoint defines the minimum vector of the bounding box
  7005. * @param maxPoint defines the maximum vector of the bounding box
  7006. * @param sphereCenter defines the sphere center
  7007. * @param sphereRadius defines the sphere radius
  7008. * @returns true if there is an intersection
  7009. */
  7010. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7011. /**
  7012. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7013. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7014. * @param frustumPlanes defines the frustum planes to test
  7015. * @return true if there is an inclusion
  7016. */
  7017. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7018. /**
  7019. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7020. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7021. * @param frustumPlanes defines the frustum planes to test
  7022. * @return true if there is an intersection
  7023. */
  7024. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7025. }
  7026. }
  7027. declare module "babylonjs/Collisions/collider" {
  7028. import { Nullable, IndicesArray } from "babylonjs/types";
  7029. import { Vector3, Plane } from "babylonjs/Maths/math";
  7030. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7031. /** @hidden */
  7032. export class Collider {
  7033. /** Define if a collision was found */
  7034. collisionFound: boolean;
  7035. /**
  7036. * Define last intersection point in local space
  7037. */
  7038. intersectionPoint: Vector3;
  7039. /**
  7040. * Define last collided mesh
  7041. */
  7042. collidedMesh: Nullable<AbstractMesh>;
  7043. private _collisionPoint;
  7044. private _planeIntersectionPoint;
  7045. private _tempVector;
  7046. private _tempVector2;
  7047. private _tempVector3;
  7048. private _tempVector4;
  7049. private _edge;
  7050. private _baseToVertex;
  7051. private _destinationPoint;
  7052. private _slidePlaneNormal;
  7053. private _displacementVector;
  7054. /** @hidden */
  7055. _radius: Vector3;
  7056. /** @hidden */
  7057. _retry: number;
  7058. private _velocity;
  7059. private _basePoint;
  7060. private _epsilon;
  7061. /** @hidden */
  7062. _velocityWorldLength: number;
  7063. /** @hidden */
  7064. _basePointWorld: Vector3;
  7065. private _velocityWorld;
  7066. private _normalizedVelocity;
  7067. /** @hidden */
  7068. _initialVelocity: Vector3;
  7069. /** @hidden */
  7070. _initialPosition: Vector3;
  7071. private _nearestDistance;
  7072. private _collisionMask;
  7073. collisionMask: number;
  7074. /**
  7075. * Gets the plane normal used to compute the sliding response (in local space)
  7076. */
  7077. readonly slidePlaneNormal: Vector3;
  7078. /** @hidden */
  7079. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7080. /** @hidden */
  7081. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7082. /** @hidden */
  7083. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7084. /** @hidden */
  7085. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7086. /** @hidden */
  7087. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7088. /** @hidden */
  7089. _getResponse(pos: Vector3, vel: Vector3): void;
  7090. }
  7091. }
  7092. declare module "babylonjs/Culling/boundingInfo" {
  7093. import { DeepImmutable } from "babylonjs/types";
  7094. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7095. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7096. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7097. import { Collider } from "babylonjs/Collisions/collider";
  7098. /**
  7099. * Interface for cullable objects
  7100. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7101. */
  7102. export interface ICullable {
  7103. /**
  7104. * Checks if the object or part of the object is in the frustum
  7105. * @param frustumPlanes Camera near/planes
  7106. * @returns true if the object is in frustum otherwise false
  7107. */
  7108. isInFrustum(frustumPlanes: Plane[]): boolean;
  7109. /**
  7110. * Checks if a cullable object (mesh...) is in the camera frustum
  7111. * Unlike isInFrustum this cheks the full bounding box
  7112. * @param frustumPlanes Camera near/planes
  7113. * @returns true if the object is in frustum otherwise false
  7114. */
  7115. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7116. }
  7117. /**
  7118. * Info for a bounding data of a mesh
  7119. */
  7120. export class BoundingInfo implements ICullable {
  7121. /**
  7122. * Bounding box for the mesh
  7123. */
  7124. readonly boundingBox: BoundingBox;
  7125. /**
  7126. * Bounding sphere for the mesh
  7127. */
  7128. readonly boundingSphere: BoundingSphere;
  7129. private _isLocked;
  7130. private static readonly TmpVector3;
  7131. /**
  7132. * Constructs bounding info
  7133. * @param minimum min vector of the bounding box/sphere
  7134. * @param maximum max vector of the bounding box/sphere
  7135. * @param worldMatrix defines the new world matrix
  7136. */
  7137. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7138. /**
  7139. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7140. * @param min defines the new minimum vector (in local space)
  7141. * @param max defines the new maximum vector (in local space)
  7142. * @param worldMatrix defines the new world matrix
  7143. */
  7144. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7145. /**
  7146. * min vector of the bounding box/sphere
  7147. */
  7148. readonly minimum: Vector3;
  7149. /**
  7150. * max vector of the bounding box/sphere
  7151. */
  7152. readonly maximum: Vector3;
  7153. /**
  7154. * If the info is locked and won't be updated to avoid perf overhead
  7155. */
  7156. isLocked: boolean;
  7157. /**
  7158. * Updates the bounding sphere and box
  7159. * @param world world matrix to be used to update
  7160. */
  7161. update(world: DeepImmutable<Matrix>): void;
  7162. /**
  7163. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7164. * @param center New center of the bounding info
  7165. * @param extend New extend of the bounding info
  7166. * @returns the current bounding info
  7167. */
  7168. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7169. /**
  7170. * Scale the current bounding info by applying a scale factor
  7171. * @param factor defines the scale factor to apply
  7172. * @returns the current bounding info
  7173. */
  7174. scale(factor: number): BoundingInfo;
  7175. /**
  7176. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7177. * @param frustumPlanes defines the frustum to test
  7178. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7179. * @returns true if the bounding info is in the frustum planes
  7180. */
  7181. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7182. /**
  7183. * Gets the world distance between the min and max points of the bounding box
  7184. */
  7185. readonly diagonalLength: number;
  7186. /**
  7187. * Checks if a cullable object (mesh...) is in the camera frustum
  7188. * Unlike isInFrustum this cheks the full bounding box
  7189. * @param frustumPlanes Camera near/planes
  7190. * @returns true if the object is in frustum otherwise false
  7191. */
  7192. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7193. /** @hidden */
  7194. _checkCollision(collider: Collider): boolean;
  7195. /**
  7196. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7197. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7198. * @param point the point to check intersection with
  7199. * @returns if the point intersects
  7200. */
  7201. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7202. /**
  7203. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7204. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7205. * @param boundingInfo the bounding info to check intersection with
  7206. * @param precise if the intersection should be done using OBB
  7207. * @returns if the bounding info intersects
  7208. */
  7209. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7210. }
  7211. }
  7212. declare module "babylonjs/Misc/smartArray" {
  7213. /**
  7214. * Defines an array and its length.
  7215. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7216. */
  7217. export interface ISmartArrayLike<T> {
  7218. /**
  7219. * The data of the array.
  7220. */
  7221. data: Array<T>;
  7222. /**
  7223. * The active length of the array.
  7224. */
  7225. length: number;
  7226. }
  7227. /**
  7228. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7229. */
  7230. export class SmartArray<T> implements ISmartArrayLike<T> {
  7231. /**
  7232. * The full set of data from the array.
  7233. */
  7234. data: Array<T>;
  7235. /**
  7236. * The active length of the array.
  7237. */
  7238. length: number;
  7239. protected _id: number;
  7240. /**
  7241. * Instantiates a Smart Array.
  7242. * @param capacity defines the default capacity of the array.
  7243. */
  7244. constructor(capacity: number);
  7245. /**
  7246. * Pushes a value at the end of the active data.
  7247. * @param value defines the object to push in the array.
  7248. */
  7249. push(value: T): void;
  7250. /**
  7251. * Iterates over the active data and apply the lambda to them.
  7252. * @param func defines the action to apply on each value.
  7253. */
  7254. forEach(func: (content: T) => void): void;
  7255. /**
  7256. * Sorts the full sets of data.
  7257. * @param compareFn defines the comparison function to apply.
  7258. */
  7259. sort(compareFn: (a: T, b: T) => number): void;
  7260. /**
  7261. * Resets the active data to an empty array.
  7262. */
  7263. reset(): void;
  7264. /**
  7265. * Releases all the data from the array as well as the array.
  7266. */
  7267. dispose(): void;
  7268. /**
  7269. * Concats the active data with a given array.
  7270. * @param array defines the data to concatenate with.
  7271. */
  7272. concat(array: any): void;
  7273. /**
  7274. * Returns the position of a value in the active data.
  7275. * @param value defines the value to find the index for
  7276. * @returns the index if found in the active data otherwise -1
  7277. */
  7278. indexOf(value: T): number;
  7279. /**
  7280. * Returns whether an element is part of the active data.
  7281. * @param value defines the value to look for
  7282. * @returns true if found in the active data otherwise false
  7283. */
  7284. contains(value: T): boolean;
  7285. private static _GlobalId;
  7286. }
  7287. /**
  7288. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7289. * The data in this array can only be present once
  7290. */
  7291. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7292. private _duplicateId;
  7293. /**
  7294. * Pushes a value at the end of the active data.
  7295. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7296. * @param value defines the object to push in the array.
  7297. */
  7298. push(value: T): void;
  7299. /**
  7300. * Pushes a value at the end of the active data.
  7301. * If the data is already present, it won t be added again
  7302. * @param value defines the object to push in the array.
  7303. * @returns true if added false if it was already present
  7304. */
  7305. pushNoDuplicate(value: T): boolean;
  7306. /**
  7307. * Resets the active data to an empty array.
  7308. */
  7309. reset(): void;
  7310. /**
  7311. * Concats the active data with a given array.
  7312. * This ensures no dupplicate will be present in the result.
  7313. * @param array defines the data to concatenate with.
  7314. */
  7315. concatWithNoDuplicate(array: any): void;
  7316. }
  7317. }
  7318. declare module "babylonjs/Materials/multiMaterial" {
  7319. import { Nullable } from "babylonjs/types";
  7320. import { Scene } from "babylonjs/scene";
  7321. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7322. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  7323. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7324. import { Material } from "babylonjs/Materials/material";
  7325. /**
  7326. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7327. * separate meshes. This can be use to improve performances.
  7328. * @see http://doc.babylonjs.com/how_to/multi_materials
  7329. */
  7330. export class MultiMaterial extends Material {
  7331. private _subMaterials;
  7332. /**
  7333. * Gets or Sets the list of Materials used within the multi material.
  7334. * They need to be ordered according to the submeshes order in the associated mesh
  7335. */
  7336. subMaterials: Nullable<Material>[];
  7337. /**
  7338. * Function used to align with Node.getChildren()
  7339. * @returns the list of Materials used within the multi material
  7340. */
  7341. getChildren(): Nullable<Material>[];
  7342. /**
  7343. * Instantiates a new Multi Material
  7344. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7345. * separate meshes. This can be use to improve performances.
  7346. * @see http://doc.babylonjs.com/how_to/multi_materials
  7347. * @param name Define the name in the scene
  7348. * @param scene Define the scene the material belongs to
  7349. */
  7350. constructor(name: string, scene: Scene);
  7351. private _hookArray;
  7352. /**
  7353. * Get one of the submaterial by its index in the submaterials array
  7354. * @param index The index to look the sub material at
  7355. * @returns The Material if the index has been defined
  7356. */
  7357. getSubMaterial(index: number): Nullable<Material>;
  7358. /**
  7359. * Get the list of active textures for the whole sub materials list.
  7360. * @returns All the textures that will be used during the rendering
  7361. */
  7362. getActiveTextures(): BaseTexture[];
  7363. /**
  7364. * Gets the current class name of the material e.g. "MultiMaterial"
  7365. * Mainly use in serialization.
  7366. * @returns the class name
  7367. */
  7368. getClassName(): string;
  7369. /**
  7370. * Checks if the material is ready to render the requested sub mesh
  7371. * @param mesh Define the mesh the submesh belongs to
  7372. * @param subMesh Define the sub mesh to look readyness for
  7373. * @param useInstances Define whether or not the material is used with instances
  7374. * @returns true if ready, otherwise false
  7375. */
  7376. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7377. /**
  7378. * Clones the current material and its related sub materials
  7379. * @param name Define the name of the newly cloned material
  7380. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7381. * @returns the cloned material
  7382. */
  7383. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7384. /**
  7385. * Serializes the materials into a JSON representation.
  7386. * @returns the JSON representation
  7387. */
  7388. serialize(): any;
  7389. /**
  7390. * Dispose the material and release its associated resources
  7391. * @param forceDisposeEffect Define if we want to force disposing the associated effect (if false the shader is not released and could be reuse later on)
  7392. * @param forceDisposeTextures Define if we want to force disposing the associated textures (if false, they will not be disposed and can still be use elsewhere in the app)
  7393. * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
  7394. */
  7395. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7396. /**
  7397. * Creates a MultiMaterial from parsed MultiMaterial data.
  7398. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7399. * @param scene defines the hosting scene
  7400. * @returns a new MultiMaterial
  7401. */
  7402. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7403. }
  7404. }
  7405. declare module "babylonjs/Loading/sceneLoaderFlags" {
  7406. /**
  7407. * Class used to represent data loading progression
  7408. */
  7409. export class SceneLoaderFlags {
  7410. private static _ForceFullSceneLoadingForIncremental;
  7411. private static _ShowLoadingScreen;
  7412. private static _CleanBoneMatrixWeights;
  7413. private static _loggingLevel;
  7414. /**
  7415. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7416. */
  7417. static ForceFullSceneLoadingForIncremental: boolean;
  7418. /**
  7419. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7420. */
  7421. static ShowLoadingScreen: boolean;
  7422. /**
  7423. * Defines the current logging level (while loading the scene)
  7424. * @ignorenaming
  7425. */
  7426. static loggingLevel: number;
  7427. /**
  7428. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7429. */
  7430. static CleanBoneMatrixWeights: boolean;
  7431. }
  7432. }
  7433. declare module "babylonjs/Meshes/transformNode" {
  7434. import { DeepImmutable } from "babylonjs/types";
  7435. import { Observable } from "babylonjs/Misc/observable";
  7436. import { Nullable } from "babylonjs/types";
  7437. import { Camera } from "babylonjs/Cameras/camera";
  7438. import { Scene } from "babylonjs/scene";
  7439. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  7440. import { Node } from "babylonjs/node";
  7441. import { Bone } from "babylonjs/Bones/bone";
  7442. /**
  7443. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  7444. * @see https://doc.babylonjs.com/how_to/transformnode
  7445. */
  7446. export class TransformNode extends Node {
  7447. /**
  7448. * Object will not rotate to face the camera
  7449. */
  7450. static BILLBOARDMODE_NONE: number;
  7451. /**
  7452. * Object will rotate to face the camera but only on the x axis
  7453. */
  7454. static BILLBOARDMODE_X: number;
  7455. /**
  7456. * Object will rotate to face the camera but only on the y axis
  7457. */
  7458. static BILLBOARDMODE_Y: number;
  7459. /**
  7460. * Object will rotate to face the camera but only on the z axis
  7461. */
  7462. static BILLBOARDMODE_Z: number;
  7463. /**
  7464. * Object will rotate to face the camera
  7465. */
  7466. static BILLBOARDMODE_ALL: number;
  7467. private _forward;
  7468. private _forwardInverted;
  7469. private _up;
  7470. private _right;
  7471. private _rightInverted;
  7472. private _position;
  7473. private _rotation;
  7474. private _rotationQuaternion;
  7475. protected _scaling: Vector3;
  7476. protected _isDirty: boolean;
  7477. private _transformToBoneReferal;
  7478. /**
  7479. * Set the billboard mode. Default is 0.
  7480. *
  7481. * | Value | Type | Description |
  7482. * | --- | --- | --- |
  7483. * | 0 | BILLBOARDMODE_NONE | |
  7484. * | 1 | BILLBOARDMODE_X | |
  7485. * | 2 | BILLBOARDMODE_Y | |
  7486. * | 4 | BILLBOARDMODE_Z | |
  7487. * | 7 | BILLBOARDMODE_ALL | |
  7488. *
  7489. */
  7490. billboardMode: number;
  7491. /**
  7492. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  7493. */
  7494. scalingDeterminant: number;
  7495. /**
  7496. * Sets the distance of the object to max, often used by skybox
  7497. */
  7498. infiniteDistance: boolean;
  7499. /**
  7500. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7501. * By default the system will update normals to compensate
  7502. */
  7503. ignoreNonUniformScaling: boolean;
  7504. /** @hidden */
  7505. _poseMatrix: Matrix;
  7506. /** @hidden */
  7507. _localMatrix: Matrix;
  7508. private _absolutePosition;
  7509. private _pivotMatrix;
  7510. private _pivotMatrixInverse;
  7511. protected _postMultiplyPivotMatrix: boolean;
  7512. protected _isWorldMatrixFrozen: boolean;
  7513. /** @hidden */
  7514. _indexInSceneTransformNodesArray: number;
  7515. /**
  7516. * An event triggered after the world matrix is updated
  7517. */
  7518. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7519. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7520. /**
  7521. * Gets a string identifying the name of the class
  7522. * @returns "TransformNode" string
  7523. */
  7524. getClassName(): string;
  7525. /**
  7526. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7527. */
  7528. position: Vector3;
  7529. /**
  7530. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  7531. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7532. */
  7533. rotation: Vector3;
  7534. /**
  7535. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  7536. */
  7537. scaling: Vector3;
  7538. /**
  7539. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  7540. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7541. */
  7542. rotationQuaternion: Nullable<Quaternion>;
  7543. /**
  7544. * The forward direction of that transform in world space.
  7545. */
  7546. readonly forward: Vector3;
  7547. /**
  7548. * The up direction of that transform in world space.
  7549. */
  7550. readonly up: Vector3;
  7551. /**
  7552. * The right direction of that transform in world space.
  7553. */
  7554. readonly right: Vector3;
  7555. /**
  7556. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7557. * @param matrix the matrix to copy the pose from
  7558. * @returns this TransformNode.
  7559. */
  7560. updatePoseMatrix(matrix: Matrix): TransformNode;
  7561. /**
  7562. * Returns the mesh Pose matrix.
  7563. * @returns the pose matrix
  7564. */
  7565. getPoseMatrix(): Matrix;
  7566. /** @hidden */
  7567. _isSynchronized(): boolean;
  7568. /** @hidden */
  7569. _initCache(): void;
  7570. /**
  7571. * Flag the transform node as dirty (Forcing it to update everything)
  7572. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7573. * @returns this transform node
  7574. */
  7575. markAsDirty(property: string): TransformNode;
  7576. /**
  7577. * Returns the current mesh absolute position.
  7578. * Returns a Vector3.
  7579. */
  7580. readonly absolutePosition: Vector3;
  7581. /**
  7582. * Sets a new matrix to apply before all other transformation
  7583. * @param matrix defines the transform matrix
  7584. * @returns the current TransformNode
  7585. */
  7586. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7587. /**
  7588. * Sets a new pivot matrix to the current node
  7589. * @param matrix defines the new pivot matrix to use
  7590. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  7591. * @returns the current TransformNode
  7592. */
  7593. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7594. /**
  7595. * Returns the mesh pivot matrix.
  7596. * Default : Identity.
  7597. * @returns the matrix
  7598. */
  7599. getPivotMatrix(): Matrix;
  7600. /**
  7601. * Prevents the World matrix to be computed any longer.
  7602. * @returns the TransformNode.
  7603. */
  7604. freezeWorldMatrix(): TransformNode;
  7605. /**
  7606. * Allows back the World matrix computation.
  7607. * @returns the TransformNode.
  7608. */
  7609. unfreezeWorldMatrix(): this;
  7610. /**
  7611. * True if the World matrix has been frozen.
  7612. */
  7613. readonly isWorldMatrixFrozen: boolean;
  7614. /**
  7615. * Retuns the mesh absolute position in the World.
  7616. * @returns a Vector3.
  7617. */
  7618. getAbsolutePosition(): Vector3;
  7619. /**
  7620. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7621. * @param absolutePosition the absolute position to set
  7622. * @returns the TransformNode.
  7623. */
  7624. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7625. /**
  7626. * Sets the mesh position in its local space.
  7627. * @param vector3 the position to set in localspace
  7628. * @returns the TransformNode.
  7629. */
  7630. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7631. /**
  7632. * Returns the mesh position in the local space from the current World matrix values.
  7633. * @returns a new Vector3.
  7634. */
  7635. getPositionExpressedInLocalSpace(): Vector3;
  7636. /**
  7637. * Translates the mesh along the passed Vector3 in its local space.
  7638. * @param vector3 the distance to translate in localspace
  7639. * @returns the TransformNode.
  7640. */
  7641. locallyTranslate(vector3: Vector3): TransformNode;
  7642. private static _lookAtVectorCache;
  7643. /**
  7644. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7645. * @param targetPoint the position (must be in same space as current mesh) to look at
  7646. * @param yawCor optional yaw (y-axis) correction in radians
  7647. * @param pitchCor optional pitch (x-axis) correction in radians
  7648. * @param rollCor optional roll (z-axis) correction in radians
  7649. * @param space the choosen space of the target
  7650. * @returns the TransformNode.
  7651. */
  7652. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7653. /**
  7654. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7655. * This Vector3 is expressed in the World space.
  7656. * @param localAxis axis to rotate
  7657. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7658. */
  7659. getDirection(localAxis: Vector3): Vector3;
  7660. /**
  7661. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7662. * localAxis is expressed in the mesh local space.
  7663. * result is computed in the Wordl space from the mesh World matrix.
  7664. * @param localAxis axis to rotate
  7665. * @param result the resulting transformnode
  7666. * @returns this TransformNode.
  7667. */
  7668. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7669. /**
  7670. * Sets this transform node rotation to the given local axis.
  7671. * @param localAxis the axis in local space
  7672. * @param yawCor optional yaw (y-axis) correction in radians
  7673. * @param pitchCor optional pitch (x-axis) correction in radians
  7674. * @param rollCor optional roll (z-axis) correction in radians
  7675. * @returns this TransformNode
  7676. */
  7677. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7678. /**
  7679. * Sets a new pivot point to the current node
  7680. * @param point defines the new pivot point to use
  7681. * @param space defines if the point is in world or local space (local by default)
  7682. * @returns the current TransformNode
  7683. */
  7684. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7685. /**
  7686. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7687. * @returns the pivot point
  7688. */
  7689. getPivotPoint(): Vector3;
  7690. /**
  7691. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7692. * @param result the vector3 to store the result
  7693. * @returns this TransformNode.
  7694. */
  7695. getPivotPointToRef(result: Vector3): TransformNode;
  7696. /**
  7697. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7698. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7699. */
  7700. getAbsolutePivotPoint(): Vector3;
  7701. /**
  7702. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7703. * @param result vector3 to store the result
  7704. * @returns this TransformNode.
  7705. */
  7706. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7707. /**
  7708. * Defines the passed node as the parent of the current node.
  7709. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7710. * @param node the node ot set as the parent
  7711. * @returns this TransformNode.
  7712. */
  7713. setParent(node: Nullable<Node>): TransformNode;
  7714. private _nonUniformScaling;
  7715. /**
  7716. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7717. */
  7718. readonly nonUniformScaling: boolean;
  7719. /** @hidden */
  7720. _updateNonUniformScalingState(value: boolean): boolean;
  7721. /**
  7722. * Attach the current TransformNode to another TransformNode associated with a bone
  7723. * @param bone Bone affecting the TransformNode
  7724. * @param affectedTransformNode TransformNode associated with the bone
  7725. * @returns this object
  7726. */
  7727. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7728. /**
  7729. * Detach the transform node if its associated with a bone
  7730. * @returns this object
  7731. */
  7732. detachFromBone(): TransformNode;
  7733. private static _rotationAxisCache;
  7734. /**
  7735. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7736. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7737. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7738. * The passed axis is also normalized.
  7739. * @param axis the axis to rotate around
  7740. * @param amount the amount to rotate in radians
  7741. * @param space Space to rotate in (Default: local)
  7742. * @returns the TransformNode.
  7743. */
  7744. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7745. /**
  7746. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7747. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7748. * The passed axis is also normalized. .
  7749. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7750. * @param point the point to rotate around
  7751. * @param axis the axis to rotate around
  7752. * @param amount the amount to rotate in radians
  7753. * @returns the TransformNode
  7754. */
  7755. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7756. /**
  7757. * Translates the mesh along the axis vector for the passed distance in the given space.
  7758. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7759. * @param axis the axis to translate in
  7760. * @param distance the distance to translate
  7761. * @param space Space to rotate in (Default: local)
  7762. * @returns the TransformNode.
  7763. */
  7764. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7765. /**
  7766. * Adds a rotation step to the mesh current rotation.
  7767. * x, y, z are Euler angles expressed in radians.
  7768. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7769. * This means this rotation is made in the mesh local space only.
  7770. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7771. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7772. * ```javascript
  7773. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7774. * ```
  7775. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7776. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  7777. * @param x Rotation to add
  7778. * @param y Rotation to add
  7779. * @param z Rotation to add
  7780. * @returns the TransformNode.
  7781. */
  7782. addRotation(x: number, y: number, z: number): TransformNode;
  7783. /**
  7784. * Computes the world matrix of the node
  7785. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7786. * @returns the world matrix
  7787. */
  7788. computeWorldMatrix(force?: boolean): Matrix;
  7789. protected _afterComputeWorldMatrix(): void;
  7790. /**
  7791. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7792. * @param func callback function to add
  7793. *
  7794. * @returns the TransformNode.
  7795. */
  7796. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7797. /**
  7798. * Removes a registered callback function.
  7799. * @param func callback function to remove
  7800. * @returns the TransformNode.
  7801. */
  7802. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7803. /**
  7804. * Gets the position of the current mesh in camera space
  7805. * @param camera defines the camera to use
  7806. * @returns a position
  7807. */
  7808. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7809. /**
  7810. * Returns the distance from the mesh to the active camera
  7811. * @param camera defines the camera to use
  7812. * @returns the distance
  7813. */
  7814. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7815. /**
  7816. * Clone the current transform node
  7817. * @param name Name of the new clone
  7818. * @param newParent New parent for the clone
  7819. * @param doNotCloneChildren Do not clone children hierarchy
  7820. * @returns the new transform node
  7821. */
  7822. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7823. /**
  7824. * Serializes the objects information.
  7825. * @param currentSerializationObject defines the object to serialize in
  7826. * @returns the serialized object
  7827. */
  7828. serialize(currentSerializationObject?: any): any;
  7829. /**
  7830. * Returns a new TransformNode object parsed from the source provided.
  7831. * @param parsedTransformNode is the source.
  7832. * @param scene the scne the object belongs to
  7833. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7834. * @returns a new TransformNode object parsed from the source provided.
  7835. */
  7836. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7837. /**
  7838. * Get all child-transformNodes of this node
  7839. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  7840. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  7841. * @returns an array of TransformNode
  7842. */
  7843. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7844. /**
  7845. * Releases resources associated with this transform node.
  7846. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7847. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7848. */
  7849. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7850. }
  7851. }
  7852. declare module "babylonjs/Animations/animationPropertiesOverride" {
  7853. /**
  7854. * Class used to override all child animations of a given target
  7855. */
  7856. export class AnimationPropertiesOverride {
  7857. /**
  7858. * Gets or sets a value indicating if animation blending must be used
  7859. */
  7860. enableBlending: boolean;
  7861. /**
  7862. * Gets or sets the blending speed to use when enableBlending is true
  7863. */
  7864. blendingSpeed: number;
  7865. /**
  7866. * Gets or sets the default loop mode to use
  7867. */
  7868. loopMode: number;
  7869. }
  7870. }
  7871. declare module "babylonjs/Bones/bone" {
  7872. import { Skeleton } from "babylonjs/Bones/skeleton";
  7873. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  7874. import { Nullable } from "babylonjs/types";
  7875. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7876. import { TransformNode } from "babylonjs/Meshes/transformNode";
  7877. import { Node } from "babylonjs/node";
  7878. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  7879. /**
  7880. * Class used to store bone information
  7881. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7882. */
  7883. export class Bone extends Node {
  7884. /**
  7885. * defines the bone name
  7886. */
  7887. name: string;
  7888. private static _tmpVecs;
  7889. private static _tmpQuat;
  7890. private static _tmpMats;
  7891. /**
  7892. * Gets the list of child bones
  7893. */
  7894. children: Bone[];
  7895. /** Gets the animations associated with this bone */
  7896. animations: import("babylonjs/Animations/animation").Animation[];
  7897. /**
  7898. * Gets or sets bone length
  7899. */
  7900. length: number;
  7901. /**
  7902. * @hidden Internal only
  7903. * Set this value to map this bone to a different index in the transform matrices
  7904. * Set this value to -1 to exclude the bone from the transform matrices
  7905. */
  7906. _index: Nullable<number>;
  7907. private _skeleton;
  7908. private _localMatrix;
  7909. private _restPose;
  7910. private _baseMatrix;
  7911. private _absoluteTransform;
  7912. private _invertedAbsoluteTransform;
  7913. private _parent;
  7914. private _scalingDeterminant;
  7915. private _worldTransform;
  7916. private _localScaling;
  7917. private _localRotation;
  7918. private _localPosition;
  7919. private _needToDecompose;
  7920. private _needToCompose;
  7921. /** @hidden */
  7922. _linkedTransformNode: Nullable<TransformNode>;
  7923. /** @hidden */
  7924. /** @hidden */
  7925. _matrix: Matrix;
  7926. /**
  7927. * Create a new bone
  7928. * @param name defines the bone name
  7929. * @param skeleton defines the parent skeleton
  7930. * @param parentBone defines the parent (can be null if the bone is the root)
  7931. * @param localMatrix defines the local matrix
  7932. * @param restPose defines the rest pose matrix
  7933. * @param baseMatrix defines the base matrix
  7934. * @param index defines index of the bone in the hiearchy
  7935. */
  7936. constructor(
  7937. /**
  7938. * defines the bone name
  7939. */
  7940. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  7941. /**
  7942. * Gets the parent skeleton
  7943. * @returns a skeleton
  7944. */
  7945. getSkeleton(): Skeleton;
  7946. /**
  7947. * Gets parent bone
  7948. * @returns a bone or null if the bone is the root of the bone hierarchy
  7949. */
  7950. getParent(): Nullable<Bone>;
  7951. /**
  7952. * Sets the parent bone
  7953. * @param parent defines the parent (can be null if the bone is the root)
  7954. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  7955. */
  7956. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  7957. /**
  7958. * Gets the local matrix
  7959. * @returns a matrix
  7960. */
  7961. getLocalMatrix(): Matrix;
  7962. /**
  7963. * Gets the base matrix (initial matrix which remains unchanged)
  7964. * @returns a matrix
  7965. */
  7966. getBaseMatrix(): Matrix;
  7967. /**
  7968. * Gets the rest pose matrix
  7969. * @returns a matrix
  7970. */
  7971. getRestPose(): Matrix;
  7972. /**
  7973. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  7974. */
  7975. getWorldMatrix(): Matrix;
  7976. /**
  7977. * Sets the local matrix to rest pose matrix
  7978. */
  7979. returnToRest(): void;
  7980. /**
  7981. * Gets the inverse of the absolute transform matrix.
  7982. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  7983. * @returns a matrix
  7984. */
  7985. getInvertedAbsoluteTransform(): Matrix;
  7986. /**
  7987. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  7988. * @returns a matrix
  7989. */
  7990. getAbsoluteTransform(): Matrix;
  7991. /**
  7992. * Links with the given transform node.
  7993. * The local matrix of this bone is copied from the transform node every frame.
  7994. * @param transformNode defines the transform node to link to
  7995. */
  7996. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  7997. /** Gets or sets current position (in local space) */
  7998. position: Vector3;
  7999. /** Gets or sets current rotation (in local space) */
  8000. rotation: Vector3;
  8001. /** Gets or sets current rotation quaternion (in local space) */
  8002. rotationQuaternion: Quaternion;
  8003. /** Gets or sets current scaling (in local space) */
  8004. scaling: Vector3;
  8005. /**
  8006. * Gets the animation properties override
  8007. */
  8008. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8009. private _decompose;
  8010. private _compose;
  8011. /**
  8012. * Update the base and local matrices
  8013. * @param matrix defines the new base or local matrix
  8014. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8015. * @param updateLocalMatrix defines if the local matrix should be updated
  8016. */
  8017. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8018. /** @hidden */
  8019. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8020. /**
  8021. * Flag the bone as dirty (Forcing it to update everything)
  8022. */
  8023. markAsDirty(): void;
  8024. private _markAsDirtyAndCompose;
  8025. private _markAsDirtyAndDecompose;
  8026. /**
  8027. * Translate the bone in local or world space
  8028. * @param vec The amount to translate the bone
  8029. * @param space The space that the translation is in
  8030. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8031. */
  8032. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8033. /**
  8034. * Set the postion of the bone in local or world space
  8035. * @param position The position to set the bone
  8036. * @param space The space that the position is in
  8037. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8038. */
  8039. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8040. /**
  8041. * Set the absolute position of the bone (world space)
  8042. * @param position The position to set the bone
  8043. * @param mesh The mesh that this bone is attached to
  8044. */
  8045. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8046. /**
  8047. * Scale the bone on the x, y and z axes (in local space)
  8048. * @param x The amount to scale the bone on the x axis
  8049. * @param y The amount to scale the bone on the y axis
  8050. * @param z The amount to scale the bone on the z axis
  8051. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8052. */
  8053. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8054. /**
  8055. * Set the bone scaling in local space
  8056. * @param scale defines the scaling vector
  8057. */
  8058. setScale(scale: Vector3): void;
  8059. /**
  8060. * Gets the current scaling in local space
  8061. * @returns the current scaling vector
  8062. */
  8063. getScale(): Vector3;
  8064. /**
  8065. * Gets the current scaling in local space and stores it in a target vector
  8066. * @param result defines the target vector
  8067. */
  8068. getScaleToRef(result: Vector3): void;
  8069. /**
  8070. * Set the yaw, pitch, and roll of the bone in local or world space
  8071. * @param yaw The rotation of the bone on the y axis
  8072. * @param pitch The rotation of the bone on the x axis
  8073. * @param roll The rotation of the bone on the z axis
  8074. * @param space The space that the axes of rotation are in
  8075. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8076. */
  8077. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8078. /**
  8079. * Add a rotation to the bone on an axis in local or world space
  8080. * @param axis The axis to rotate the bone on
  8081. * @param amount The amount to rotate the bone
  8082. * @param space The space that the axis is in
  8083. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8084. */
  8085. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8086. /**
  8087. * Set the rotation of the bone to a particular axis angle in local or world space
  8088. * @param axis The axis to rotate the bone on
  8089. * @param angle The angle that the bone should be rotated to
  8090. * @param space The space that the axis is in
  8091. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8092. */
  8093. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8094. /**
  8095. * Set the euler rotation of the bone in local of world space
  8096. * @param rotation The euler rotation that the bone should be set to
  8097. * @param space The space that the rotation is in
  8098. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8099. */
  8100. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8101. /**
  8102. * Set the quaternion rotation of the bone in local of world space
  8103. * @param quat The quaternion rotation that the bone should be set to
  8104. * @param space The space that the rotation is in
  8105. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8106. */
  8107. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8108. /**
  8109. * Set the rotation matrix of the bone in local of world space
  8110. * @param rotMat The rotation matrix that the bone should be set to
  8111. * @param space The space that the rotation is in
  8112. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8113. */
  8114. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8115. private _rotateWithMatrix;
  8116. private _getNegativeRotationToRef;
  8117. /**
  8118. * Get the position of the bone in local or world space
  8119. * @param space The space that the returned position is in
  8120. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8121. * @returns The position of the bone
  8122. */
  8123. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8124. /**
  8125. * Copy the position of the bone to a vector3 in local or world space
  8126. * @param space The space that the returned position is in
  8127. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8128. * @param result The vector3 to copy the position to
  8129. */
  8130. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8131. /**
  8132. * Get the absolute position of the bone (world space)
  8133. * @param mesh The mesh that this bone is attached to
  8134. * @returns The absolute position of the bone
  8135. */
  8136. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8137. /**
  8138. * Copy the absolute position of the bone (world space) to the result param
  8139. * @param mesh The mesh that this bone is attached to
  8140. * @param result The vector3 to copy the absolute position to
  8141. */
  8142. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8143. /**
  8144. * Compute the absolute transforms of this bone and its children
  8145. */
  8146. computeAbsoluteTransforms(): void;
  8147. /**
  8148. * Get the world direction from an axis that is in the local space of the bone
  8149. * @param localAxis The local direction that is used to compute the world direction
  8150. * @param mesh The mesh that this bone is attached to
  8151. * @returns The world direction
  8152. */
  8153. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8154. /**
  8155. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8156. * @param localAxis The local direction that is used to compute the world direction
  8157. * @param mesh The mesh that this bone is attached to
  8158. * @param result The vector3 that the world direction will be copied to
  8159. */
  8160. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8161. /**
  8162. * Get the euler rotation of the bone in local or world space
  8163. * @param space The space that the rotation should be in
  8164. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8165. * @returns The euler rotation
  8166. */
  8167. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8168. /**
  8169. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8170. * @param space The space that the rotation should be in
  8171. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8172. * @param result The vector3 that the rotation should be copied to
  8173. */
  8174. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8175. /**
  8176. * Get the quaternion rotation of the bone in either local or world space
  8177. * @param space The space that the rotation should be in
  8178. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8179. * @returns The quaternion rotation
  8180. */
  8181. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8182. /**
  8183. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8184. * @param space The space that the rotation should be in
  8185. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8186. * @param result The quaternion that the rotation should be copied to
  8187. */
  8188. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8189. /**
  8190. * Get the rotation matrix of the bone in local or world space
  8191. * @param space The space that the rotation should be in
  8192. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8193. * @returns The rotation matrix
  8194. */
  8195. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8196. /**
  8197. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8198. * @param space The space that the rotation should be in
  8199. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8200. * @param result The quaternion that the rotation should be copied to
  8201. */
  8202. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8203. /**
  8204. * Get the world position of a point that is in the local space of the bone
  8205. * @param position The local position
  8206. * @param mesh The mesh that this bone is attached to
  8207. * @returns The world position
  8208. */
  8209. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8210. /**
  8211. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8212. * @param position The local position
  8213. * @param mesh The mesh that this bone is attached to
  8214. * @param result The vector3 that the world position should be copied to
  8215. */
  8216. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8217. /**
  8218. * Get the local position of a point that is in world space
  8219. * @param position The world position
  8220. * @param mesh The mesh that this bone is attached to
  8221. * @returns The local position
  8222. */
  8223. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8224. /**
  8225. * Get the local position of a point that is in world space and copy it to the result param
  8226. * @param position The world position
  8227. * @param mesh The mesh that this bone is attached to
  8228. * @param result The vector3 that the local position should be copied to
  8229. */
  8230. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8231. }
  8232. }
  8233. declare module "babylonjs/Materials/Textures/cubeTexture" {
  8234. import { Nullable } from "babylonjs/types";
  8235. import { Scene } from "babylonjs/scene";
  8236. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8237. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8238. /**
  8239. * Class for creating a cube texture
  8240. */
  8241. export class CubeTexture extends BaseTexture {
  8242. private _delayedOnLoad;
  8243. /**
  8244. * The url of the texture
  8245. */
  8246. url: string;
  8247. /**
  8248. * Gets or sets the center of the bounding box associated with the cube texture.
  8249. * It must define where the camera used to render the texture was set
  8250. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8251. */
  8252. boundingBoxPosition: Vector3;
  8253. private _boundingBoxSize;
  8254. /**
  8255. * Gets or sets the size of the bounding box associated with the cube texture
  8256. * When defined, the cubemap will switch to local mode
  8257. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8258. * @example https://www.babylonjs-playground.com/#RNASML
  8259. */
  8260. /**
  8261. * Returns the bounding box size
  8262. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8263. */
  8264. boundingBoxSize: Vector3;
  8265. protected _rotationY: number;
  8266. /**
  8267. * Sets texture matrix rotation angle around Y axis in radians.
  8268. */
  8269. /**
  8270. * Gets texture matrix rotation angle around Y axis radians.
  8271. */
  8272. rotationY: number;
  8273. /**
  8274. * Are mip maps generated for this texture or not.
  8275. */
  8276. readonly noMipmap: boolean;
  8277. private _noMipmap;
  8278. private _files;
  8279. private _extensions;
  8280. private _textureMatrix;
  8281. private _format;
  8282. private _createPolynomials;
  8283. /** @hidden */
  8284. _prefiltered: boolean;
  8285. /**
  8286. * Creates a cube texture from an array of image urls
  8287. * @param files defines an array of image urls
  8288. * @param scene defines the hosting scene
  8289. * @param noMipmap specifies if mip maps are not used
  8290. * @returns a cube texture
  8291. */
  8292. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8293. /**
  8294. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8295. * @param url defines the url of the prefiltered texture
  8296. * @param scene defines the scene the texture is attached to
  8297. * @param forcedExtension defines the extension of the file if different from the url
  8298. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8299. * @return the prefiltered texture
  8300. */
  8301. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8302. /**
  8303. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8304. * as prefiltered data.
  8305. * @param rootUrl defines the url of the texture or the root name of the six images
  8306. * @param scene defines the scene the texture is attached to
  8307. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8308. * @param noMipmap defines if mipmaps should be created or not
  8309. * @param files defines the six files to load for the different faces
  8310. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8311. * @param onError defines a callback triggered in case of error during load
  8312. * @param format defines the internal format to use for the texture once loaded
  8313. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8314. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8315. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8316. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8317. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8318. * @return the cube texture
  8319. */
  8320. 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);
  8321. /**
  8322. * Get the current class name of the texture useful for serialization or dynamic coding.
  8323. * @returns "CubeTexture"
  8324. */
  8325. getClassName(): string;
  8326. /**
  8327. * Update the url (and optional buffer) of this texture if url was null during construction.
  8328. * @param url the url of the texture
  8329. * @param forcedExtension defines the extension to use
  8330. * @param onLoad callback called when the texture is loaded (defaults to null)
  8331. */
  8332. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8333. /**
  8334. * Delays loading of the cube texture
  8335. * @param forcedExtension defines the extension to use
  8336. */
  8337. delayLoad(forcedExtension?: string): void;
  8338. /**
  8339. * Returns the reflection texture matrix
  8340. * @returns the reflection texture matrix
  8341. */
  8342. getReflectionTextureMatrix(): Matrix;
  8343. /**
  8344. * Sets the reflection texture matrix
  8345. * @param value Reflection texture matrix
  8346. */
  8347. setReflectionTextureMatrix(value: Matrix): void;
  8348. /**
  8349. * Parses text to create a cube texture
  8350. * @param parsedTexture define the serialized text to read from
  8351. * @param scene defines the hosting scene
  8352. * @param rootUrl defines the root url of the cube texture
  8353. * @returns a cube texture
  8354. */
  8355. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8356. /**
  8357. * Makes a clone, or deep copy, of the cube texture
  8358. * @returns a new cube texture
  8359. */
  8360. clone(): CubeTexture;
  8361. }
  8362. }
  8363. declare module "babylonjs/Shaders/postprocess.vertex" {
  8364. /** @hidden */
  8365. export var postprocessVertexShader: {
  8366. name: string;
  8367. shader: string;
  8368. };
  8369. }
  8370. declare module "babylonjs/Cameras/targetCamera" {
  8371. import { Nullable } from "babylonjs/types";
  8372. import { Camera } from "babylonjs/Cameras/camera";
  8373. import { Scene } from "babylonjs/scene";
  8374. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  8375. /**
  8376. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8377. * This is the base of the follow, arc rotate cameras and Free camera
  8378. * @see http://doc.babylonjs.com/features/cameras
  8379. */
  8380. export class TargetCamera extends Camera {
  8381. private static _RigCamTransformMatrix;
  8382. private static _TargetTransformMatrix;
  8383. private static _TargetFocalPoint;
  8384. /**
  8385. * Define the current direction the camera is moving to
  8386. */
  8387. cameraDirection: Vector3;
  8388. /**
  8389. * Define the current rotation the camera is rotating to
  8390. */
  8391. cameraRotation: Vector2;
  8392. /**
  8393. * When set, the up vector of the camera will be updated by the rotation of the camera
  8394. */
  8395. updateUpVectorFromRotation: boolean;
  8396. private _tmpQuaternion;
  8397. /**
  8398. * Define the current rotation of the camera
  8399. */
  8400. rotation: Vector3;
  8401. /**
  8402. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8403. */
  8404. rotationQuaternion: Quaternion;
  8405. /**
  8406. * Define the current speed of the camera
  8407. */
  8408. speed: number;
  8409. /**
  8410. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8411. * around all axis.
  8412. */
  8413. noRotationConstraint: boolean;
  8414. /**
  8415. * Define the current target of the camera as an object or a position.
  8416. */
  8417. lockedTarget: any;
  8418. /** @hidden */
  8419. _currentTarget: Vector3;
  8420. /** @hidden */
  8421. _initialFocalDistance: number;
  8422. /** @hidden */
  8423. _viewMatrix: Matrix;
  8424. /** @hidden */
  8425. _camMatrix: Matrix;
  8426. /** @hidden */
  8427. _cameraTransformMatrix: Matrix;
  8428. /** @hidden */
  8429. _cameraRotationMatrix: Matrix;
  8430. /** @hidden */
  8431. _referencePoint: Vector3;
  8432. /** @hidden */
  8433. _transformedReferencePoint: Vector3;
  8434. protected _globalCurrentTarget: Vector3;
  8435. protected _globalCurrentUpVector: Vector3;
  8436. /** @hidden */
  8437. _reset: () => void;
  8438. private _defaultUp;
  8439. /**
  8440. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8441. * This is the base of the follow, arc rotate cameras and Free camera
  8442. * @see http://doc.babylonjs.com/features/cameras
  8443. * @param name Defines the name of the camera in the scene
  8444. * @param position Defines the start position of the camera in the scene
  8445. * @param scene Defines the scene the camera belongs to
  8446. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8447. */
  8448. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8449. /**
  8450. * Gets the position in front of the camera at a given distance.
  8451. * @param distance The distance from the camera we want the position to be
  8452. * @returns the position
  8453. */
  8454. getFrontPosition(distance: number): Vector3;
  8455. /** @hidden */
  8456. _getLockedTargetPosition(): Nullable<Vector3>;
  8457. private _storedPosition;
  8458. private _storedRotation;
  8459. private _storedRotationQuaternion;
  8460. /**
  8461. * Store current camera state of the camera (fov, position, rotation, etc..)
  8462. * @returns the camera
  8463. */
  8464. storeState(): Camera;
  8465. /**
  8466. * Restored camera state. You must call storeState() first
  8467. * @returns whether it was successful or not
  8468. * @hidden
  8469. */
  8470. _restoreStateValues(): boolean;
  8471. /** @hidden */
  8472. _initCache(): void;
  8473. /** @hidden */
  8474. _updateCache(ignoreParentClass?: boolean): void;
  8475. /** @hidden */
  8476. _isSynchronizedViewMatrix(): boolean;
  8477. /** @hidden */
  8478. _computeLocalCameraSpeed(): number;
  8479. /** @hidden */
  8480. setTarget(target: Vector3): void;
  8481. /**
  8482. * Return the current target position of the camera. This value is expressed in local space.
  8483. * @returns the target position
  8484. */
  8485. getTarget(): Vector3;
  8486. /** @hidden */
  8487. _decideIfNeedsToMove(): boolean;
  8488. /** @hidden */
  8489. _updatePosition(): void;
  8490. /** @hidden */
  8491. _checkInputs(): void;
  8492. protected _updateCameraRotationMatrix(): void;
  8493. /**
  8494. * 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)
  8495. * @returns the current camera
  8496. */
  8497. private _rotateUpVectorWithCameraRotationMatrix;
  8498. private _cachedRotationZ;
  8499. private _cachedQuaternionRotationZ;
  8500. /** @hidden */
  8501. _getViewMatrix(): Matrix;
  8502. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8503. /**
  8504. * @hidden
  8505. */
  8506. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8507. /**
  8508. * @hidden
  8509. */
  8510. _updateRigCameras(): void;
  8511. private _getRigCamPositionAndTarget;
  8512. /**
  8513. * Gets the current object class name.
  8514. * @return the class name
  8515. */
  8516. getClassName(): string;
  8517. }
  8518. }
  8519. declare module "babylonjs/Cameras/cameraInputsManager" {
  8520. import { Nullable } from "babylonjs/types";
  8521. import { Camera } from "babylonjs/Cameras/camera";
  8522. /**
  8523. * @ignore
  8524. * This is a list of all the different input types that are available in the application.
  8525. * Fo instance: ArcRotateCameraGamepadInput...
  8526. */
  8527. export var CameraInputTypes: {};
  8528. /**
  8529. * This is the contract to implement in order to create a new input class.
  8530. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8531. */
  8532. export interface ICameraInput<TCamera extends Camera> {
  8533. /**
  8534. * Defines the camera the input is attached to.
  8535. */
  8536. camera: Nullable<TCamera>;
  8537. /**
  8538. * Gets the class name of the current intput.
  8539. * @returns the class name
  8540. */
  8541. getClassName(): string;
  8542. /**
  8543. * Get the friendly name associated with the input class.
  8544. * @returns the input friendly name
  8545. */
  8546. getSimpleName(): string;
  8547. /**
  8548. * Attach the input controls to a specific dom element to get the input from.
  8549. * @param element Defines the element the controls should be listened from
  8550. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8551. */
  8552. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8553. /**
  8554. * Detach the current controls from the specified dom element.
  8555. * @param element Defines the element to stop listening the inputs from
  8556. */
  8557. detachControl(element: Nullable<HTMLElement>): void;
  8558. /**
  8559. * Update the current camera state depending on the inputs that have been used this frame.
  8560. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8561. */
  8562. checkInputs?: () => void;
  8563. }
  8564. /**
  8565. * Represents a map of input types to input instance or input index to input instance.
  8566. */
  8567. export interface CameraInputsMap<TCamera extends Camera> {
  8568. /**
  8569. * Accessor to the input by input type.
  8570. */
  8571. [name: string]: ICameraInput<TCamera>;
  8572. /**
  8573. * Accessor to the input by input index.
  8574. */
  8575. [idx: number]: ICameraInput<TCamera>;
  8576. }
  8577. /**
  8578. * This represents the input manager used within a camera.
  8579. * It helps dealing with all the different kind of input attached to a camera.
  8580. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8581. */
  8582. export class CameraInputsManager<TCamera extends Camera> {
  8583. /**
  8584. * Defines the list of inputs attahed to the camera.
  8585. */
  8586. attached: CameraInputsMap<TCamera>;
  8587. /**
  8588. * Defines the dom element the camera is collecting inputs from.
  8589. * This is null if the controls have not been attached.
  8590. */
  8591. attachedElement: Nullable<HTMLElement>;
  8592. /**
  8593. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8594. */
  8595. noPreventDefault: boolean;
  8596. /**
  8597. * Defined the camera the input manager belongs to.
  8598. */
  8599. camera: TCamera;
  8600. /**
  8601. * Update the current camera state depending on the inputs that have been used this frame.
  8602. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8603. */
  8604. checkInputs: () => void;
  8605. /**
  8606. * Instantiate a new Camera Input Manager.
  8607. * @param camera Defines the camera the input manager blongs to
  8608. */
  8609. constructor(camera: TCamera);
  8610. /**
  8611. * Add an input method to a camera
  8612. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8613. * @param input camera input method
  8614. */
  8615. add(input: ICameraInput<TCamera>): void;
  8616. /**
  8617. * Remove a specific input method from a camera
  8618. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8619. * @param inputToRemove camera input method
  8620. */
  8621. remove(inputToRemove: ICameraInput<TCamera>): void;
  8622. /**
  8623. * Remove a specific input type from a camera
  8624. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8625. * @param inputType the type of the input to remove
  8626. */
  8627. removeByType(inputType: string): void;
  8628. private _addCheckInputs;
  8629. /**
  8630. * Attach the input controls to the currently attached dom element to listen the events from.
  8631. * @param input Defines the input to attach
  8632. */
  8633. attachInput(input: ICameraInput<TCamera>): void;
  8634. /**
  8635. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8636. * @param element Defines the dom element to collect the events 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. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8640. /**
  8641. * Detach the current manager inputs controls from a specific dom element.
  8642. * @param element Defines the dom element to collect the events from
  8643. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8644. */
  8645. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8646. /**
  8647. * Rebuild the dynamic inputCheck function from the current list of
  8648. * defined inputs in the manager.
  8649. */
  8650. rebuildInputCheck(): void;
  8651. /**
  8652. * Remove all attached input methods from a camera
  8653. */
  8654. clear(): void;
  8655. /**
  8656. * Serialize the current input manager attached to a camera.
  8657. * This ensures than once parsed,
  8658. * the input associated to the camera will be identical to the current ones
  8659. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8660. */
  8661. serialize(serializedCamera: any): void;
  8662. /**
  8663. * Parses an input manager serialized JSON to restore the previous list of inputs
  8664. * and states associated to a camera.
  8665. * @param parsedCamera Defines the JSON to parse
  8666. */
  8667. parse(parsedCamera: any): void;
  8668. }
  8669. }
  8670. declare module "babylonjs/Events/keyboardEvents" {
  8671. /**
  8672. * Gather the list of keyboard event types as constants.
  8673. */
  8674. export class KeyboardEventTypes {
  8675. /**
  8676. * The keydown event is fired when a key becomes active (pressed).
  8677. */
  8678. static readonly KEYDOWN: number;
  8679. /**
  8680. * The keyup event is fired when a key has been released.
  8681. */
  8682. static readonly KEYUP: number;
  8683. }
  8684. /**
  8685. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8686. */
  8687. export class KeyboardInfo {
  8688. /**
  8689. * Defines the type of event (KeyboardEventTypes)
  8690. */
  8691. type: number;
  8692. /**
  8693. * Defines the related dom event
  8694. */
  8695. event: KeyboardEvent;
  8696. /**
  8697. * Instantiates a new keyboard info.
  8698. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8699. * @param type Defines the type of event (KeyboardEventTypes)
  8700. * @param event Defines the related dom event
  8701. */
  8702. constructor(
  8703. /**
  8704. * Defines the type of event (KeyboardEventTypes)
  8705. */
  8706. type: number,
  8707. /**
  8708. * Defines the related dom event
  8709. */
  8710. event: KeyboardEvent);
  8711. }
  8712. /**
  8713. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8714. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8715. */
  8716. export class KeyboardInfoPre extends KeyboardInfo {
  8717. /**
  8718. * Defines the type of event (KeyboardEventTypes)
  8719. */
  8720. type: number;
  8721. /**
  8722. * Defines the related dom event
  8723. */
  8724. event: KeyboardEvent;
  8725. /**
  8726. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8727. */
  8728. skipOnPointerObservable: boolean;
  8729. /**
  8730. * Instantiates a new keyboard pre info.
  8731. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8732. * @param type Defines the type of event (KeyboardEventTypes)
  8733. * @param event Defines the related dom event
  8734. */
  8735. constructor(
  8736. /**
  8737. * Defines the type of event (KeyboardEventTypes)
  8738. */
  8739. type: number,
  8740. /**
  8741. * Defines the related dom event
  8742. */
  8743. event: KeyboardEvent);
  8744. }
  8745. }
  8746. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8747. import { Nullable } from "babylonjs/types";
  8748. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8749. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8750. /**
  8751. * Manage the keyboard inputs to control the movement of a free camera.
  8752. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8753. */
  8754. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8755. /**
  8756. * Defines the camera the input is attached to.
  8757. */
  8758. camera: FreeCamera;
  8759. /**
  8760. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8761. */
  8762. keysUp: number[];
  8763. /**
  8764. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8765. */
  8766. keysDown: number[];
  8767. /**
  8768. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8769. */
  8770. keysLeft: number[];
  8771. /**
  8772. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8773. */
  8774. keysRight: number[];
  8775. private _keys;
  8776. private _onCanvasBlurObserver;
  8777. private _onKeyboardObserver;
  8778. private _engine;
  8779. private _scene;
  8780. /**
  8781. * Attach the input controls to a specific dom element to get the input from.
  8782. * @param element Defines the element the controls should be listened from
  8783. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8784. */
  8785. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8786. /**
  8787. * Detach the current controls from the specified dom element.
  8788. * @param element Defines the element to stop listening the inputs from
  8789. */
  8790. detachControl(element: Nullable<HTMLElement>): void;
  8791. /**
  8792. * Update the current camera state depending on the inputs that have been used this frame.
  8793. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8794. */
  8795. checkInputs(): void;
  8796. /**
  8797. * Gets the class name of the current intput.
  8798. * @returns the class name
  8799. */
  8800. getClassName(): string;
  8801. /** @hidden */
  8802. _onLostFocus(): void;
  8803. /**
  8804. * Get the friendly name associated with the input class.
  8805. * @returns the input friendly name
  8806. */
  8807. getSimpleName(): string;
  8808. }
  8809. }
  8810. declare module "babylonjs/Lights/shadowLight" {
  8811. import { Camera } from "babylonjs/Cameras/camera";
  8812. import { Scene } from "babylonjs/scene";
  8813. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8814. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8815. import { Light } from "babylonjs/Lights/light";
  8816. /**
  8817. * Interface describing all the common properties and methods a shadow light needs to implement.
  8818. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8819. * as well as binding the different shadow properties to the effects.
  8820. */
  8821. export interface IShadowLight extends Light {
  8822. /**
  8823. * The light id in the scene (used in scene.findLighById for instance)
  8824. */
  8825. id: string;
  8826. /**
  8827. * The position the shdow will be casted from.
  8828. */
  8829. position: Vector3;
  8830. /**
  8831. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8832. */
  8833. direction: Vector3;
  8834. /**
  8835. * The transformed position. Position of the light in world space taking parenting in account.
  8836. */
  8837. transformedPosition: Vector3;
  8838. /**
  8839. * The transformed direction. Direction of the light in world space taking parenting in account.
  8840. */
  8841. transformedDirection: Vector3;
  8842. /**
  8843. * The friendly name of the light in the scene.
  8844. */
  8845. name: string;
  8846. /**
  8847. * Defines the shadow projection clipping minimum z value.
  8848. */
  8849. shadowMinZ: number;
  8850. /**
  8851. * Defines the shadow projection clipping maximum z value.
  8852. */
  8853. shadowMaxZ: number;
  8854. /**
  8855. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8856. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8857. */
  8858. computeTransformedInformation(): boolean;
  8859. /**
  8860. * Gets the scene the light belongs to.
  8861. * @returns The scene
  8862. */
  8863. getScene(): Scene;
  8864. /**
  8865. * Callback defining a custom Projection Matrix Builder.
  8866. * This can be used to override the default projection matrix computation.
  8867. */
  8868. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8869. /**
  8870. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8871. * @param matrix The materix to updated with the projection information
  8872. * @param viewMatrix The transform matrix of the light
  8873. * @param renderList The list of mesh to render in the map
  8874. * @returns The current light
  8875. */
  8876. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8877. /**
  8878. * Gets the current depth scale used in ESM.
  8879. * @returns The scale
  8880. */
  8881. getDepthScale(): number;
  8882. /**
  8883. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8884. * @returns true if a cube texture needs to be use
  8885. */
  8886. needCube(): boolean;
  8887. /**
  8888. * Detects if the projection matrix requires to be recomputed this frame.
  8889. * @returns true if it requires to be recomputed otherwise, false.
  8890. */
  8891. needProjectionMatrixCompute(): boolean;
  8892. /**
  8893. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8894. */
  8895. forceProjectionMatrixCompute(): void;
  8896. /**
  8897. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8898. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8899. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8900. */
  8901. getShadowDirection(faceIndex?: number): Vector3;
  8902. /**
  8903. * Gets the minZ used for shadow according to both the scene and the light.
  8904. * @param activeCamera The camera we are returning the min for
  8905. * @returns the depth min z
  8906. */
  8907. getDepthMinZ(activeCamera: Camera): number;
  8908. /**
  8909. * Gets the maxZ used for shadow according to both the scene and the light.
  8910. * @param activeCamera The camera we are returning the max for
  8911. * @returns the depth max z
  8912. */
  8913. getDepthMaxZ(activeCamera: Camera): number;
  8914. }
  8915. /**
  8916. * Base implementation IShadowLight
  8917. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8918. */
  8919. export abstract class ShadowLight extends Light implements IShadowLight {
  8920. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8921. protected _position: Vector3;
  8922. protected _setPosition(value: Vector3): void;
  8923. /**
  8924. * Sets the position the shadow will be casted from. Also use as the light position for both
  8925. * point and spot lights.
  8926. */
  8927. /**
  8928. * Sets the position the shadow will be casted from. Also use as the light position for both
  8929. * point and spot lights.
  8930. */
  8931. position: Vector3;
  8932. protected _direction: Vector3;
  8933. protected _setDirection(value: Vector3): void;
  8934. /**
  8935. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8936. * Also use as the light direction on spot and directional lights.
  8937. */
  8938. /**
  8939. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8940. * Also use as the light direction on spot and directional lights.
  8941. */
  8942. direction: Vector3;
  8943. private _shadowMinZ;
  8944. /**
  8945. * Gets the shadow projection clipping minimum z value.
  8946. */
  8947. /**
  8948. * Sets the shadow projection clipping minimum z value.
  8949. */
  8950. shadowMinZ: number;
  8951. private _shadowMaxZ;
  8952. /**
  8953. * Sets the shadow projection clipping maximum z value.
  8954. */
  8955. /**
  8956. * Gets the shadow projection clipping maximum z value.
  8957. */
  8958. shadowMaxZ: number;
  8959. /**
  8960. * Callback defining a custom Projection Matrix Builder.
  8961. * This can be used to override the default projection matrix computation.
  8962. */
  8963. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8964. /**
  8965. * The transformed position. Position of the light in world space taking parenting in account.
  8966. */
  8967. transformedPosition: Vector3;
  8968. /**
  8969. * The transformed direction. Direction of the light in world space taking parenting in account.
  8970. */
  8971. transformedDirection: Vector3;
  8972. private _needProjectionMatrixCompute;
  8973. /**
  8974. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8975. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8976. */
  8977. computeTransformedInformation(): boolean;
  8978. /**
  8979. * Return the depth scale used for the shadow map.
  8980. * @returns the depth scale.
  8981. */
  8982. getDepthScale(): number;
  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. * Returns the ShadowLight absolute position in the World.
  8991. * @returns the position vector in world space
  8992. */
  8993. getAbsolutePosition(): Vector3;
  8994. /**
  8995. * Sets the ShadowLight direction toward the passed target.
  8996. * @param target The point to target in local space
  8997. * @returns the updated ShadowLight direction
  8998. */
  8999. setDirectionToTarget(target: Vector3): Vector3;
  9000. /**
  9001. * Returns the light rotation in euler definition.
  9002. * @returns the x y z rotation in local space.
  9003. */
  9004. getRotation(): Vector3;
  9005. /**
  9006. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9007. * @returns true if a cube texture needs to be use
  9008. */
  9009. needCube(): boolean;
  9010. /**
  9011. * Detects if the projection matrix requires to be recomputed this frame.
  9012. * @returns true if it requires to be recomputed otherwise, false.
  9013. */
  9014. needProjectionMatrixCompute(): boolean;
  9015. /**
  9016. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9017. */
  9018. forceProjectionMatrixCompute(): void;
  9019. /** @hidden */
  9020. _initCache(): void;
  9021. /** @hidden */
  9022. _isSynchronized(): boolean;
  9023. /**
  9024. * Computes the world matrix of the node
  9025. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9026. * @returns the world matrix
  9027. */
  9028. computeWorldMatrix(force?: boolean): Matrix;
  9029. /**
  9030. * Gets the minZ used for shadow according to both the scene and the light.
  9031. * @param activeCamera The camera we are returning the min for
  9032. * @returns the depth min z
  9033. */
  9034. getDepthMinZ(activeCamera: Camera): number;
  9035. /**
  9036. * Gets the maxZ used for shadow according to both the scene and the light.
  9037. * @param activeCamera The camera we are returning the max for
  9038. * @returns the depth max z
  9039. */
  9040. getDepthMaxZ(activeCamera: Camera): number;
  9041. /**
  9042. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9043. * @param matrix The materix to updated with the projection information
  9044. * @param viewMatrix The transform matrix of the light
  9045. * @param renderList The list of mesh to render in the map
  9046. * @returns The current light
  9047. */
  9048. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9049. }
  9050. }
  9051. declare module "babylonjs/Materials/materialHelper" {
  9052. import { Nullable } from "babylonjs/types";
  9053. import { Scene } from "babylonjs/scene";
  9054. import { Engine } from "babylonjs/Engines/engine";
  9055. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9056. import { Light } from "babylonjs/Lights/light";
  9057. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9058. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  9059. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9060. /**
  9061. * "Static Class" containing the most commonly used helper while dealing with material for
  9062. * rendering purpose.
  9063. *
  9064. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9065. *
  9066. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9067. */
  9068. export class MaterialHelper {
  9069. /**
  9070. * Bind the current view position to an effect.
  9071. * @param effect The effect to be bound
  9072. * @param scene The scene the eyes position is used from
  9073. */
  9074. static BindEyePosition(effect: Effect, scene: Scene): void;
  9075. /**
  9076. * Helps preparing the defines values about the UVs in used in the effect.
  9077. * UVs are shared as much as we can accross channels in the shaders.
  9078. * @param texture The texture we are preparing the UVs for
  9079. * @param defines The defines to update
  9080. * @param key The channel key "diffuse", "specular"... used in the shader
  9081. */
  9082. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9083. /**
  9084. * Binds a texture matrix value to its corrsponding uniform
  9085. * @param texture The texture to bind the matrix for
  9086. * @param uniformBuffer The uniform buffer receivin the data
  9087. * @param key The channel key "diffuse", "specular"... used in the shader
  9088. */
  9089. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9090. /**
  9091. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9092. * @param mesh defines the current mesh
  9093. * @param scene defines the current scene
  9094. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9095. * @param pointsCloud defines if point cloud rendering has to be turned on
  9096. * @param fogEnabled defines if fog has to be turned on
  9097. * @param alphaTest defines if alpha testing has to be turned on
  9098. * @param defines defines the current list of defines
  9099. */
  9100. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9101. /**
  9102. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9103. * @param scene defines the current scene
  9104. * @param engine defines the current engine
  9105. * @param defines specifies the list of active defines
  9106. * @param useInstances defines if instances have to be turned on
  9107. * @param useClipPlane defines if clip plane have to be turned on
  9108. */
  9109. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9110. /**
  9111. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9112. * @param mesh The mesh containing the geometry data we will draw
  9113. * @param defines The defines to update
  9114. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9115. * @param useBones Precise whether bones should be used or not (override mesh info)
  9116. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9117. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9118. * @returns false if defines are considered not dirty and have not been checked
  9119. */
  9120. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9121. /**
  9122. * Prepares the defines related to the light information passed in parameter
  9123. * @param scene The scene we are intending to draw
  9124. * @param mesh The mesh the effect is compiling for
  9125. * @param defines The defines to update
  9126. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9127. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9128. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9129. * @returns true if normals will be required for the rest of the effect
  9130. */
  9131. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9132. /**
  9133. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9134. * that won t be acctive due to defines being turned off.
  9135. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9136. * @param samplersList The samplers list
  9137. * @param defines The defines helping in the list generation
  9138. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9139. */
  9140. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9141. /**
  9142. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9143. * @param defines The defines to update while falling back
  9144. * @param fallbacks The authorized effect fallbacks
  9145. * @param maxSimultaneousLights The maximum number of lights allowed
  9146. * @param rank the current rank of the Effect
  9147. * @returns The newly affected rank
  9148. */
  9149. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9150. /**
  9151. * Prepares the list of attributes required for morph targets according to the effect defines.
  9152. * @param attribs The current list of supported attribs
  9153. * @param mesh The mesh to prepare the morph targets attributes for
  9154. * @param defines The current Defines of the effect
  9155. */
  9156. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9157. /**
  9158. * Prepares the list of attributes required for bones according to the effect defines.
  9159. * @param attribs The current list of supported attribs
  9160. * @param mesh The mesh to prepare the bones attributes for
  9161. * @param defines The current Defines of the effect
  9162. * @param fallbacks The current efffect fallback strategy
  9163. */
  9164. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9165. /**
  9166. * Prepares the list of attributes required for instances according to the effect defines.
  9167. * @param attribs The current list of supported attribs
  9168. * @param defines The current Defines of the effect
  9169. */
  9170. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9171. /**
  9172. * Binds the light shadow information to the effect for the given mesh.
  9173. * @param light The light containing the generator
  9174. * @param scene The scene the lights belongs to
  9175. * @param mesh The mesh we are binding the information to render
  9176. * @param lightIndex The light index in the effect used to render the mesh
  9177. * @param effect The effect we are binding the data to
  9178. */
  9179. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9180. /**
  9181. * Binds the light information to the effect.
  9182. * @param light The light containing the generator
  9183. * @param effect The effect we are binding the data to
  9184. * @param lightIndex The light index in the effect used to render
  9185. */
  9186. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9187. /**
  9188. * Binds the lights information from the scene to the effect for the given mesh.
  9189. * @param scene The scene the lights belongs to
  9190. * @param mesh The mesh we are binding the information to render
  9191. * @param effect The effect we are binding the data to
  9192. * @param defines The generated defines for the effect
  9193. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9194. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9195. */
  9196. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9197. private static _tempFogColor;
  9198. /**
  9199. * Binds the fog information from the scene to the effect for the given mesh.
  9200. * @param scene The scene the lights belongs to
  9201. * @param mesh The mesh we are binding the information to render
  9202. * @param effect The effect we are binding the data to
  9203. * @param linearSpace Defines if the fog effect is applied in linear space
  9204. */
  9205. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9206. /**
  9207. * Binds the bones information from the mesh to the effect.
  9208. * @param mesh The mesh we are binding the information to render
  9209. * @param effect The effect we are binding the data to
  9210. */
  9211. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9212. /**
  9213. * Binds the morph targets information from the mesh to the effect.
  9214. * @param abstractMesh The mesh we are binding the information to render
  9215. * @param effect The effect we are binding the data to
  9216. */
  9217. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9218. /**
  9219. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9220. * @param defines The generated defines used in the effect
  9221. * @param effect The effect we are binding the data to
  9222. * @param scene The scene we are willing to render with logarithmic scale for
  9223. */
  9224. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9225. /**
  9226. * Binds the clip plane information from the scene to the effect.
  9227. * @param scene The scene the clip plane information are extracted from
  9228. * @param effect The effect we are binding the data to
  9229. */
  9230. static BindClipPlane(effect: Effect, scene: Scene): void;
  9231. }
  9232. }
  9233. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  9234. /** @hidden */
  9235. export var kernelBlurVaryingDeclaration: {
  9236. name: string;
  9237. shader: string;
  9238. };
  9239. }
  9240. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  9241. /** @hidden */
  9242. export var kernelBlurFragment: {
  9243. name: string;
  9244. shader: string;
  9245. };
  9246. }
  9247. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  9248. /** @hidden */
  9249. export var kernelBlurFragment2: {
  9250. name: string;
  9251. shader: string;
  9252. };
  9253. }
  9254. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  9255. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9256. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  9257. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  9258. /** @hidden */
  9259. export var kernelBlurPixelShader: {
  9260. name: string;
  9261. shader: string;
  9262. };
  9263. }
  9264. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  9265. /** @hidden */
  9266. export var kernelBlurVertex: {
  9267. name: string;
  9268. shader: string;
  9269. };
  9270. }
  9271. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  9272. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9273. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  9274. /** @hidden */
  9275. export var kernelBlurVertexShader: {
  9276. name: string;
  9277. shader: string;
  9278. };
  9279. }
  9280. declare module "babylonjs/PostProcesses/blurPostProcess" {
  9281. import { Vector2 } from "babylonjs/Maths/math";
  9282. import { Nullable } from "babylonjs/types";
  9283. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  9284. import { Camera } from "babylonjs/Cameras/camera";
  9285. import { Effect } from "babylonjs/Materials/effect";
  9286. import { Engine } from "babylonjs/Engines/engine";
  9287. import "babylonjs/Shaders/kernelBlur.fragment";
  9288. import "babylonjs/Shaders/kernelBlur.vertex";
  9289. /**
  9290. * The Blur Post Process which blurs an image based on a kernel and direction.
  9291. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9292. */
  9293. export class BlurPostProcess extends PostProcess {
  9294. /** The direction in which to blur the image. */
  9295. direction: Vector2;
  9296. private blockCompilation;
  9297. protected _kernel: number;
  9298. protected _idealKernel: number;
  9299. protected _packedFloat: boolean;
  9300. private _staticDefines;
  9301. /**
  9302. * Sets the length in pixels of the blur sample region
  9303. */
  9304. /**
  9305. * Gets the length in pixels of the blur sample region
  9306. */
  9307. kernel: number;
  9308. /**
  9309. * Sets wether or not the blur needs to unpack/repack floats
  9310. */
  9311. /**
  9312. * Gets wether or not the blur is unpacking/repacking floats
  9313. */
  9314. packedFloat: boolean;
  9315. /**
  9316. * Creates a new instance BlurPostProcess
  9317. * @param name The name of the effect.
  9318. * @param direction The direction in which to blur the image.
  9319. * @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.
  9320. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9321. * @param camera The camera to apply the render pass to.
  9322. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9323. * @param engine The engine which the post process will be applied. (default: current engine)
  9324. * @param reusable If the post process can be reused on the same frame. (default: false)
  9325. * @param textureType Type of textures used when performing the post process. (default: 0)
  9326. * @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)
  9327. */
  9328. constructor(name: string,
  9329. /** The direction in which to blur the image. */
  9330. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9331. /**
  9332. * Updates the effect with the current post process compile time values and recompiles the shader.
  9333. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9334. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9335. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9336. * @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
  9337. * @param onCompiled Called when the shader has been compiled.
  9338. * @param onError Called if there is an error when compiling a shader.
  9339. */
  9340. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9341. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9342. /**
  9343. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9344. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9345. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9346. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9347. * The gaps between physical kernels are compensated for in the weighting of the samples
  9348. * @param idealKernel Ideal blur kernel.
  9349. * @return Nearest best kernel.
  9350. */
  9351. protected _nearestBestKernel(idealKernel: number): number;
  9352. /**
  9353. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9354. * @param x The point on the Gaussian distribution to sample.
  9355. * @return the value of the Gaussian function at x.
  9356. */
  9357. protected _gaussianWeight(x: number): number;
  9358. /**
  9359. * Generates a string that can be used as a floating point number in GLSL.
  9360. * @param x Value to print.
  9361. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9362. * @return GLSL float string.
  9363. */
  9364. protected _glslFloat(x: number, decimalFigures?: number): string;
  9365. }
  9366. }
  9367. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9368. /** @hidden */
  9369. export var shadowMapPixelShader: {
  9370. name: string;
  9371. shader: string;
  9372. };
  9373. }
  9374. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9375. /** @hidden */
  9376. export var bonesDeclaration: {
  9377. name: string;
  9378. shader: string;
  9379. };
  9380. }
  9381. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9382. /** @hidden */
  9383. export var morphTargetsVertexGlobalDeclaration: {
  9384. name: string;
  9385. shader: string;
  9386. };
  9387. }
  9388. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9389. /** @hidden */
  9390. export var morphTargetsVertexDeclaration: {
  9391. name: string;
  9392. shader: string;
  9393. };
  9394. }
  9395. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9396. /** @hidden */
  9397. export var instancesDeclaration: {
  9398. name: string;
  9399. shader: string;
  9400. };
  9401. }
  9402. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9403. /** @hidden */
  9404. export var helperFunctions: {
  9405. name: string;
  9406. shader: string;
  9407. };
  9408. }
  9409. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9410. /** @hidden */
  9411. export var morphTargetsVertex: {
  9412. name: string;
  9413. shader: string;
  9414. };
  9415. }
  9416. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9417. /** @hidden */
  9418. export var instancesVertex: {
  9419. name: string;
  9420. shader: string;
  9421. };
  9422. }
  9423. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9424. /** @hidden */
  9425. export var bonesVertex: {
  9426. name: string;
  9427. shader: string;
  9428. };
  9429. }
  9430. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9431. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9432. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9433. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9434. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9435. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9436. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9437. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9438. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9439. /** @hidden */
  9440. export var shadowMapVertexShader: {
  9441. name: string;
  9442. shader: string;
  9443. };
  9444. }
  9445. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9446. /** @hidden */
  9447. export var depthBoxBlurPixelShader: {
  9448. name: string;
  9449. shader: string;
  9450. };
  9451. }
  9452. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9453. import { Nullable } from "babylonjs/types";
  9454. import { Scene } from "babylonjs/scene";
  9455. import { Matrix } from "babylonjs/Maths/math";
  9456. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9457. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9458. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9459. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9460. import { Effect } from "babylonjs/Materials/effect";
  9461. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9462. import "babylonjs/Shaders/shadowMap.fragment";
  9463. import "babylonjs/Shaders/shadowMap.vertex";
  9464. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9465. import { Observable } from "babylonjs/Misc/observable";
  9466. /**
  9467. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9468. */
  9469. export interface ICustomShaderOptions {
  9470. /**
  9471. * Gets or sets the custom shader name to use
  9472. */
  9473. shaderName: string;
  9474. /**
  9475. * The list of attribute names used in the shader
  9476. */
  9477. attributes?: string[];
  9478. /**
  9479. * The list of unifrom names used in the shader
  9480. */
  9481. uniforms?: string[];
  9482. /**
  9483. * The list of sampler names used in the shader
  9484. */
  9485. samplers?: string[];
  9486. /**
  9487. * The list of defines used in the shader
  9488. */
  9489. defines?: string[];
  9490. }
  9491. /**
  9492. * Interface to implement to create a shadow generator compatible with BJS.
  9493. */
  9494. export interface IShadowGenerator {
  9495. /**
  9496. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9497. * @returns The render target texture if present otherwise, null
  9498. */
  9499. getShadowMap(): Nullable<RenderTargetTexture>;
  9500. /**
  9501. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9502. * @returns The render target texture if the shadow map is present otherwise, null
  9503. */
  9504. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9505. /**
  9506. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9507. * @param subMesh The submesh we want to render in the shadow map
  9508. * @param useInstances Defines wether will draw in the map using instances
  9509. * @returns true if ready otherwise, false
  9510. */
  9511. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9512. /**
  9513. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9514. * @param defines Defines of the material we want to update
  9515. * @param lightIndex Index of the light in the enabled light list of the material
  9516. */
  9517. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9518. /**
  9519. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9520. * defined in the generator but impacting the effect).
  9521. * It implies the unifroms available on the materials are the standard BJS ones.
  9522. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9523. * @param effect The effect we are binfing the information for
  9524. */
  9525. bindShadowLight(lightIndex: string, effect: Effect): void;
  9526. /**
  9527. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9528. * (eq to shadow prjection matrix * light transform matrix)
  9529. * @returns The transform matrix used to create the shadow map
  9530. */
  9531. getTransformMatrix(): Matrix;
  9532. /**
  9533. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9534. * Cube and 2D textures for instance.
  9535. */
  9536. recreateShadowMap(): void;
  9537. /**
  9538. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9539. * @param onCompiled Callback triggered at the and of the effects compilation
  9540. * @param options Sets of optional options forcing the compilation with different modes
  9541. */
  9542. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9543. useInstances: boolean;
  9544. }>): void;
  9545. /**
  9546. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9547. * @param options Sets of optional options forcing the compilation with different modes
  9548. * @returns A promise that resolves when the compilation completes
  9549. */
  9550. forceCompilationAsync(options?: Partial<{
  9551. useInstances: boolean;
  9552. }>): Promise<void>;
  9553. /**
  9554. * Serializes the shadow generator setup to a json object.
  9555. * @returns The serialized JSON object
  9556. */
  9557. serialize(): any;
  9558. /**
  9559. * Disposes the Shadow map and related Textures and effects.
  9560. */
  9561. dispose(): void;
  9562. }
  9563. /**
  9564. * Default implementation IShadowGenerator.
  9565. * This is the main object responsible of generating shadows in the framework.
  9566. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9567. */
  9568. export class ShadowGenerator implements IShadowGenerator {
  9569. /**
  9570. * Shadow generator mode None: no filtering applied.
  9571. */
  9572. static readonly FILTER_NONE: number;
  9573. /**
  9574. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9575. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9576. */
  9577. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9578. /**
  9579. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9580. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9581. */
  9582. static readonly FILTER_POISSONSAMPLING: number;
  9583. /**
  9584. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9585. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9586. */
  9587. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9588. /**
  9589. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9590. * edge artifacts on steep falloff.
  9591. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9592. */
  9593. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9594. /**
  9595. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9596. * edge artifacts on steep falloff.
  9597. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9598. */
  9599. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9600. /**
  9601. * Shadow generator mode PCF: Percentage Closer Filtering
  9602. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9603. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9604. */
  9605. static readonly FILTER_PCF: number;
  9606. /**
  9607. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9608. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9609. * Contact Hardening
  9610. */
  9611. static readonly FILTER_PCSS: number;
  9612. /**
  9613. * Reserved for PCF and PCSS
  9614. * Highest Quality.
  9615. *
  9616. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9617. *
  9618. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9619. */
  9620. static readonly QUALITY_HIGH: number;
  9621. /**
  9622. * Reserved for PCF and PCSS
  9623. * Good tradeoff for quality/perf cross devices
  9624. *
  9625. * Execute PCF on a 3*3 kernel.
  9626. *
  9627. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9628. */
  9629. static readonly QUALITY_MEDIUM: number;
  9630. /**
  9631. * Reserved for PCF and PCSS
  9632. * The lowest quality but the fastest.
  9633. *
  9634. * Execute PCF on a 1*1 kernel.
  9635. *
  9636. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9637. */
  9638. static readonly QUALITY_LOW: number;
  9639. /** Gets or sets the custom shader name to use */
  9640. customShaderOptions: ICustomShaderOptions;
  9641. /**
  9642. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9643. */
  9644. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9645. private _bias;
  9646. /**
  9647. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9648. */
  9649. /**
  9650. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9651. */
  9652. bias: number;
  9653. private _normalBias;
  9654. /**
  9655. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9656. */
  9657. /**
  9658. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9659. */
  9660. normalBias: number;
  9661. private _blurBoxOffset;
  9662. /**
  9663. * Gets the blur box offset: offset applied during the blur pass.
  9664. * Only useful if useKernelBlur = false
  9665. */
  9666. /**
  9667. * Sets the blur box offset: offset applied during the blur pass.
  9668. * Only useful if useKernelBlur = false
  9669. */
  9670. blurBoxOffset: number;
  9671. private _blurScale;
  9672. /**
  9673. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9674. * 2 means half of the size.
  9675. */
  9676. /**
  9677. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9678. * 2 means half of the size.
  9679. */
  9680. blurScale: number;
  9681. private _blurKernel;
  9682. /**
  9683. * Gets the blur kernel: kernel size of the blur pass.
  9684. * Only useful if useKernelBlur = true
  9685. */
  9686. /**
  9687. * Sets the blur kernel: kernel size of the blur pass.
  9688. * Only useful if useKernelBlur = true
  9689. */
  9690. blurKernel: number;
  9691. private _useKernelBlur;
  9692. /**
  9693. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9694. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9695. */
  9696. /**
  9697. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9698. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9699. */
  9700. useKernelBlur: boolean;
  9701. private _depthScale;
  9702. /**
  9703. * Gets the depth scale used in ESM mode.
  9704. */
  9705. /**
  9706. * Sets the depth scale used in ESM mode.
  9707. * This can override the scale stored on the light.
  9708. */
  9709. depthScale: number;
  9710. private _filter;
  9711. /**
  9712. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9713. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9714. */
  9715. /**
  9716. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9717. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9718. */
  9719. filter: number;
  9720. /**
  9721. * Gets if the current filter is set to Poisson Sampling.
  9722. */
  9723. /**
  9724. * Sets the current filter to Poisson Sampling.
  9725. */
  9726. usePoissonSampling: boolean;
  9727. /**
  9728. * Gets if the current filter is set to ESM.
  9729. */
  9730. /**
  9731. * Sets the current filter is to ESM.
  9732. */
  9733. useExponentialShadowMap: boolean;
  9734. /**
  9735. * Gets if the current filter is set to filtered ESM.
  9736. */
  9737. /**
  9738. * Gets if the current filter is set to filtered ESM.
  9739. */
  9740. useBlurExponentialShadowMap: boolean;
  9741. /**
  9742. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9743. * exponential to prevent steep falloff artifacts).
  9744. */
  9745. /**
  9746. * Sets the current filter to "close ESM" (using the inverse of the
  9747. * exponential to prevent steep falloff artifacts).
  9748. */
  9749. useCloseExponentialShadowMap: boolean;
  9750. /**
  9751. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9752. * exponential to prevent steep falloff artifacts).
  9753. */
  9754. /**
  9755. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9756. * exponential to prevent steep falloff artifacts).
  9757. */
  9758. useBlurCloseExponentialShadowMap: boolean;
  9759. /**
  9760. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9761. */
  9762. /**
  9763. * Sets the current filter to "PCF" (percentage closer filtering).
  9764. */
  9765. usePercentageCloserFiltering: boolean;
  9766. private _filteringQuality;
  9767. /**
  9768. * Gets the PCF or PCSS Quality.
  9769. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9770. */
  9771. /**
  9772. * Sets the PCF or PCSS Quality.
  9773. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9774. */
  9775. filteringQuality: number;
  9776. /**
  9777. * Gets if the current filter is set to "PCSS" (contact hardening).
  9778. */
  9779. /**
  9780. * Sets the current filter to "PCSS" (contact hardening).
  9781. */
  9782. useContactHardeningShadow: boolean;
  9783. private _contactHardeningLightSizeUVRatio;
  9784. /**
  9785. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9786. * Using a ratio helps keeping shape stability independently of the map size.
  9787. *
  9788. * It does not account for the light projection as it was having too much
  9789. * instability during the light setup or during light position changes.
  9790. *
  9791. * Only valid if useContactHardeningShadow is true.
  9792. */
  9793. /**
  9794. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9795. * Using a ratio helps keeping shape stability independently of the map size.
  9796. *
  9797. * It does not account for the light projection as it was having too much
  9798. * instability during the light setup or during light position changes.
  9799. *
  9800. * Only valid if useContactHardeningShadow is true.
  9801. */
  9802. contactHardeningLightSizeUVRatio: number;
  9803. private _darkness;
  9804. /**
  9805. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9806. * 0 means strongest and 1 would means no shadow.
  9807. * @returns the darkness.
  9808. */
  9809. getDarkness(): number;
  9810. /**
  9811. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9812. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9813. * @returns the shadow generator allowing fluent coding.
  9814. */
  9815. setDarkness(darkness: number): ShadowGenerator;
  9816. private _transparencyShadow;
  9817. /**
  9818. * Sets the ability to have transparent shadow (boolean).
  9819. * @param transparent True if transparent else False
  9820. * @returns the shadow generator allowing fluent coding
  9821. */
  9822. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9823. private _shadowMap;
  9824. private _shadowMap2;
  9825. /**
  9826. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9827. * @returns The render target texture if present otherwise, null
  9828. */
  9829. getShadowMap(): Nullable<RenderTargetTexture>;
  9830. /**
  9831. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9832. * @returns The render target texture if the shadow map is present otherwise, null
  9833. */
  9834. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9835. /**
  9836. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9837. * @param mesh Mesh to add
  9838. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9839. * @returns the Shadow Generator itself
  9840. */
  9841. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9842. /**
  9843. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9844. * @param mesh Mesh to remove
  9845. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9846. * @returns the Shadow Generator itself
  9847. */
  9848. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9849. /**
  9850. * Controls the extent to which the shadows fade out at the edge of the frustum
  9851. * Used only by directionals and spots
  9852. */
  9853. frustumEdgeFalloff: number;
  9854. private _light;
  9855. /**
  9856. * Returns the associated light object.
  9857. * @returns the light generating the shadow
  9858. */
  9859. getLight(): IShadowLight;
  9860. /**
  9861. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9862. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9863. * It might on the other hand introduce peter panning.
  9864. */
  9865. forceBackFacesOnly: boolean;
  9866. private _scene;
  9867. private _lightDirection;
  9868. private _effect;
  9869. private _viewMatrix;
  9870. private _projectionMatrix;
  9871. private _transformMatrix;
  9872. private _cachedPosition;
  9873. private _cachedDirection;
  9874. private _cachedDefines;
  9875. private _currentRenderID;
  9876. private _boxBlurPostprocess;
  9877. private _kernelBlurXPostprocess;
  9878. private _kernelBlurYPostprocess;
  9879. private _blurPostProcesses;
  9880. private _mapSize;
  9881. private _currentFaceIndex;
  9882. private _currentFaceIndexCache;
  9883. private _textureType;
  9884. private _defaultTextureMatrix;
  9885. /** @hidden */
  9886. static _SceneComponentInitialization: (scene: Scene) => void;
  9887. /**
  9888. * Creates a ShadowGenerator object.
  9889. * A ShadowGenerator is the required tool to use the shadows.
  9890. * Each light casting shadows needs to use its own ShadowGenerator.
  9891. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9892. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9893. * @param light The light object generating the shadows.
  9894. * @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.
  9895. */
  9896. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9897. private _initializeGenerator;
  9898. private _initializeShadowMap;
  9899. private _initializeBlurRTTAndPostProcesses;
  9900. private _renderForShadowMap;
  9901. private _renderSubMeshForShadowMap;
  9902. private _applyFilterValues;
  9903. /**
  9904. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9905. * @param onCompiled Callback triggered at the and of the effects compilation
  9906. * @param options Sets of optional options forcing the compilation with different modes
  9907. */
  9908. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9909. useInstances: boolean;
  9910. }>): void;
  9911. /**
  9912. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9913. * @param options Sets of optional options forcing the compilation with different modes
  9914. * @returns A promise that resolves when the compilation completes
  9915. */
  9916. forceCompilationAsync(options?: Partial<{
  9917. useInstances: boolean;
  9918. }>): Promise<void>;
  9919. /**
  9920. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9921. * @param subMesh The submesh we want to render in the shadow map
  9922. * @param useInstances Defines wether will draw in the map using instances
  9923. * @returns true if ready otherwise, false
  9924. */
  9925. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9926. /**
  9927. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9928. * @param defines Defines of the material we want to update
  9929. * @param lightIndex Index of the light in the enabled light list of the material
  9930. */
  9931. prepareDefines(defines: any, lightIndex: number): void;
  9932. /**
  9933. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9934. * defined in the generator but impacting the effect).
  9935. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9936. * @param effect The effect we are binfing the information for
  9937. */
  9938. bindShadowLight(lightIndex: string, effect: Effect): void;
  9939. /**
  9940. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9941. * (eq to shadow prjection matrix * light transform matrix)
  9942. * @returns The transform matrix used to create the shadow map
  9943. */
  9944. getTransformMatrix(): Matrix;
  9945. /**
  9946. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9947. * Cube and 2D textures for instance.
  9948. */
  9949. recreateShadowMap(): void;
  9950. private _disposeBlurPostProcesses;
  9951. private _disposeRTTandPostProcesses;
  9952. /**
  9953. * Disposes the ShadowGenerator.
  9954. * Returns nothing.
  9955. */
  9956. dispose(): void;
  9957. /**
  9958. * Serializes the shadow generator setup to a json object.
  9959. * @returns The serialized JSON object
  9960. */
  9961. serialize(): any;
  9962. /**
  9963. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9964. * @param parsedShadowGenerator The JSON object to parse
  9965. * @param scene The scene to create the shadow map for
  9966. * @returns The parsed shadow generator
  9967. */
  9968. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9969. }
  9970. }
  9971. declare module "babylonjs/Lights/light" {
  9972. import { Nullable } from "babylonjs/types";
  9973. import { Scene } from "babylonjs/scene";
  9974. import { Vector3, Color3 } from "babylonjs/Maths/math";
  9975. import { Node } from "babylonjs/node";
  9976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9977. import { Effect } from "babylonjs/Materials/effect";
  9978. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9979. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9980. /**
  9981. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9982. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9983. * 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.
  9984. */
  9985. export abstract class Light extends Node {
  9986. /**
  9987. * Falloff Default: light is falling off following the material specification:
  9988. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9989. */
  9990. static readonly FALLOFF_DEFAULT: number;
  9991. /**
  9992. * Falloff Physical: light is falling off following the inverse squared distance law.
  9993. */
  9994. static readonly FALLOFF_PHYSICAL: number;
  9995. /**
  9996. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9997. * to enhance interoperability with other engines.
  9998. */
  9999. static readonly FALLOFF_GLTF: number;
  10000. /**
  10001. * Falloff Standard: light is falling off like in the standard material
  10002. * to enhance interoperability with other materials.
  10003. */
  10004. static readonly FALLOFF_STANDARD: number;
  10005. /**
  10006. * If every light affecting the material is in this lightmapMode,
  10007. * material.lightmapTexture adds or multiplies
  10008. * (depends on material.useLightmapAsShadowmap)
  10009. * after every other light calculations.
  10010. */
  10011. static readonly LIGHTMAP_DEFAULT: number;
  10012. /**
  10013. * material.lightmapTexture as only diffuse lighting from this light
  10014. * adds only specular lighting from this light
  10015. * adds dynamic shadows
  10016. */
  10017. static readonly LIGHTMAP_SPECULAR: number;
  10018. /**
  10019. * material.lightmapTexture as only lighting
  10020. * no light calculation from this light
  10021. * only adds dynamic shadows from this light
  10022. */
  10023. static readonly LIGHTMAP_SHADOWSONLY: number;
  10024. /**
  10025. * Each light type uses the default quantity according to its type:
  10026. * point/spot lights use luminous intensity
  10027. * directional lights use illuminance
  10028. */
  10029. static readonly INTENSITYMODE_AUTOMATIC: number;
  10030. /**
  10031. * lumen (lm)
  10032. */
  10033. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10034. /**
  10035. * candela (lm/sr)
  10036. */
  10037. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10038. /**
  10039. * lux (lm/m^2)
  10040. */
  10041. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10042. /**
  10043. * nit (cd/m^2)
  10044. */
  10045. static readonly INTENSITYMODE_LUMINANCE: number;
  10046. /**
  10047. * Light type const id of the point light.
  10048. */
  10049. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10050. /**
  10051. * Light type const id of the directional light.
  10052. */
  10053. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10054. /**
  10055. * Light type const id of the spot light.
  10056. */
  10057. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10058. /**
  10059. * Light type const id of the hemispheric light.
  10060. */
  10061. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10062. /**
  10063. * Diffuse gives the basic color to an object.
  10064. */
  10065. diffuse: Color3;
  10066. /**
  10067. * Specular produces a highlight color on an object.
  10068. * Note: This is note affecting PBR materials.
  10069. */
  10070. specular: Color3;
  10071. /**
  10072. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10073. * falling off base on range or angle.
  10074. * This can be set to any values in Light.FALLOFF_x.
  10075. *
  10076. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10077. * other types of materials.
  10078. */
  10079. falloffType: number;
  10080. /**
  10081. * Strength of the light.
  10082. * Note: By default it is define in the framework own unit.
  10083. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10084. */
  10085. intensity: number;
  10086. private _range;
  10087. protected _inverseSquaredRange: number;
  10088. /**
  10089. * Defines how far from the source the light is impacting in scene units.
  10090. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10091. */
  10092. /**
  10093. * Defines how far from the source the light is impacting in scene units.
  10094. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10095. */
  10096. range: number;
  10097. /**
  10098. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10099. * of light.
  10100. */
  10101. private _photometricScale;
  10102. private _intensityMode;
  10103. /**
  10104. * Gets the photometric scale used to interpret the intensity.
  10105. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10106. */
  10107. /**
  10108. * Sets the photometric scale used to interpret the intensity.
  10109. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10110. */
  10111. intensityMode: number;
  10112. private _radius;
  10113. /**
  10114. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10115. */
  10116. /**
  10117. * sets the light radius used by PBR Materials to simulate soft area lights.
  10118. */
  10119. radius: number;
  10120. private _renderPriority;
  10121. /**
  10122. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10123. * exceeding the number allowed of the materials.
  10124. */
  10125. renderPriority: number;
  10126. private _shadowEnabled;
  10127. /**
  10128. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10129. * the current shadow generator.
  10130. */
  10131. /**
  10132. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10133. * the current shadow generator.
  10134. */
  10135. shadowEnabled: boolean;
  10136. private _includedOnlyMeshes;
  10137. /**
  10138. * Gets the only meshes impacted by this light.
  10139. */
  10140. /**
  10141. * Sets the only meshes impacted by this light.
  10142. */
  10143. includedOnlyMeshes: AbstractMesh[];
  10144. private _excludedMeshes;
  10145. /**
  10146. * Gets the meshes not impacted by this light.
  10147. */
  10148. /**
  10149. * Sets the meshes not impacted by this light.
  10150. */
  10151. excludedMeshes: AbstractMesh[];
  10152. private _excludeWithLayerMask;
  10153. /**
  10154. * Gets the layer id use to find what meshes are not impacted by the light.
  10155. * Inactive if 0
  10156. */
  10157. /**
  10158. * Sets the layer id use to find what meshes are not impacted by the light.
  10159. * Inactive if 0
  10160. */
  10161. excludeWithLayerMask: number;
  10162. private _includeOnlyWithLayerMask;
  10163. /**
  10164. * Gets the layer id use to find what meshes are impacted by the light.
  10165. * Inactive if 0
  10166. */
  10167. /**
  10168. * Sets the layer id use to find what meshes are impacted by the light.
  10169. * Inactive if 0
  10170. */
  10171. includeOnlyWithLayerMask: number;
  10172. private _lightmapMode;
  10173. /**
  10174. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10175. */
  10176. /**
  10177. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10178. */
  10179. lightmapMode: number;
  10180. /**
  10181. * Shadow generator associted to the light.
  10182. * @hidden Internal use only.
  10183. */
  10184. _shadowGenerator: Nullable<IShadowGenerator>;
  10185. /**
  10186. * @hidden Internal use only.
  10187. */
  10188. _excludedMeshesIds: string[];
  10189. /**
  10190. * @hidden Internal use only.
  10191. */
  10192. _includedOnlyMeshesIds: string[];
  10193. /**
  10194. * The current light unifom buffer.
  10195. * @hidden Internal use only.
  10196. */
  10197. _uniformBuffer: UniformBuffer;
  10198. /**
  10199. * Creates a Light object in the scene.
  10200. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10201. * @param name The firendly name of the light
  10202. * @param scene The scene the light belongs too
  10203. */
  10204. constructor(name: string, scene: Scene);
  10205. protected abstract _buildUniformLayout(): void;
  10206. /**
  10207. * Sets the passed Effect "effect" with the Light information.
  10208. * @param effect The effect to update
  10209. * @param lightIndex The index of the light in the effect to update
  10210. * @returns The light
  10211. */
  10212. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10213. /**
  10214. * Returns the string "Light".
  10215. * @returns the class name
  10216. */
  10217. getClassName(): string;
  10218. /** @hidden */
  10219. readonly _isLight: boolean;
  10220. /**
  10221. * Converts the light information to a readable string for debug purpose.
  10222. * @param fullDetails Supports for multiple levels of logging within scene loading
  10223. * @returns the human readable light info
  10224. */
  10225. toString(fullDetails?: boolean): string;
  10226. /** @hidden */
  10227. protected _syncParentEnabledState(): void;
  10228. /**
  10229. * Set the enabled state of this node.
  10230. * @param value - the new enabled state
  10231. */
  10232. setEnabled(value: boolean): void;
  10233. /**
  10234. * Returns the Light associated shadow generator if any.
  10235. * @return the associated shadow generator.
  10236. */
  10237. getShadowGenerator(): Nullable<IShadowGenerator>;
  10238. /**
  10239. * Returns a Vector3, the absolute light position in the World.
  10240. * @returns the world space position of the light
  10241. */
  10242. getAbsolutePosition(): Vector3;
  10243. /**
  10244. * Specifies if the light will affect the passed mesh.
  10245. * @param mesh The mesh to test against the light
  10246. * @return true the mesh is affected otherwise, false.
  10247. */
  10248. canAffectMesh(mesh: AbstractMesh): boolean;
  10249. /**
  10250. * Sort function to order lights for rendering.
  10251. * @param a First Light object to compare to second.
  10252. * @param b Second Light object to compare first.
  10253. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10254. */
  10255. static CompareLightsPriority(a: Light, b: Light): number;
  10256. /**
  10257. * Releases resources associated with this node.
  10258. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10259. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10260. */
  10261. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10262. /**
  10263. * Returns the light type ID (integer).
  10264. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10265. */
  10266. getTypeID(): number;
  10267. /**
  10268. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10269. * @returns the scaled intensity in intensity mode unit
  10270. */
  10271. getScaledIntensity(): number;
  10272. /**
  10273. * Returns a new Light object, named "name", from the current one.
  10274. * @param name The name of the cloned light
  10275. * @returns the new created light
  10276. */
  10277. clone(name: string): Nullable<Light>;
  10278. /**
  10279. * Serializes the current light into a Serialization object.
  10280. * @returns the serialized object.
  10281. */
  10282. serialize(): any;
  10283. /**
  10284. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10285. * This new light is named "name" and added to the passed scene.
  10286. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10287. * @param name The friendly name of the light
  10288. * @param scene The scene the new light will belong to
  10289. * @returns the constructor function
  10290. */
  10291. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10292. /**
  10293. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10294. * @param parsedLight The JSON representation of the light
  10295. * @param scene The scene to create the parsed light in
  10296. * @returns the created light after parsing
  10297. */
  10298. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10299. private _hookArrayForExcluded;
  10300. private _hookArrayForIncludedOnly;
  10301. private _resyncMeshes;
  10302. /**
  10303. * Forces the meshes to update their light related information in their rendering used effects
  10304. * @hidden Internal Use Only
  10305. */
  10306. _markMeshesAsLightDirty(): void;
  10307. /**
  10308. * Recomputes the cached photometric scale if needed.
  10309. */
  10310. private _computePhotometricScale;
  10311. /**
  10312. * Returns the Photometric Scale according to the light type and intensity mode.
  10313. */
  10314. private _getPhotometricScale;
  10315. /**
  10316. * Reorder the light in the scene according to their defined priority.
  10317. * @hidden Internal Use Only
  10318. */
  10319. _reorderLightsInScene(): void;
  10320. /**
  10321. * Prepares the list of defines specific to the light type.
  10322. * @param defines the list of defines
  10323. * @param lightIndex defines the index of the light for the effect
  10324. */
  10325. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10326. }
  10327. }
  10328. declare module "babylonjs/Actions/action" {
  10329. import { Observable } from "babylonjs/Misc/observable";
  10330. import { Condition } from "babylonjs/Actions/condition";
  10331. import { ActionManager } from "babylonjs/Actions/actionManager";
  10332. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10333. /**
  10334. * Interface used to define Action
  10335. */
  10336. export interface IAction {
  10337. /**
  10338. * Trigger for the action
  10339. */
  10340. trigger: number;
  10341. /** Options of the trigger */
  10342. triggerOptions: any;
  10343. /**
  10344. * Gets the trigger parameters
  10345. * @returns the trigger parameters
  10346. */
  10347. getTriggerParameter(): any;
  10348. /**
  10349. * Internal only - executes current action event
  10350. * @hidden
  10351. */
  10352. _executeCurrent(evt?: ActionEvent): void;
  10353. /**
  10354. * Serialize placeholder for child classes
  10355. * @param parent of child
  10356. * @returns the serialized object
  10357. */
  10358. serialize(parent: any): any;
  10359. }
  10360. /**
  10361. * The action to be carried out following a trigger
  10362. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10363. */
  10364. export class Action implements IAction {
  10365. /** the trigger, with or without parameters, for the action */
  10366. triggerOptions: any;
  10367. /**
  10368. * Trigger for the action
  10369. */
  10370. trigger: number;
  10371. /**
  10372. * Internal only - manager for action
  10373. * @hidden
  10374. */
  10375. _actionManager: ActionManager;
  10376. private _nextActiveAction;
  10377. private _child;
  10378. private _condition?;
  10379. private _triggerParameter;
  10380. /**
  10381. * An event triggered prior to action being executed.
  10382. */
  10383. onBeforeExecuteObservable: Observable<Action>;
  10384. /**
  10385. * Creates a new Action
  10386. * @param triggerOptions the trigger, with or without parameters, for the action
  10387. * @param condition an optional determinant of action
  10388. */
  10389. constructor(
  10390. /** the trigger, with or without parameters, for the action */
  10391. triggerOptions: any, condition?: Condition);
  10392. /**
  10393. * Internal only
  10394. * @hidden
  10395. */
  10396. _prepare(): void;
  10397. /**
  10398. * Gets the trigger parameters
  10399. * @returns the trigger parameters
  10400. */
  10401. getTriggerParameter(): any;
  10402. /**
  10403. * Internal only - executes current action event
  10404. * @hidden
  10405. */
  10406. _executeCurrent(evt?: ActionEvent): void;
  10407. /**
  10408. * Execute placeholder for child classes
  10409. * @param evt optional action event
  10410. */
  10411. execute(evt?: ActionEvent): void;
  10412. /**
  10413. * Skips to next active action
  10414. */
  10415. skipToNextActiveAction(): void;
  10416. /**
  10417. * Adds action to chain of actions, may be a DoNothingAction
  10418. * @param action defines the next action to execute
  10419. * @returns The action passed in
  10420. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10421. */
  10422. then(action: Action): Action;
  10423. /**
  10424. * Internal only
  10425. * @hidden
  10426. */
  10427. _getProperty(propertyPath: string): string;
  10428. /**
  10429. * Internal only
  10430. * @hidden
  10431. */
  10432. _getEffectiveTarget(target: any, propertyPath: string): any;
  10433. /**
  10434. * Serialize placeholder for child classes
  10435. * @param parent of child
  10436. * @returns the serialized object
  10437. */
  10438. serialize(parent: any): any;
  10439. /**
  10440. * Internal only called by serialize
  10441. * @hidden
  10442. */
  10443. protected _serialize(serializedAction: any, parent?: any): any;
  10444. /**
  10445. * Internal only
  10446. * @hidden
  10447. */
  10448. static _SerializeValueAsString: (value: any) => string;
  10449. /**
  10450. * Internal only
  10451. * @hidden
  10452. */
  10453. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  10454. name: string;
  10455. targetType: string;
  10456. value: string;
  10457. };
  10458. }
  10459. }
  10460. declare module "babylonjs/Actions/condition" {
  10461. import { ActionManager } from "babylonjs/Actions/actionManager";
  10462. /**
  10463. * A Condition applied to an Action
  10464. */
  10465. export class Condition {
  10466. /**
  10467. * Internal only - manager for action
  10468. * @hidden
  10469. */
  10470. _actionManager: ActionManager;
  10471. /**
  10472. * Internal only
  10473. * @hidden
  10474. */
  10475. _evaluationId: number;
  10476. /**
  10477. * Internal only
  10478. * @hidden
  10479. */
  10480. _currentResult: boolean;
  10481. /**
  10482. * Creates a new Condition
  10483. * @param actionManager the manager of the action the condition is applied to
  10484. */
  10485. constructor(actionManager: ActionManager);
  10486. /**
  10487. * Check if the current condition is valid
  10488. * @returns a boolean
  10489. */
  10490. isValid(): boolean;
  10491. /**
  10492. * Internal only
  10493. * @hidden
  10494. */
  10495. _getProperty(propertyPath: string): string;
  10496. /**
  10497. * Internal only
  10498. * @hidden
  10499. */
  10500. _getEffectiveTarget(target: any, propertyPath: string): any;
  10501. /**
  10502. * Serialize placeholder for child classes
  10503. * @returns the serialized object
  10504. */
  10505. serialize(): any;
  10506. /**
  10507. * Internal only
  10508. * @hidden
  10509. */
  10510. protected _serialize(serializedCondition: any): any;
  10511. }
  10512. /**
  10513. * Defines specific conditional operators as extensions of Condition
  10514. */
  10515. export class ValueCondition extends Condition {
  10516. /** path to specify the property of the target the conditional operator uses */
  10517. propertyPath: string;
  10518. /** the value compared by the conditional operator against the current value of the property */
  10519. value: any;
  10520. /** the conditional operator, default ValueCondition.IsEqual */
  10521. operator: number;
  10522. /**
  10523. * Internal only
  10524. * @hidden
  10525. */
  10526. private static _IsEqual;
  10527. /**
  10528. * Internal only
  10529. * @hidden
  10530. */
  10531. private static _IsDifferent;
  10532. /**
  10533. * Internal only
  10534. * @hidden
  10535. */
  10536. private static _IsGreater;
  10537. /**
  10538. * Internal only
  10539. * @hidden
  10540. */
  10541. private static _IsLesser;
  10542. /**
  10543. * returns the number for IsEqual
  10544. */
  10545. static readonly IsEqual: number;
  10546. /**
  10547. * Returns the number for IsDifferent
  10548. */
  10549. static readonly IsDifferent: number;
  10550. /**
  10551. * Returns the number for IsGreater
  10552. */
  10553. static readonly IsGreater: number;
  10554. /**
  10555. * Returns the number for IsLesser
  10556. */
  10557. static readonly IsLesser: number;
  10558. /**
  10559. * Internal only The action manager for the condition
  10560. * @hidden
  10561. */
  10562. _actionManager: ActionManager;
  10563. /**
  10564. * Internal only
  10565. * @hidden
  10566. */
  10567. private _target;
  10568. /**
  10569. * Internal only
  10570. * @hidden
  10571. */
  10572. private _effectiveTarget;
  10573. /**
  10574. * Internal only
  10575. * @hidden
  10576. */
  10577. private _property;
  10578. /**
  10579. * Creates a new ValueCondition
  10580. * @param actionManager manager for the action the condition applies to
  10581. * @param target for the action
  10582. * @param propertyPath path to specify the property of the target the conditional operator uses
  10583. * @param value the value compared by the conditional operator against the current value of the property
  10584. * @param operator the conditional operator, default ValueCondition.IsEqual
  10585. */
  10586. constructor(actionManager: ActionManager, target: any,
  10587. /** path to specify the property of the target the conditional operator uses */
  10588. propertyPath: string,
  10589. /** the value compared by the conditional operator against the current value of the property */
  10590. value: any,
  10591. /** the conditional operator, default ValueCondition.IsEqual */
  10592. operator?: number);
  10593. /**
  10594. * Compares the given value with the property value for the specified conditional operator
  10595. * @returns the result of the comparison
  10596. */
  10597. isValid(): boolean;
  10598. /**
  10599. * Serialize the ValueCondition into a JSON compatible object
  10600. * @returns serialization object
  10601. */
  10602. serialize(): any;
  10603. /**
  10604. * Gets the name of the conditional operator for the ValueCondition
  10605. * @param operator the conditional operator
  10606. * @returns the name
  10607. */
  10608. static GetOperatorName(operator: number): string;
  10609. }
  10610. /**
  10611. * Defines a predicate condition as an extension of Condition
  10612. */
  10613. export class PredicateCondition extends Condition {
  10614. /** defines the predicate function used to validate the condition */
  10615. predicate: () => boolean;
  10616. /**
  10617. * Internal only - manager for action
  10618. * @hidden
  10619. */
  10620. _actionManager: ActionManager;
  10621. /**
  10622. * Creates a new PredicateCondition
  10623. * @param actionManager manager for the action the condition applies to
  10624. * @param predicate defines the predicate function used to validate the condition
  10625. */
  10626. constructor(actionManager: ActionManager,
  10627. /** defines the predicate function used to validate the condition */
  10628. predicate: () => boolean);
  10629. /**
  10630. * @returns the validity of the predicate condition
  10631. */
  10632. isValid(): boolean;
  10633. }
  10634. /**
  10635. * Defines a state condition as an extension of Condition
  10636. */
  10637. export class StateCondition extends Condition {
  10638. /** Value to compare with target state */
  10639. value: string;
  10640. /**
  10641. * Internal only - manager for action
  10642. * @hidden
  10643. */
  10644. _actionManager: ActionManager;
  10645. /**
  10646. * Internal only
  10647. * @hidden
  10648. */
  10649. private _target;
  10650. /**
  10651. * Creates a new StateCondition
  10652. * @param actionManager manager for the action the condition applies to
  10653. * @param target of the condition
  10654. * @param value to compare with target state
  10655. */
  10656. constructor(actionManager: ActionManager, target: any,
  10657. /** Value to compare with target state */
  10658. value: string);
  10659. /**
  10660. * Gets a boolean indicating if the current condition is met
  10661. * @returns the validity of the state
  10662. */
  10663. isValid(): boolean;
  10664. /**
  10665. * Serialize the StateCondition into a JSON compatible object
  10666. * @returns serialization object
  10667. */
  10668. serialize(): any;
  10669. }
  10670. }
  10671. declare module "babylonjs/Actions/directActions" {
  10672. import { Action } from "babylonjs/Actions/action";
  10673. import { Condition } from "babylonjs/Actions/condition";
  10674. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10675. /**
  10676. * This defines an action responsible to toggle a boolean once triggered.
  10677. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10678. */
  10679. export class SwitchBooleanAction extends Action {
  10680. /**
  10681. * The path to the boolean property in the target object
  10682. */
  10683. propertyPath: string;
  10684. private _target;
  10685. private _effectiveTarget;
  10686. private _property;
  10687. /**
  10688. * Instantiate the action
  10689. * @param triggerOptions defines the trigger options
  10690. * @param target defines the object containing the boolean
  10691. * @param propertyPath defines the path to the boolean property in the target object
  10692. * @param condition defines the trigger related conditions
  10693. */
  10694. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10695. /** @hidden */
  10696. _prepare(): void;
  10697. /**
  10698. * Execute the action toggle the boolean value.
  10699. */
  10700. execute(): void;
  10701. /**
  10702. * Serializes the actions and its related information.
  10703. * @param parent defines the object to serialize in
  10704. * @returns the serialized object
  10705. */
  10706. serialize(parent: any): any;
  10707. }
  10708. /**
  10709. * This defines an action responsible to set a the state field of the target
  10710. * to a desired value once triggered.
  10711. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10712. */
  10713. export class SetStateAction extends Action {
  10714. /**
  10715. * The value to store in the state field.
  10716. */
  10717. value: string;
  10718. private _target;
  10719. /**
  10720. * Instantiate the action
  10721. * @param triggerOptions defines the trigger options
  10722. * @param target defines the object containing the state property
  10723. * @param value defines the value to store in the state field
  10724. * @param condition defines the trigger related conditions
  10725. */
  10726. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10727. /**
  10728. * Execute the action and store the value on the target state property.
  10729. */
  10730. execute(): void;
  10731. /**
  10732. * Serializes the actions and its related information.
  10733. * @param parent defines the object to serialize in
  10734. * @returns the serialized object
  10735. */
  10736. serialize(parent: any): any;
  10737. }
  10738. /**
  10739. * This defines an action responsible to set a property of the target
  10740. * to a desired value once triggered.
  10741. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10742. */
  10743. export class SetValueAction extends Action {
  10744. /**
  10745. * The path of the property to set in the target.
  10746. */
  10747. propertyPath: string;
  10748. /**
  10749. * The value to set in the property
  10750. */
  10751. value: any;
  10752. private _target;
  10753. private _effectiveTarget;
  10754. private _property;
  10755. /**
  10756. * Instantiate the action
  10757. * @param triggerOptions defines the trigger options
  10758. * @param target defines the object containing the property
  10759. * @param propertyPath defines the path of the property to set in the target
  10760. * @param value defines the value to set in the property
  10761. * @param condition defines the trigger related conditions
  10762. */
  10763. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10764. /** @hidden */
  10765. _prepare(): void;
  10766. /**
  10767. * Execute the action and set the targetted property to the desired value.
  10768. */
  10769. execute(): void;
  10770. /**
  10771. * Serializes the actions and its related information.
  10772. * @param parent defines the object to serialize in
  10773. * @returns the serialized object
  10774. */
  10775. serialize(parent: any): any;
  10776. }
  10777. /**
  10778. * This defines an action responsible to increment the target value
  10779. * to a desired value once triggered.
  10780. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10781. */
  10782. export class IncrementValueAction extends Action {
  10783. /**
  10784. * The path of the property to increment in the target.
  10785. */
  10786. propertyPath: string;
  10787. /**
  10788. * The value we should increment the property by.
  10789. */
  10790. value: any;
  10791. private _target;
  10792. private _effectiveTarget;
  10793. private _property;
  10794. /**
  10795. * Instantiate the action
  10796. * @param triggerOptions defines the trigger options
  10797. * @param target defines the object containing the property
  10798. * @param propertyPath defines the path of the property to increment in the target
  10799. * @param value defines the value value we should increment the property by
  10800. * @param condition defines the trigger related conditions
  10801. */
  10802. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10803. /** @hidden */
  10804. _prepare(): void;
  10805. /**
  10806. * Execute the action and increment the target of the value amount.
  10807. */
  10808. execute(): void;
  10809. /**
  10810. * Serializes the actions and its related information.
  10811. * @param parent defines the object to serialize in
  10812. * @returns the serialized object
  10813. */
  10814. serialize(parent: any): any;
  10815. }
  10816. /**
  10817. * This defines an action responsible to start an animation once triggered.
  10818. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10819. */
  10820. export class PlayAnimationAction extends Action {
  10821. /**
  10822. * Where the animation should start (animation frame)
  10823. */
  10824. from: number;
  10825. /**
  10826. * Where the animation should stop (animation frame)
  10827. */
  10828. to: number;
  10829. /**
  10830. * Define if the animation should loop or stop after the first play.
  10831. */
  10832. loop?: boolean;
  10833. private _target;
  10834. /**
  10835. * Instantiate the action
  10836. * @param triggerOptions defines the trigger options
  10837. * @param target defines the target animation or animation name
  10838. * @param from defines from where the animation should start (animation frame)
  10839. * @param end defines where the animation should stop (animation frame)
  10840. * @param loop defines if the animation should loop or stop after the first play
  10841. * @param condition defines the trigger related conditions
  10842. */
  10843. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10844. /** @hidden */
  10845. _prepare(): void;
  10846. /**
  10847. * Execute the action and play the animation.
  10848. */
  10849. execute(): void;
  10850. /**
  10851. * Serializes the actions and its related information.
  10852. * @param parent defines the object to serialize in
  10853. * @returns the serialized object
  10854. */
  10855. serialize(parent: any): any;
  10856. }
  10857. /**
  10858. * This defines an action responsible to stop an animation once triggered.
  10859. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10860. */
  10861. export class StopAnimationAction extends Action {
  10862. private _target;
  10863. /**
  10864. * Instantiate the action
  10865. * @param triggerOptions defines the trigger options
  10866. * @param target defines the target animation or animation name
  10867. * @param condition defines the trigger related conditions
  10868. */
  10869. constructor(triggerOptions: any, target: any, condition?: Condition);
  10870. /** @hidden */
  10871. _prepare(): void;
  10872. /**
  10873. * Execute the action and stop the animation.
  10874. */
  10875. execute(): void;
  10876. /**
  10877. * Serializes the actions and its related information.
  10878. * @param parent defines the object to serialize in
  10879. * @returns the serialized object
  10880. */
  10881. serialize(parent: any): any;
  10882. }
  10883. /**
  10884. * This defines an action responsible that does nothing once triggered.
  10885. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10886. */
  10887. export class DoNothingAction extends Action {
  10888. /**
  10889. * Instantiate the action
  10890. * @param triggerOptions defines the trigger options
  10891. * @param condition defines the trigger related conditions
  10892. */
  10893. constructor(triggerOptions?: any, condition?: Condition);
  10894. /**
  10895. * Execute the action and do nothing.
  10896. */
  10897. execute(): void;
  10898. /**
  10899. * Serializes the actions and its related information.
  10900. * @param parent defines the object to serialize in
  10901. * @returns the serialized object
  10902. */
  10903. serialize(parent: any): any;
  10904. }
  10905. /**
  10906. * This defines an action responsible to trigger several actions once triggered.
  10907. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10908. */
  10909. export class CombineAction extends Action {
  10910. /**
  10911. * The list of aggregated animations to run.
  10912. */
  10913. children: Action[];
  10914. /**
  10915. * Instantiate the action
  10916. * @param triggerOptions defines the trigger options
  10917. * @param children defines the list of aggregated animations to run
  10918. * @param condition defines the trigger related conditions
  10919. */
  10920. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10921. /** @hidden */
  10922. _prepare(): void;
  10923. /**
  10924. * Execute the action and executes all the aggregated actions.
  10925. */
  10926. execute(evt: ActionEvent): void;
  10927. /**
  10928. * Serializes the actions and its related information.
  10929. * @param parent defines the object to serialize in
  10930. * @returns the serialized object
  10931. */
  10932. serialize(parent: any): any;
  10933. }
  10934. /**
  10935. * This defines an action responsible to run code (external event) once triggered.
  10936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10937. */
  10938. export class ExecuteCodeAction extends Action {
  10939. /**
  10940. * The callback function to run.
  10941. */
  10942. func: (evt: ActionEvent) => void;
  10943. /**
  10944. * Instantiate the action
  10945. * @param triggerOptions defines the trigger options
  10946. * @param func defines the callback function to run
  10947. * @param condition defines the trigger related conditions
  10948. */
  10949. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10950. /**
  10951. * Execute the action and run the attached code.
  10952. */
  10953. execute(evt: ActionEvent): void;
  10954. }
  10955. /**
  10956. * This defines an action responsible to set the parent property of the target once triggered.
  10957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10958. */
  10959. export class SetParentAction extends Action {
  10960. private _parent;
  10961. private _target;
  10962. /**
  10963. * Instantiate the action
  10964. * @param triggerOptions defines the trigger options
  10965. * @param target defines the target containing the parent property
  10966. * @param parent defines from where the animation should start (animation frame)
  10967. * @param condition defines the trigger related conditions
  10968. */
  10969. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10970. /** @hidden */
  10971. _prepare(): void;
  10972. /**
  10973. * Execute the action and set the parent property.
  10974. */
  10975. execute(): void;
  10976. /**
  10977. * Serializes the actions and its related information.
  10978. * @param parent defines the object to serialize in
  10979. * @returns the serialized object
  10980. */
  10981. serialize(parent: any): any;
  10982. }
  10983. }
  10984. declare module "babylonjs/Actions/actionManager" {
  10985. import { Nullable } from "babylonjs/types";
  10986. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10987. import { Scene } from "babylonjs/scene";
  10988. import { Action } from "babylonjs/Actions/action";
  10989. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10990. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10991. /**
  10992. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10993. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10994. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10995. */
  10996. export class ActionManager extends AbstractActionManager {
  10997. /**
  10998. * Nothing
  10999. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11000. */
  11001. static readonly NothingTrigger: number;
  11002. /**
  11003. * On pick
  11004. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11005. */
  11006. static readonly OnPickTrigger: number;
  11007. /**
  11008. * On left pick
  11009. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11010. */
  11011. static readonly OnLeftPickTrigger: number;
  11012. /**
  11013. * On right pick
  11014. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11015. */
  11016. static readonly OnRightPickTrigger: number;
  11017. /**
  11018. * On center pick
  11019. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11020. */
  11021. static readonly OnCenterPickTrigger: number;
  11022. /**
  11023. * On pick down
  11024. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11025. */
  11026. static readonly OnPickDownTrigger: number;
  11027. /**
  11028. * On double pick
  11029. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11030. */
  11031. static readonly OnDoublePickTrigger: number;
  11032. /**
  11033. * On pick up
  11034. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11035. */
  11036. static readonly OnPickUpTrigger: number;
  11037. /**
  11038. * On pick out.
  11039. * This trigger will only be raised if you also declared a OnPickDown
  11040. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11041. */
  11042. static readonly OnPickOutTrigger: number;
  11043. /**
  11044. * On long press
  11045. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11046. */
  11047. static readonly OnLongPressTrigger: number;
  11048. /**
  11049. * On pointer over
  11050. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11051. */
  11052. static readonly OnPointerOverTrigger: number;
  11053. /**
  11054. * On pointer out
  11055. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11056. */
  11057. static readonly OnPointerOutTrigger: number;
  11058. /**
  11059. * On every frame
  11060. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11061. */
  11062. static readonly OnEveryFrameTrigger: number;
  11063. /**
  11064. * On intersection enter
  11065. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11066. */
  11067. static readonly OnIntersectionEnterTrigger: number;
  11068. /**
  11069. * On intersection exit
  11070. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11071. */
  11072. static readonly OnIntersectionExitTrigger: number;
  11073. /**
  11074. * On key down
  11075. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11076. */
  11077. static readonly OnKeyDownTrigger: number;
  11078. /**
  11079. * On key up
  11080. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11081. */
  11082. static readonly OnKeyUpTrigger: number;
  11083. private _scene;
  11084. /**
  11085. * Creates a new action manager
  11086. * @param scene defines the hosting scene
  11087. */
  11088. constructor(scene: Scene);
  11089. /**
  11090. * Releases all associated resources
  11091. */
  11092. dispose(): void;
  11093. /**
  11094. * Gets hosting scene
  11095. * @returns the hosting scene
  11096. */
  11097. getScene(): Scene;
  11098. /**
  11099. * Does this action manager handles actions of any of the given triggers
  11100. * @param triggers defines the triggers to be tested
  11101. * @return a boolean indicating whether one (or more) of the triggers is handled
  11102. */
  11103. hasSpecificTriggers(triggers: number[]): boolean;
  11104. /**
  11105. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11106. * speed.
  11107. * @param triggerA defines the trigger to be tested
  11108. * @param triggerB defines the trigger to be tested
  11109. * @return a boolean indicating whether one (or more) of the triggers is handled
  11110. */
  11111. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11112. /**
  11113. * Does this action manager handles actions of a given trigger
  11114. * @param trigger defines the trigger to be tested
  11115. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11116. * @return whether the trigger is handled
  11117. */
  11118. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11119. /**
  11120. * Does this action manager has pointer triggers
  11121. */
  11122. readonly hasPointerTriggers: boolean;
  11123. /**
  11124. * Does this action manager has pick triggers
  11125. */
  11126. readonly hasPickTriggers: boolean;
  11127. /**
  11128. * Registers an action to this action manager
  11129. * @param action defines the action to be registered
  11130. * @return the action amended (prepared) after registration
  11131. */
  11132. registerAction(action: Action): Nullable<Action>;
  11133. /**
  11134. * Unregisters an action to this action manager
  11135. * @param action defines the action to be unregistered
  11136. * @return a boolean indicating whether the action has been unregistered
  11137. */
  11138. unregisterAction(action: Action): Boolean;
  11139. /**
  11140. * Process a specific trigger
  11141. * @param trigger defines the trigger to process
  11142. * @param evt defines the event details to be processed
  11143. */
  11144. processTrigger(trigger: number, evt?: IActionEvent): void;
  11145. /** @hidden */
  11146. _getEffectiveTarget(target: any, propertyPath: string): any;
  11147. /** @hidden */
  11148. _getProperty(propertyPath: string): string;
  11149. /**
  11150. * Serialize this manager to a JSON object
  11151. * @param name defines the property name to store this manager
  11152. * @returns a JSON representation of this manager
  11153. */
  11154. serialize(name: string): any;
  11155. /**
  11156. * Creates a new ActionManager from a JSON data
  11157. * @param parsedActions defines the JSON data to read from
  11158. * @param object defines the hosting mesh
  11159. * @param scene defines the hosting scene
  11160. */
  11161. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11162. /**
  11163. * Get a trigger name by index
  11164. * @param trigger defines the trigger index
  11165. * @returns a trigger name
  11166. */
  11167. static GetTriggerName(trigger: number): string;
  11168. }
  11169. }
  11170. declare module "babylonjs/Culling/ray" {
  11171. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11172. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  11173. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11174. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11175. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11176. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11177. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11178. /**
  11179. * Class representing a ray with position and direction
  11180. */
  11181. export class Ray {
  11182. /** origin point */
  11183. origin: Vector3;
  11184. /** direction */
  11185. direction: Vector3;
  11186. /** length of the ray */
  11187. length: number;
  11188. private static readonly TmpVector3;
  11189. private _tmpRay;
  11190. /**
  11191. * Creates a new ray
  11192. * @param origin origin point
  11193. * @param direction direction
  11194. * @param length length of the ray
  11195. */
  11196. constructor(
  11197. /** origin point */
  11198. origin: Vector3,
  11199. /** direction */
  11200. direction: Vector3,
  11201. /** length of the ray */
  11202. length?: number);
  11203. /**
  11204. * Checks if the ray intersects a box
  11205. * @param minimum bound of the box
  11206. * @param maximum bound of the box
  11207. * @param intersectionTreshold extra extend to be added to the box in all direction
  11208. * @returns if the box was hit
  11209. */
  11210. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11211. /**
  11212. * Checks if the ray intersects a box
  11213. * @param box the bounding box to check
  11214. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11215. * @returns if the box was hit
  11216. */
  11217. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11218. /**
  11219. * If the ray hits a sphere
  11220. * @param sphere the bounding sphere to check
  11221. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11222. * @returns true if it hits the sphere
  11223. */
  11224. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11225. /**
  11226. * If the ray hits a triange
  11227. * @param vertex0 triangle vertex
  11228. * @param vertex1 triangle vertex
  11229. * @param vertex2 triangle vertex
  11230. * @returns intersection information if hit
  11231. */
  11232. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11233. /**
  11234. * Checks if ray intersects a plane
  11235. * @param plane the plane to check
  11236. * @returns the distance away it was hit
  11237. */
  11238. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11239. /**
  11240. * Checks if ray intersects a mesh
  11241. * @param mesh the mesh to check
  11242. * @param fastCheck if only the bounding box should checked
  11243. * @returns picking info of the intersecton
  11244. */
  11245. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11246. /**
  11247. * Checks if ray intersects a mesh
  11248. * @param meshes the meshes to check
  11249. * @param fastCheck if only the bounding box should checked
  11250. * @param results array to store result in
  11251. * @returns Array of picking infos
  11252. */
  11253. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11254. private _comparePickingInfo;
  11255. private static smallnum;
  11256. private static rayl;
  11257. /**
  11258. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11259. * @param sega the first point of the segment to test the intersection against
  11260. * @param segb the second point of the segment to test the intersection against
  11261. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11262. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11263. */
  11264. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11265. /**
  11266. * Update the ray from viewport position
  11267. * @param x position
  11268. * @param y y position
  11269. * @param viewportWidth viewport width
  11270. * @param viewportHeight viewport height
  11271. * @param world world matrix
  11272. * @param view view matrix
  11273. * @param projection projection matrix
  11274. * @returns this ray updated
  11275. */
  11276. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11277. /**
  11278. * Creates a ray with origin and direction of 0,0,0
  11279. * @returns the new ray
  11280. */
  11281. static Zero(): Ray;
  11282. /**
  11283. * Creates a new ray from screen space and viewport
  11284. * @param x position
  11285. * @param y y position
  11286. * @param viewportWidth viewport width
  11287. * @param viewportHeight viewport height
  11288. * @param world world matrix
  11289. * @param view view matrix
  11290. * @param projection projection matrix
  11291. * @returns new ray
  11292. */
  11293. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11294. /**
  11295. * 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
  11296. * transformed to the given world matrix.
  11297. * @param origin The origin point
  11298. * @param end The end point
  11299. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11300. * @returns the new ray
  11301. */
  11302. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11303. /**
  11304. * Transforms a ray by a matrix
  11305. * @param ray ray to transform
  11306. * @param matrix matrix to apply
  11307. * @returns the resulting new ray
  11308. */
  11309. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11310. /**
  11311. * Transforms a ray by a matrix
  11312. * @param ray ray to transform
  11313. * @param matrix matrix to apply
  11314. * @param result ray to store result in
  11315. */
  11316. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11317. /**
  11318. * Unproject a ray from screen space to object space
  11319. * @param sourceX defines the screen space x coordinate to use
  11320. * @param sourceY defines the screen space y coordinate to use
  11321. * @param viewportWidth defines the current width of the viewport
  11322. * @param viewportHeight defines the current height of the viewport
  11323. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11324. * @param view defines the view matrix to use
  11325. * @param projection defines the projection matrix to use
  11326. */
  11327. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11328. }
  11329. module "babylonjs/scene" {
  11330. interface Scene {
  11331. /** @hidden */
  11332. _tempPickingRay: Nullable<Ray>;
  11333. /** @hidden */
  11334. _cachedRayForTransform: Ray;
  11335. /** @hidden */
  11336. _pickWithRayInverseMatrix: Matrix;
  11337. /** @hidden */
  11338. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11339. /** @hidden */
  11340. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  11341. }
  11342. }
  11343. }
  11344. declare module "babylonjs/sceneComponent" {
  11345. import { Scene } from "babylonjs/scene";
  11346. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11347. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11348. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11349. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11350. import { Nullable } from "babylonjs/types";
  11351. import { Camera } from "babylonjs/Cameras/camera";
  11352. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11353. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11354. import { AbstractScene } from "babylonjs/abstractScene";
  11355. /**
  11356. * Groups all the scene component constants in one place to ease maintenance.
  11357. * @hidden
  11358. */
  11359. export class SceneComponentConstants {
  11360. static readonly NAME_EFFECTLAYER: string;
  11361. static readonly NAME_LAYER: string;
  11362. static readonly NAME_LENSFLARESYSTEM: string;
  11363. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11364. static readonly NAME_PARTICLESYSTEM: string;
  11365. static readonly NAME_GAMEPAD: string;
  11366. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11367. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11368. static readonly NAME_DEPTHRENDERER: string;
  11369. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11370. static readonly NAME_SPRITE: string;
  11371. static readonly NAME_OUTLINERENDERER: string;
  11372. static readonly NAME_PROCEDURALTEXTURE: string;
  11373. static readonly NAME_SHADOWGENERATOR: string;
  11374. static readonly NAME_OCTREE: string;
  11375. static readonly NAME_PHYSICSENGINE: string;
  11376. static readonly NAME_AUDIO: string;
  11377. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11378. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11379. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11380. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11381. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11382. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11383. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11384. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11385. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11386. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11387. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11388. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11389. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11390. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11391. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11392. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11393. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11394. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11395. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11396. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11397. static readonly STEP_AFTERRENDER_AUDIO: number;
  11398. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11399. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11400. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11401. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11402. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11403. static readonly STEP_POINTERMOVE_SPRITE: number;
  11404. static readonly STEP_POINTERDOWN_SPRITE: number;
  11405. static readonly STEP_POINTERUP_SPRITE: number;
  11406. }
  11407. /**
  11408. * This represents a scene component.
  11409. *
  11410. * This is used to decouple the dependency the scene is having on the different workloads like
  11411. * layers, post processes...
  11412. */
  11413. export interface ISceneComponent {
  11414. /**
  11415. * The name of the component. Each component must have a unique name.
  11416. */
  11417. name: string;
  11418. /**
  11419. * The scene the component belongs to.
  11420. */
  11421. scene: Scene;
  11422. /**
  11423. * Register the component to one instance of a scene.
  11424. */
  11425. register(): void;
  11426. /**
  11427. * Rebuilds the elements related to this component in case of
  11428. * context lost for instance.
  11429. */
  11430. rebuild(): void;
  11431. /**
  11432. * Disposes the component and the associated ressources.
  11433. */
  11434. dispose(): void;
  11435. }
  11436. /**
  11437. * This represents a SERIALIZABLE scene component.
  11438. *
  11439. * This extends Scene Component to add Serialization methods on top.
  11440. */
  11441. export interface ISceneSerializableComponent extends ISceneComponent {
  11442. /**
  11443. * Adds all the element from the container to the scene
  11444. * @param container the container holding the elements
  11445. */
  11446. addFromContainer(container: AbstractScene): void;
  11447. /**
  11448. * Removes all the elements in the container from the scene
  11449. * @param container contains the elements to remove
  11450. */
  11451. removeFromContainer(container: AbstractScene): void;
  11452. /**
  11453. * Serializes the component data to the specified json object
  11454. * @param serializationObject The object to serialize to
  11455. */
  11456. serialize(serializationObject: any): void;
  11457. }
  11458. /**
  11459. * Strong typing of a Mesh related stage step action
  11460. */
  11461. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11462. /**
  11463. * Strong typing of a Evaluate Sub Mesh related stage step action
  11464. */
  11465. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11466. /**
  11467. * Strong typing of a Active Mesh related stage step action
  11468. */
  11469. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11470. /**
  11471. * Strong typing of a Camera related stage step action
  11472. */
  11473. export type CameraStageAction = (camera: Camera) => void;
  11474. /**
  11475. * Strong typing of a Render Target related stage step action
  11476. */
  11477. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11478. /**
  11479. * Strong typing of a RenderingGroup related stage step action
  11480. */
  11481. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11482. /**
  11483. * Strong typing of a Mesh Render related stage step action
  11484. */
  11485. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11486. /**
  11487. * Strong typing of a simple stage step action
  11488. */
  11489. export type SimpleStageAction = () => void;
  11490. /**
  11491. * Strong typing of a render target action.
  11492. */
  11493. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11494. /**
  11495. * Strong typing of a pointer move action.
  11496. */
  11497. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11498. /**
  11499. * Strong typing of a pointer up/down action.
  11500. */
  11501. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11502. /**
  11503. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11504. * @hidden
  11505. */
  11506. export class Stage<T extends Function> extends Array<{
  11507. index: number;
  11508. component: ISceneComponent;
  11509. action: T;
  11510. }> {
  11511. /**
  11512. * Hide ctor from the rest of the world.
  11513. * @param items The items to add.
  11514. */
  11515. private constructor();
  11516. /**
  11517. * Creates a new Stage.
  11518. * @returns A new instance of a Stage
  11519. */
  11520. static Create<T extends Function>(): Stage<T>;
  11521. /**
  11522. * Registers a step in an ordered way in the targeted stage.
  11523. * @param index Defines the position to register the step in
  11524. * @param component Defines the component attached to the step
  11525. * @param action Defines the action to launch during the step
  11526. */
  11527. registerStep(index: number, component: ISceneComponent, action: T): void;
  11528. /**
  11529. * Clears all the steps from the stage.
  11530. */
  11531. clear(): void;
  11532. }
  11533. }
  11534. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11535. import { Nullable } from "babylonjs/types";
  11536. import { Observable } from "babylonjs/Misc/observable";
  11537. import { Scene } from "babylonjs/scene";
  11538. import { Sprite } from "babylonjs/Sprites/sprite";
  11539. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11540. import { Ray } from "babylonjs/Culling/ray";
  11541. import { Camera } from "babylonjs/Cameras/camera";
  11542. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11543. import { ISceneComponent } from "babylonjs/sceneComponent";
  11544. module "babylonjs/scene" {
  11545. interface Scene {
  11546. /** @hidden */
  11547. _pointerOverSprite: Nullable<Sprite>;
  11548. /** @hidden */
  11549. _pickedDownSprite: Nullable<Sprite>;
  11550. /** @hidden */
  11551. _tempSpritePickingRay: Nullable<Ray>;
  11552. /**
  11553. * All of the sprite managers added to this scene
  11554. * @see http://doc.babylonjs.com/babylon101/sprites
  11555. */
  11556. spriteManagers: Array<ISpriteManager>;
  11557. /**
  11558. * An event triggered when sprites rendering is about to start
  11559. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11560. */
  11561. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11562. /**
  11563. * An event triggered when sprites rendering is done
  11564. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11565. */
  11566. onAfterSpritesRenderingObservable: Observable<Scene>;
  11567. /** @hidden */
  11568. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11569. /** Launch a ray to try to pick a sprite in the scene
  11570. * @param x position on screen
  11571. * @param y position on screen
  11572. * @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
  11573. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11574. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11575. * @returns a PickingInfo
  11576. */
  11577. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11578. /** Use the given ray to pick a sprite in the scene
  11579. * @param ray The ray (in world space) to use to pick meshes
  11580. * @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
  11581. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11582. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11583. * @returns a PickingInfo
  11584. */
  11585. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11586. /**
  11587. * Force the sprite under the pointer
  11588. * @param sprite defines the sprite to use
  11589. */
  11590. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11591. /**
  11592. * Gets the sprite under the pointer
  11593. * @returns a Sprite or null if no sprite is under the pointer
  11594. */
  11595. getPointerOverSprite(): Nullable<Sprite>;
  11596. }
  11597. }
  11598. /**
  11599. * Defines the sprite scene component responsible to manage sprites
  11600. * in a given scene.
  11601. */
  11602. export class SpriteSceneComponent implements ISceneComponent {
  11603. /**
  11604. * The component name helpfull to identify the component in the list of scene components.
  11605. */
  11606. readonly name: string;
  11607. /**
  11608. * The scene the component belongs to.
  11609. */
  11610. scene: Scene;
  11611. /** @hidden */
  11612. private _spritePredicate;
  11613. /**
  11614. * Creates a new instance of the component for the given scene
  11615. * @param scene Defines the scene to register the component in
  11616. */
  11617. constructor(scene: Scene);
  11618. /**
  11619. * Registers the component in a given scene
  11620. */
  11621. register(): void;
  11622. /**
  11623. * Rebuilds the elements related to this component in case of
  11624. * context lost for instance.
  11625. */
  11626. rebuild(): void;
  11627. /**
  11628. * Disposes the component and the associated ressources.
  11629. */
  11630. dispose(): void;
  11631. private _pickSpriteButKeepRay;
  11632. private _pointerMove;
  11633. private _pointerDown;
  11634. private _pointerUp;
  11635. }
  11636. }
  11637. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11638. /** @hidden */
  11639. export var fogFragmentDeclaration: {
  11640. name: string;
  11641. shader: string;
  11642. };
  11643. }
  11644. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11645. /** @hidden */
  11646. export var fogFragment: {
  11647. name: string;
  11648. shader: string;
  11649. };
  11650. }
  11651. declare module "babylonjs/Shaders/sprites.fragment" {
  11652. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11653. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11654. /** @hidden */
  11655. export var spritesPixelShader: {
  11656. name: string;
  11657. shader: string;
  11658. };
  11659. }
  11660. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11661. /** @hidden */
  11662. export var fogVertexDeclaration: {
  11663. name: string;
  11664. shader: string;
  11665. };
  11666. }
  11667. declare module "babylonjs/Shaders/sprites.vertex" {
  11668. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11669. /** @hidden */
  11670. export var spritesVertexShader: {
  11671. name: string;
  11672. shader: string;
  11673. };
  11674. }
  11675. declare module "babylonjs/Sprites/spriteManager" {
  11676. import { IDisposable, Scene } from "babylonjs/scene";
  11677. import { Nullable } from "babylonjs/types";
  11678. import { Observable } from "babylonjs/Misc/observable";
  11679. import { Sprite } from "babylonjs/Sprites/sprite";
  11680. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11681. import { Camera } from "babylonjs/Cameras/camera";
  11682. import { Texture } from "babylonjs/Materials/Textures/texture";
  11683. import "babylonjs/Shaders/sprites.fragment";
  11684. import "babylonjs/Shaders/sprites.vertex";
  11685. import { Ray } from "babylonjs/Culling/ray";
  11686. /**
  11687. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11688. */
  11689. export interface ISpriteManager extends IDisposable {
  11690. /**
  11691. * Restricts the camera to viewing objects with the same layerMask.
  11692. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11693. */
  11694. layerMask: number;
  11695. /**
  11696. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11697. */
  11698. isPickable: boolean;
  11699. /**
  11700. * Specifies the rendering group id for this mesh (0 by default)
  11701. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11702. */
  11703. renderingGroupId: number;
  11704. /**
  11705. * Defines the list of sprites managed by the manager.
  11706. */
  11707. sprites: Array<Sprite>;
  11708. /**
  11709. * Tests the intersection of a sprite with a specific ray.
  11710. * @param ray The ray we are sending to test the collision
  11711. * @param camera The camera space we are sending rays in
  11712. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11713. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11714. * @returns picking info or null.
  11715. */
  11716. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11717. /**
  11718. * Renders the list of sprites on screen.
  11719. */
  11720. render(): void;
  11721. }
  11722. /**
  11723. * Class used to manage multiple sprites on the same spritesheet
  11724. * @see http://doc.babylonjs.com/babylon101/sprites
  11725. */
  11726. export class SpriteManager implements ISpriteManager {
  11727. /** defines the manager's name */
  11728. name: string;
  11729. /** Gets the list of sprites */
  11730. sprites: Sprite[];
  11731. /** Gets or sets the rendering group id (0 by default) */
  11732. renderingGroupId: number;
  11733. /** Gets or sets camera layer mask */
  11734. layerMask: number;
  11735. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11736. fogEnabled: boolean;
  11737. /** Gets or sets a boolean indicating if the sprites are pickable */
  11738. isPickable: boolean;
  11739. /** Defines the default width of a cell in the spritesheet */
  11740. cellWidth: number;
  11741. /** Defines the default height of a cell in the spritesheet */
  11742. cellHeight: number;
  11743. /**
  11744. * An event triggered when the manager is disposed.
  11745. */
  11746. onDisposeObservable: Observable<SpriteManager>;
  11747. private _onDisposeObserver;
  11748. /**
  11749. * Callback called when the manager is disposed
  11750. */
  11751. onDispose: () => void;
  11752. private _capacity;
  11753. private _spriteTexture;
  11754. private _epsilon;
  11755. private _scene;
  11756. private _vertexData;
  11757. private _buffer;
  11758. private _vertexBuffers;
  11759. private _indexBuffer;
  11760. private _effectBase;
  11761. private _effectFog;
  11762. /**
  11763. * Gets or sets the spritesheet texture
  11764. */
  11765. texture: Texture;
  11766. /**
  11767. * Creates a new sprite manager
  11768. * @param name defines the manager's name
  11769. * @param imgUrl defines the sprite sheet url
  11770. * @param capacity defines the maximum allowed number of sprites
  11771. * @param cellSize defines the size of a sprite cell
  11772. * @param scene defines the hosting scene
  11773. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11774. * @param samplingMode defines the smapling mode to use with spritesheet
  11775. */
  11776. constructor(
  11777. /** defines the manager's name */
  11778. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11779. private _appendSpriteVertex;
  11780. /**
  11781. * Intersects the sprites with a ray
  11782. * @param ray defines the ray to intersect with
  11783. * @param camera defines the current active camera
  11784. * @param predicate defines a predicate used to select candidate sprites
  11785. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11786. * @returns null if no hit or a PickingInfo
  11787. */
  11788. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11789. /**
  11790. * Render all child sprites
  11791. */
  11792. render(): void;
  11793. /**
  11794. * Release associated resources
  11795. */
  11796. dispose(): void;
  11797. }
  11798. }
  11799. declare module "babylonjs/Sprites/sprite" {
  11800. import { Vector3, Color4 } from "babylonjs/Maths/math";
  11801. import { Nullable } from "babylonjs/types";
  11802. import { ActionManager } from "babylonjs/Actions/actionManager";
  11803. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11804. /**
  11805. * Class used to represent a sprite
  11806. * @see http://doc.babylonjs.com/babylon101/sprites
  11807. */
  11808. export class Sprite {
  11809. /** defines the name */
  11810. name: string;
  11811. /** Gets or sets the current world position */
  11812. position: Vector3;
  11813. /** Gets or sets the main color */
  11814. color: Color4;
  11815. /** Gets or sets the width */
  11816. width: number;
  11817. /** Gets or sets the height */
  11818. height: number;
  11819. /** Gets or sets rotation angle */
  11820. angle: number;
  11821. /** Gets or sets the cell index in the sprite sheet */
  11822. cellIndex: number;
  11823. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11824. invertU: number;
  11825. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11826. invertV: number;
  11827. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11828. disposeWhenFinishedAnimating: boolean;
  11829. /** Gets the list of attached animations */
  11830. animations: Animation[];
  11831. /** Gets or sets a boolean indicating if the sprite can be picked */
  11832. isPickable: boolean;
  11833. /**
  11834. * Gets or sets the associated action manager
  11835. */
  11836. actionManager: Nullable<ActionManager>;
  11837. private _animationStarted;
  11838. private _loopAnimation;
  11839. private _fromIndex;
  11840. private _toIndex;
  11841. private _delay;
  11842. private _direction;
  11843. private _manager;
  11844. private _time;
  11845. private _onAnimationEnd;
  11846. /**
  11847. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11848. */
  11849. isVisible: boolean;
  11850. /**
  11851. * Gets or sets the sprite size
  11852. */
  11853. size: number;
  11854. /**
  11855. * Creates a new Sprite
  11856. * @param name defines the name
  11857. * @param manager defines the manager
  11858. */
  11859. constructor(
  11860. /** defines the name */
  11861. name: string, manager: ISpriteManager);
  11862. /**
  11863. * Starts an animation
  11864. * @param from defines the initial key
  11865. * @param to defines the end key
  11866. * @param loop defines if the animation must loop
  11867. * @param delay defines the start delay (in ms)
  11868. * @param onAnimationEnd defines a callback to call when animation ends
  11869. */
  11870. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11871. /** Stops current animation (if any) */
  11872. stopAnimation(): void;
  11873. /** @hidden */
  11874. _animate(deltaTime: number): void;
  11875. /** Release associated resources */
  11876. dispose(): void;
  11877. }
  11878. }
  11879. declare module "babylonjs/Collisions/pickingInfo" {
  11880. import { Nullable } from "babylonjs/types";
  11881. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  11882. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11883. import { Sprite } from "babylonjs/Sprites/sprite";
  11884. import { Ray } from "babylonjs/Culling/ray";
  11885. /**
  11886. * Information about the result of picking within a scene
  11887. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11888. */
  11889. export class PickingInfo {
  11890. /** @hidden */
  11891. _pickingUnavailable: boolean;
  11892. /**
  11893. * If the pick collided with an object
  11894. */
  11895. hit: boolean;
  11896. /**
  11897. * Distance away where the pick collided
  11898. */
  11899. distance: number;
  11900. /**
  11901. * The location of pick collision
  11902. */
  11903. pickedPoint: Nullable<Vector3>;
  11904. /**
  11905. * The mesh corresponding the the pick collision
  11906. */
  11907. pickedMesh: Nullable<AbstractMesh>;
  11908. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  11909. bu: number;
  11910. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  11911. bv: number;
  11912. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11913. faceId: number;
  11914. /** Id of the the submesh that was picked */
  11915. subMeshId: number;
  11916. /** If a sprite was picked, this will be the sprite the pick collided with */
  11917. pickedSprite: Nullable<Sprite>;
  11918. /**
  11919. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11920. */
  11921. originMesh: Nullable<AbstractMesh>;
  11922. /**
  11923. * The ray that was used to perform the picking.
  11924. */
  11925. ray: Nullable<Ray>;
  11926. /**
  11927. * Gets the normal correspodning to the face the pick collided with
  11928. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11929. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11930. * @returns The normal correspodning to the face the pick collided with
  11931. */
  11932. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11933. /**
  11934. * Gets the texture coordinates of where the pick occured
  11935. * @returns the vector containing the coordnates of the texture
  11936. */
  11937. getTextureCoordinates(): Nullable<Vector2>;
  11938. }
  11939. }
  11940. declare module "babylonjs/Events/pointerEvents" {
  11941. import { Nullable } from "babylonjs/types";
  11942. import { Vector2 } from "babylonjs/Maths/math";
  11943. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11944. import { Ray } from "babylonjs/Culling/ray";
  11945. /**
  11946. * Gather the list of pointer event types as constants.
  11947. */
  11948. export class PointerEventTypes {
  11949. /**
  11950. * 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.
  11951. */
  11952. static readonly POINTERDOWN: number;
  11953. /**
  11954. * The pointerup event is fired when a pointer is no longer active.
  11955. */
  11956. static readonly POINTERUP: number;
  11957. /**
  11958. * The pointermove event is fired when a pointer changes coordinates.
  11959. */
  11960. static readonly POINTERMOVE: number;
  11961. /**
  11962. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11963. */
  11964. static readonly POINTERWHEEL: number;
  11965. /**
  11966. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11967. */
  11968. static readonly POINTERPICK: number;
  11969. /**
  11970. * The pointertap event is fired when a the object has been touched and released without drag.
  11971. */
  11972. static readonly POINTERTAP: number;
  11973. /**
  11974. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11975. */
  11976. static readonly POINTERDOUBLETAP: number;
  11977. }
  11978. /**
  11979. * Base class of pointer info types.
  11980. */
  11981. export class PointerInfoBase {
  11982. /**
  11983. * Defines the type of event (PointerEventTypes)
  11984. */
  11985. type: number;
  11986. /**
  11987. * Defines the related dom event
  11988. */
  11989. event: PointerEvent | MouseWheelEvent;
  11990. /**
  11991. * Instantiates the base class of pointers info.
  11992. * @param type Defines the type of event (PointerEventTypes)
  11993. * @param event Defines the related dom event
  11994. */
  11995. constructor(
  11996. /**
  11997. * Defines the type of event (PointerEventTypes)
  11998. */
  11999. type: number,
  12000. /**
  12001. * Defines the related dom event
  12002. */
  12003. event: PointerEvent | MouseWheelEvent);
  12004. }
  12005. /**
  12006. * This class is used to store pointer related info for the onPrePointerObservable event.
  12007. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12008. */
  12009. export class PointerInfoPre extends PointerInfoBase {
  12010. /**
  12011. * Ray from a pointer if availible (eg. 6dof controller)
  12012. */
  12013. ray: Nullable<Ray>;
  12014. /**
  12015. * Defines the local position of the pointer on the canvas.
  12016. */
  12017. localPosition: Vector2;
  12018. /**
  12019. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12020. */
  12021. skipOnPointerObservable: boolean;
  12022. /**
  12023. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12024. * @param type Defines the type of event (PointerEventTypes)
  12025. * @param event Defines the related dom event
  12026. * @param localX Defines the local x coordinates of the pointer when the event occured
  12027. * @param localY Defines the local y coordinates of the pointer when the event occured
  12028. */
  12029. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12030. }
  12031. /**
  12032. * This type contains all the data related to a pointer event in Babylon.js.
  12033. * 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.
  12034. */
  12035. export class PointerInfo extends PointerInfoBase {
  12036. /**
  12037. * Defines the picking info associated to the info (if any)\
  12038. */
  12039. pickInfo: Nullable<PickingInfo>;
  12040. /**
  12041. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12042. * @param type Defines the type of event (PointerEventTypes)
  12043. * @param event Defines the related dom event
  12044. * @param pickInfo Defines the picking info associated to the info (if any)\
  12045. */
  12046. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12047. /**
  12048. * Defines the picking info associated to the info (if any)\
  12049. */
  12050. pickInfo: Nullable<PickingInfo>);
  12051. }
  12052. }
  12053. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12054. import { Nullable } from "babylonjs/types";
  12055. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12056. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12057. /**
  12058. * Manage the mouse inputs to control the movement of a free camera.
  12059. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12060. */
  12061. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12062. /**
  12063. * Define if touch is enabled in the mouse input
  12064. */
  12065. touchEnabled: boolean;
  12066. /**
  12067. * Defines the camera the input is attached to.
  12068. */
  12069. camera: FreeCamera;
  12070. /**
  12071. * Defines the buttons associated with the input to handle camera move.
  12072. */
  12073. buttons: number[];
  12074. /**
  12075. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12076. */
  12077. angularSensibility: number;
  12078. private _pointerInput;
  12079. private _onMouseMove;
  12080. private _observer;
  12081. private previousPosition;
  12082. /**
  12083. * Manage the mouse inputs to control the movement of a free camera.
  12084. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12085. * @param touchEnabled Defines if touch is enabled or not
  12086. */
  12087. constructor(
  12088. /**
  12089. * Define if touch is enabled in the mouse input
  12090. */
  12091. touchEnabled?: boolean);
  12092. /**
  12093. * Attach the input controls to a specific dom element to get the input from.
  12094. * @param element Defines the element the controls should be listened from
  12095. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12096. */
  12097. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12098. /**
  12099. * Detach the current controls from the specified dom element.
  12100. * @param element Defines the element to stop listening the inputs from
  12101. */
  12102. detachControl(element: Nullable<HTMLElement>): void;
  12103. /**
  12104. * Gets the class name of the current intput.
  12105. * @returns the class name
  12106. */
  12107. getClassName(): string;
  12108. /**
  12109. * Get the friendly name associated with the input class.
  12110. * @returns the input friendly name
  12111. */
  12112. getSimpleName(): string;
  12113. }
  12114. }
  12115. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12116. import { Nullable } from "babylonjs/types";
  12117. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12118. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12119. /**
  12120. * Manage the touch inputs to control the movement of a free camera.
  12121. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12122. */
  12123. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12124. /**
  12125. * Defines the camera the input is attached to.
  12126. */
  12127. camera: FreeCamera;
  12128. /**
  12129. * Defines the touch sensibility for rotation.
  12130. * The higher the faster.
  12131. */
  12132. touchAngularSensibility: number;
  12133. /**
  12134. * Defines the touch sensibility for move.
  12135. * The higher the faster.
  12136. */
  12137. touchMoveSensibility: number;
  12138. private _offsetX;
  12139. private _offsetY;
  12140. private _pointerPressed;
  12141. private _pointerInput;
  12142. private _observer;
  12143. private _onLostFocus;
  12144. /**
  12145. * Attach the input controls to a specific dom element to get the input from.
  12146. * @param element Defines the element the controls should be listened from
  12147. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12148. */
  12149. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12150. /**
  12151. * Detach the current controls from the specified dom element.
  12152. * @param element Defines the element to stop listening the inputs from
  12153. */
  12154. detachControl(element: Nullable<HTMLElement>): void;
  12155. /**
  12156. * Update the current camera state depending on the inputs that have been used this frame.
  12157. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12158. */
  12159. checkInputs(): void;
  12160. /**
  12161. * Gets the class name of the current intput.
  12162. * @returns the class name
  12163. */
  12164. getClassName(): string;
  12165. /**
  12166. * Get the friendly name associated with the input class.
  12167. * @returns the input friendly name
  12168. */
  12169. getSimpleName(): string;
  12170. }
  12171. }
  12172. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12173. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12174. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12175. /**
  12176. * Default Inputs manager for the FreeCamera.
  12177. * It groups all the default supported inputs for ease of use.
  12178. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12179. */
  12180. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12181. /**
  12182. * Instantiates a new FreeCameraInputsManager.
  12183. * @param camera Defines the camera the inputs belong to
  12184. */
  12185. constructor(camera: FreeCamera);
  12186. /**
  12187. * Add keyboard input support to the input manager.
  12188. * @returns the current input manager
  12189. */
  12190. addKeyboard(): FreeCameraInputsManager;
  12191. /**
  12192. * Add mouse input support to the input manager.
  12193. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12194. * @returns the current input manager
  12195. */
  12196. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12197. /**
  12198. * Add touch input support to the input manager.
  12199. * @returns the current input manager
  12200. */
  12201. addTouch(): FreeCameraInputsManager;
  12202. }
  12203. }
  12204. declare module "babylonjs/Cameras/freeCamera" {
  12205. import { Vector3 } from "babylonjs/Maths/math";
  12206. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12207. import { Scene } from "babylonjs/scene";
  12208. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12209. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12210. /**
  12211. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12212. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12213. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12214. */
  12215. export class FreeCamera extends TargetCamera {
  12216. /**
  12217. * Define the collision ellipsoid of the camera.
  12218. * This is helpful to simulate a camera body like the player body around the camera
  12219. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12220. */
  12221. ellipsoid: Vector3;
  12222. /**
  12223. * Define an offset for the position of the ellipsoid around the camera.
  12224. * This can be helpful to determine the center of the body near the gravity center of the body
  12225. * instead of its head.
  12226. */
  12227. ellipsoidOffset: Vector3;
  12228. /**
  12229. * Enable or disable collisions of the camera with the rest of the scene objects.
  12230. */
  12231. checkCollisions: boolean;
  12232. /**
  12233. * Enable or disable gravity on the camera.
  12234. */
  12235. applyGravity: boolean;
  12236. /**
  12237. * Define the input manager associated to the camera.
  12238. */
  12239. inputs: FreeCameraInputsManager;
  12240. /**
  12241. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12242. * Higher values reduce sensitivity.
  12243. */
  12244. /**
  12245. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12246. * Higher values reduce sensitivity.
  12247. */
  12248. angularSensibility: number;
  12249. /**
  12250. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12251. */
  12252. keysUp: number[];
  12253. /**
  12254. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12255. */
  12256. keysDown: number[];
  12257. /**
  12258. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12259. */
  12260. keysLeft: number[];
  12261. /**
  12262. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12263. */
  12264. keysRight: number[];
  12265. /**
  12266. * Event raised when the camera collide with a mesh in the scene.
  12267. */
  12268. onCollide: (collidedMesh: AbstractMesh) => void;
  12269. private _collider;
  12270. private _needMoveForGravity;
  12271. private _oldPosition;
  12272. private _diffPosition;
  12273. private _newPosition;
  12274. /** @hidden */
  12275. _localDirection: Vector3;
  12276. /** @hidden */
  12277. _transformedDirection: Vector3;
  12278. /**
  12279. * Instantiates a Free Camera.
  12280. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12281. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12282. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12283. * @param name Define the name of the camera in the scene
  12284. * @param position Define the start position of the camera in the scene
  12285. * @param scene Define the scene the camera belongs to
  12286. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12287. */
  12288. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12289. /**
  12290. * Attached controls to the current camera.
  12291. * @param element Defines the element the controls should be listened from
  12292. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12293. */
  12294. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12295. /**
  12296. * Detach the current controls from the camera.
  12297. * The camera will stop reacting to inputs.
  12298. * @param element Defines the element to stop listening the inputs from
  12299. */
  12300. detachControl(element: HTMLElement): void;
  12301. private _collisionMask;
  12302. /**
  12303. * Define a collision mask to limit the list of object the camera can collide with
  12304. */
  12305. collisionMask: number;
  12306. /** @hidden */
  12307. _collideWithWorld(displacement: Vector3): void;
  12308. private _onCollisionPositionChange;
  12309. /** @hidden */
  12310. _checkInputs(): void;
  12311. /** @hidden */
  12312. _decideIfNeedsToMove(): boolean;
  12313. /** @hidden */
  12314. _updatePosition(): void;
  12315. /**
  12316. * Destroy the camera and release the current resources hold by it.
  12317. */
  12318. dispose(): void;
  12319. /**
  12320. * Gets the current object class name.
  12321. * @return the class name
  12322. */
  12323. getClassName(): string;
  12324. }
  12325. }
  12326. declare module "babylonjs/Gamepads/gamepad" {
  12327. import { Observable } from "babylonjs/Misc/observable";
  12328. /**
  12329. * Represents a gamepad control stick position
  12330. */
  12331. export class StickValues {
  12332. /**
  12333. * The x component of the control stick
  12334. */
  12335. x: number;
  12336. /**
  12337. * The y component of the control stick
  12338. */
  12339. y: number;
  12340. /**
  12341. * Initializes the gamepad x and y control stick values
  12342. * @param x The x component of the gamepad control stick value
  12343. * @param y The y component of the gamepad control stick value
  12344. */
  12345. constructor(
  12346. /**
  12347. * The x component of the control stick
  12348. */
  12349. x: number,
  12350. /**
  12351. * The y component of the control stick
  12352. */
  12353. y: number);
  12354. }
  12355. /**
  12356. * An interface which manages callbacks for gamepad button changes
  12357. */
  12358. export interface GamepadButtonChanges {
  12359. /**
  12360. * Called when a gamepad has been changed
  12361. */
  12362. changed: boolean;
  12363. /**
  12364. * Called when a gamepad press event has been triggered
  12365. */
  12366. pressChanged: boolean;
  12367. /**
  12368. * Called when a touch event has been triggered
  12369. */
  12370. touchChanged: boolean;
  12371. /**
  12372. * Called when a value has changed
  12373. */
  12374. valueChanged: boolean;
  12375. }
  12376. /**
  12377. * Represents a gamepad
  12378. */
  12379. export class Gamepad {
  12380. /**
  12381. * The id of the gamepad
  12382. */
  12383. id: string;
  12384. /**
  12385. * The index of the gamepad
  12386. */
  12387. index: number;
  12388. /**
  12389. * The browser gamepad
  12390. */
  12391. browserGamepad: any;
  12392. /**
  12393. * Specifies what type of gamepad this represents
  12394. */
  12395. type: number;
  12396. private _leftStick;
  12397. private _rightStick;
  12398. /** @hidden */
  12399. _isConnected: boolean;
  12400. private _leftStickAxisX;
  12401. private _leftStickAxisY;
  12402. private _rightStickAxisX;
  12403. private _rightStickAxisY;
  12404. /**
  12405. * Triggered when the left control stick has been changed
  12406. */
  12407. private _onleftstickchanged;
  12408. /**
  12409. * Triggered when the right control stick has been changed
  12410. */
  12411. private _onrightstickchanged;
  12412. /**
  12413. * Represents a gamepad controller
  12414. */
  12415. static GAMEPAD: number;
  12416. /**
  12417. * Represents a generic controller
  12418. */
  12419. static GENERIC: number;
  12420. /**
  12421. * Represents an XBox controller
  12422. */
  12423. static XBOX: number;
  12424. /**
  12425. * Represents a pose-enabled controller
  12426. */
  12427. static POSE_ENABLED: number;
  12428. /**
  12429. * Specifies whether the left control stick should be Y-inverted
  12430. */
  12431. protected _invertLeftStickY: boolean;
  12432. /**
  12433. * Specifies if the gamepad has been connected
  12434. */
  12435. readonly isConnected: boolean;
  12436. /**
  12437. * Initializes the gamepad
  12438. * @param id The id of the gamepad
  12439. * @param index The index of the gamepad
  12440. * @param browserGamepad The browser gamepad
  12441. * @param leftStickX The x component of the left joystick
  12442. * @param leftStickY The y component of the left joystick
  12443. * @param rightStickX The x component of the right joystick
  12444. * @param rightStickY The y component of the right joystick
  12445. */
  12446. constructor(
  12447. /**
  12448. * The id of the gamepad
  12449. */
  12450. id: string,
  12451. /**
  12452. * The index of the gamepad
  12453. */
  12454. index: number,
  12455. /**
  12456. * The browser gamepad
  12457. */
  12458. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12459. /**
  12460. * Callback triggered when the left joystick has changed
  12461. * @param callback
  12462. */
  12463. onleftstickchanged(callback: (values: StickValues) => void): void;
  12464. /**
  12465. * Callback triggered when the right joystick has changed
  12466. * @param callback
  12467. */
  12468. onrightstickchanged(callback: (values: StickValues) => void): void;
  12469. /**
  12470. * Gets the left joystick
  12471. */
  12472. /**
  12473. * Sets the left joystick values
  12474. */
  12475. leftStick: StickValues;
  12476. /**
  12477. * Gets the right joystick
  12478. */
  12479. /**
  12480. * Sets the right joystick value
  12481. */
  12482. rightStick: StickValues;
  12483. /**
  12484. * Updates the gamepad joystick positions
  12485. */
  12486. update(): void;
  12487. /**
  12488. * Disposes the gamepad
  12489. */
  12490. dispose(): void;
  12491. }
  12492. /**
  12493. * Represents a generic gamepad
  12494. */
  12495. export class GenericPad extends Gamepad {
  12496. private _buttons;
  12497. private _onbuttondown;
  12498. private _onbuttonup;
  12499. /**
  12500. * Observable triggered when a button has been pressed
  12501. */
  12502. onButtonDownObservable: Observable<number>;
  12503. /**
  12504. * Observable triggered when a button has been released
  12505. */
  12506. onButtonUpObservable: Observable<number>;
  12507. /**
  12508. * Callback triggered when a button has been pressed
  12509. * @param callback Called when a button has been pressed
  12510. */
  12511. onbuttondown(callback: (buttonPressed: number) => void): void;
  12512. /**
  12513. * Callback triggered when a button has been released
  12514. * @param callback Called when a button has been released
  12515. */
  12516. onbuttonup(callback: (buttonReleased: number) => void): void;
  12517. /**
  12518. * Initializes the generic gamepad
  12519. * @param id The id of the generic gamepad
  12520. * @param index The index of the generic gamepad
  12521. * @param browserGamepad The browser gamepad
  12522. */
  12523. constructor(id: string, index: number, browserGamepad: any);
  12524. private _setButtonValue;
  12525. /**
  12526. * Updates the generic gamepad
  12527. */
  12528. update(): void;
  12529. /**
  12530. * Disposes the generic gamepad
  12531. */
  12532. dispose(): void;
  12533. }
  12534. }
  12535. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  12536. import { Observable } from "babylonjs/Misc/observable";
  12537. import { Nullable } from "babylonjs/types";
  12538. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12539. import { TransformNode } from "babylonjs/Meshes/transformNode";
  12540. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12541. import { Ray } from "babylonjs/Culling/ray";
  12542. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  12543. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  12544. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12545. /**
  12546. * Defines the types of pose enabled controllers that are supported
  12547. */
  12548. export enum PoseEnabledControllerType {
  12549. /**
  12550. * HTC Vive
  12551. */
  12552. VIVE = 0,
  12553. /**
  12554. * Oculus Rift
  12555. */
  12556. OCULUS = 1,
  12557. /**
  12558. * Windows mixed reality
  12559. */
  12560. WINDOWS = 2,
  12561. /**
  12562. * Samsung gear VR
  12563. */
  12564. GEAR_VR = 3,
  12565. /**
  12566. * Google Daydream
  12567. */
  12568. DAYDREAM = 4,
  12569. /**
  12570. * Generic
  12571. */
  12572. GENERIC = 5
  12573. }
  12574. /**
  12575. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12576. */
  12577. export interface MutableGamepadButton {
  12578. /**
  12579. * Value of the button/trigger
  12580. */
  12581. value: number;
  12582. /**
  12583. * If the button/trigger is currently touched
  12584. */
  12585. touched: boolean;
  12586. /**
  12587. * If the button/trigger is currently pressed
  12588. */
  12589. pressed: boolean;
  12590. }
  12591. /**
  12592. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12593. * @hidden
  12594. */
  12595. export interface ExtendedGamepadButton extends GamepadButton {
  12596. /**
  12597. * If the button/trigger is currently pressed
  12598. */
  12599. readonly pressed: boolean;
  12600. /**
  12601. * If the button/trigger is currently touched
  12602. */
  12603. readonly touched: boolean;
  12604. /**
  12605. * Value of the button/trigger
  12606. */
  12607. readonly value: number;
  12608. }
  12609. /** @hidden */
  12610. export interface _GamePadFactory {
  12611. /**
  12612. * Returns wether or not the current gamepad can be created for this type of controller.
  12613. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12614. * @returns true if it can be created, otherwise false
  12615. */
  12616. canCreate(gamepadInfo: any): boolean;
  12617. /**
  12618. * Creates a new instance of the Gamepad.
  12619. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12620. * @returns the new gamepad instance
  12621. */
  12622. create(gamepadInfo: any): Gamepad;
  12623. }
  12624. /**
  12625. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12626. */
  12627. export class PoseEnabledControllerHelper {
  12628. /** @hidden */
  12629. static _ControllerFactories: _GamePadFactory[];
  12630. /** @hidden */
  12631. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12632. /**
  12633. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12634. * @param vrGamepad the gamepad to initialized
  12635. * @returns a vr controller of the type the gamepad identified as
  12636. */
  12637. static InitiateController(vrGamepad: any): Gamepad;
  12638. }
  12639. /**
  12640. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12641. */
  12642. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12643. private _deviceRoomPosition;
  12644. private _deviceRoomRotationQuaternion;
  12645. /**
  12646. * The device position in babylon space
  12647. */
  12648. devicePosition: Vector3;
  12649. /**
  12650. * The device rotation in babylon space
  12651. */
  12652. deviceRotationQuaternion: Quaternion;
  12653. /**
  12654. * The scale factor of the device in babylon space
  12655. */
  12656. deviceScaleFactor: number;
  12657. /**
  12658. * (Likely devicePosition should be used instead) The device position in its room space
  12659. */
  12660. position: Vector3;
  12661. /**
  12662. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12663. */
  12664. rotationQuaternion: Quaternion;
  12665. /**
  12666. * The type of controller (Eg. Windows mixed reality)
  12667. */
  12668. controllerType: PoseEnabledControllerType;
  12669. protected _calculatedPosition: Vector3;
  12670. private _calculatedRotation;
  12671. /**
  12672. * The raw pose from the device
  12673. */
  12674. rawPose: DevicePose;
  12675. private _trackPosition;
  12676. private _maxRotationDistFromHeadset;
  12677. private _draggedRoomRotation;
  12678. /**
  12679. * @hidden
  12680. */
  12681. _disableTrackPosition(fixedPosition: Vector3): void;
  12682. /**
  12683. * Internal, the mesh attached to the controller
  12684. * @hidden
  12685. */
  12686. _mesh: Nullable<AbstractMesh>;
  12687. private _poseControlledCamera;
  12688. private _leftHandSystemQuaternion;
  12689. /**
  12690. * Internal, matrix used to convert room space to babylon space
  12691. * @hidden
  12692. */
  12693. _deviceToWorld: Matrix;
  12694. /**
  12695. * Node to be used when casting a ray from the controller
  12696. * @hidden
  12697. */
  12698. _pointingPoseNode: Nullable<TransformNode>;
  12699. /**
  12700. * Name of the child mesh that can be used to cast a ray from the controller
  12701. */
  12702. static readonly POINTING_POSE: string;
  12703. /**
  12704. * Creates a new PoseEnabledController from a gamepad
  12705. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12706. */
  12707. constructor(browserGamepad: any);
  12708. private _workingMatrix;
  12709. /**
  12710. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12711. */
  12712. update(): void;
  12713. /**
  12714. * Updates only the pose device and mesh without doing any button event checking
  12715. */
  12716. protected _updatePoseAndMesh(): void;
  12717. /**
  12718. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12719. * @param poseData raw pose fromthe device
  12720. */
  12721. updateFromDevice(poseData: DevicePose): void;
  12722. /**
  12723. * @hidden
  12724. */
  12725. _meshAttachedObservable: Observable<AbstractMesh>;
  12726. /**
  12727. * Attaches a mesh to the controller
  12728. * @param mesh the mesh to be attached
  12729. */
  12730. attachToMesh(mesh: AbstractMesh): void;
  12731. /**
  12732. * Attaches the controllers mesh to a camera
  12733. * @param camera the camera the mesh should be attached to
  12734. */
  12735. attachToPoseControlledCamera(camera: TargetCamera): void;
  12736. /**
  12737. * Disposes of the controller
  12738. */
  12739. dispose(): void;
  12740. /**
  12741. * The mesh that is attached to the controller
  12742. */
  12743. readonly mesh: Nullable<AbstractMesh>;
  12744. /**
  12745. * Gets the ray of the controller in the direction the controller is pointing
  12746. * @param length the length the resulting ray should be
  12747. * @returns a ray in the direction the controller is pointing
  12748. */
  12749. getForwardRay(length?: number): Ray;
  12750. }
  12751. }
  12752. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  12753. import { Observable } from "babylonjs/Misc/observable";
  12754. import { Scene } from "babylonjs/scene";
  12755. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12756. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  12757. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  12758. /**
  12759. * Defines the WebVRController object that represents controllers tracked in 3D space
  12760. */
  12761. export abstract class WebVRController extends PoseEnabledController {
  12762. /**
  12763. * Internal, the default controller model for the controller
  12764. */
  12765. protected _defaultModel: AbstractMesh;
  12766. /**
  12767. * Fired when the trigger state has changed
  12768. */
  12769. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12770. /**
  12771. * Fired when the main button state has changed
  12772. */
  12773. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12774. /**
  12775. * Fired when the secondary button state has changed
  12776. */
  12777. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12778. /**
  12779. * Fired when the pad state has changed
  12780. */
  12781. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12782. /**
  12783. * Fired when controllers stick values have changed
  12784. */
  12785. onPadValuesChangedObservable: Observable<StickValues>;
  12786. /**
  12787. * Array of button availible on the controller
  12788. */
  12789. protected _buttons: Array<MutableGamepadButton>;
  12790. private _onButtonStateChange;
  12791. /**
  12792. * Fired when a controller button's state has changed
  12793. * @param callback the callback containing the button that was modified
  12794. */
  12795. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  12796. /**
  12797. * X and Y axis corrisponding to the controllers joystick
  12798. */
  12799. pad: StickValues;
  12800. /**
  12801. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  12802. */
  12803. hand: string;
  12804. /**
  12805. * The default controller model for the controller
  12806. */
  12807. readonly defaultModel: AbstractMesh;
  12808. /**
  12809. * Creates a new WebVRController from a gamepad
  12810. * @param vrGamepad the gamepad that the WebVRController should be created from
  12811. */
  12812. constructor(vrGamepad: any);
  12813. /**
  12814. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  12815. */
  12816. update(): void;
  12817. /**
  12818. * Function to be called when a button is modified
  12819. */
  12820. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  12821. /**
  12822. * Loads a mesh and attaches it to the controller
  12823. * @param scene the scene the mesh should be added to
  12824. * @param meshLoaded callback for when the mesh has been loaded
  12825. */
  12826. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  12827. private _setButtonValue;
  12828. private _changes;
  12829. private _checkChanges;
  12830. /**
  12831. * Disposes of th webVRCOntroller
  12832. */
  12833. dispose(): void;
  12834. }
  12835. }
  12836. declare module "babylonjs/Lights/hemisphericLight" {
  12837. import { Nullable } from "babylonjs/types";
  12838. import { Scene } from "babylonjs/scene";
  12839. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  12840. import { Effect } from "babylonjs/Materials/effect";
  12841. import { Light } from "babylonjs/Lights/light";
  12842. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  12843. /**
  12844. * The HemisphericLight simulates the ambient environment light,
  12845. * so the passed direction is the light reflection direction, not the incoming direction.
  12846. */
  12847. export class HemisphericLight extends Light {
  12848. /**
  12849. * The groundColor is the light in the opposite direction to the one specified during creation.
  12850. * 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.
  12851. */
  12852. groundColor: Color3;
  12853. /**
  12854. * The light reflection direction, not the incoming direction.
  12855. */
  12856. direction: Vector3;
  12857. /**
  12858. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  12859. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  12860. * The HemisphericLight can't cast shadows.
  12861. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12862. * @param name The friendly name of the light
  12863. * @param direction The direction of the light reflection
  12864. * @param scene The scene the light belongs to
  12865. */
  12866. constructor(name: string, direction: Vector3, scene: Scene);
  12867. protected _buildUniformLayout(): void;
  12868. /**
  12869. * Returns the string "HemisphericLight".
  12870. * @return The class name
  12871. */
  12872. getClassName(): string;
  12873. /**
  12874. * Sets the HemisphericLight direction towards the passed target (Vector3).
  12875. * Returns the updated direction.
  12876. * @param target The target the direction should point to
  12877. * @return The computed direction
  12878. */
  12879. setDirectionToTarget(target: Vector3): Vector3;
  12880. /**
  12881. * Returns the shadow generator associated to the light.
  12882. * @returns Always null for hemispheric lights because it does not support shadows.
  12883. */
  12884. getShadowGenerator(): Nullable<IShadowGenerator>;
  12885. /**
  12886. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  12887. * @param effect The effect to update
  12888. * @param lightIndex The index of the light in the effect to update
  12889. * @returns The hemispheric light
  12890. */
  12891. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  12892. /**
  12893. * Computes the world matrix of the node
  12894. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  12895. * @param useWasUpdatedFlag defines a reserved property
  12896. * @returns the world matrix
  12897. */
  12898. computeWorldMatrix(): Matrix;
  12899. /**
  12900. * Returns the integer 3.
  12901. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12902. */
  12903. getTypeID(): number;
  12904. /**
  12905. * Prepares the list of defines specific to the light type.
  12906. * @param defines the list of defines
  12907. * @param lightIndex defines the index of the light for the effect
  12908. */
  12909. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12910. }
  12911. }
  12912. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  12913. declare module "babylonjs/Cameras/VR/webVRCamera" {
  12914. import { Nullable } from "babylonjs/types";
  12915. import { Observable } from "babylonjs/Misc/observable";
  12916. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12917. import { Scene } from "babylonjs/scene";
  12918. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12919. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  12920. import { Node } from "babylonjs/node";
  12921. import { Ray } from "babylonjs/Culling/ray";
  12922. import "babylonjs/Cameras/RigModes/webVRRigMode";
  12923. /**
  12924. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  12925. * IMPORTANT!! The data is right-hand data.
  12926. * @export
  12927. * @interface DevicePose
  12928. */
  12929. export interface DevicePose {
  12930. /**
  12931. * The position of the device, values in array are [x,y,z].
  12932. */
  12933. readonly position: Nullable<Float32Array>;
  12934. /**
  12935. * The linearVelocity of the device, values in array are [x,y,z].
  12936. */
  12937. readonly linearVelocity: Nullable<Float32Array>;
  12938. /**
  12939. * The linearAcceleration of the device, values in array are [x,y,z].
  12940. */
  12941. readonly linearAcceleration: Nullable<Float32Array>;
  12942. /**
  12943. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  12944. */
  12945. readonly orientation: Nullable<Float32Array>;
  12946. /**
  12947. * The angularVelocity of the device, values in array are [x,y,z].
  12948. */
  12949. readonly angularVelocity: Nullable<Float32Array>;
  12950. /**
  12951. * The angularAcceleration of the device, values in array are [x,y,z].
  12952. */
  12953. readonly angularAcceleration: Nullable<Float32Array>;
  12954. }
  12955. /**
  12956. * Interface representing a pose controlled object in Babylon.
  12957. * A pose controlled object has both regular pose values as well as pose values
  12958. * from an external device such as a VR head mounted display
  12959. */
  12960. export interface PoseControlled {
  12961. /**
  12962. * The position of the object in babylon space.
  12963. */
  12964. position: Vector3;
  12965. /**
  12966. * The rotation quaternion of the object in babylon space.
  12967. */
  12968. rotationQuaternion: Quaternion;
  12969. /**
  12970. * The position of the device in babylon space.
  12971. */
  12972. devicePosition?: Vector3;
  12973. /**
  12974. * The rotation quaternion of the device in babylon space.
  12975. */
  12976. deviceRotationQuaternion: Quaternion;
  12977. /**
  12978. * The raw pose coming from the device.
  12979. */
  12980. rawPose: Nullable<DevicePose>;
  12981. /**
  12982. * The scale of the device to be used when translating from device space to babylon space.
  12983. */
  12984. deviceScaleFactor: number;
  12985. /**
  12986. * Updates the poseControlled values based on the input device pose.
  12987. * @param poseData the pose data to update the object with
  12988. */
  12989. updateFromDevice(poseData: DevicePose): void;
  12990. }
  12991. /**
  12992. * Set of options to customize the webVRCamera
  12993. */
  12994. export interface WebVROptions {
  12995. /**
  12996. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  12997. */
  12998. trackPosition?: boolean;
  12999. /**
  13000. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13001. */
  13002. positionScale?: number;
  13003. /**
  13004. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13005. */
  13006. displayName?: string;
  13007. /**
  13008. * Should the native controller meshes be initialized. (default: true)
  13009. */
  13010. controllerMeshes?: boolean;
  13011. /**
  13012. * Creating a default HemiLight only on controllers. (default: true)
  13013. */
  13014. defaultLightingOnControllers?: boolean;
  13015. /**
  13016. * If you don't want to use the default VR button of the helper. (default: false)
  13017. */
  13018. useCustomVRButton?: boolean;
  13019. /**
  13020. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13021. */
  13022. customVRButton?: HTMLButtonElement;
  13023. /**
  13024. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13025. */
  13026. rayLength?: number;
  13027. /**
  13028. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13029. */
  13030. defaultHeight?: number;
  13031. }
  13032. /**
  13033. * This represents a WebVR camera.
  13034. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13035. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13036. */
  13037. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13038. private webVROptions;
  13039. /**
  13040. * @hidden
  13041. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13042. */
  13043. _vrDevice: any;
  13044. /**
  13045. * The rawPose of the vrDevice.
  13046. */
  13047. rawPose: Nullable<DevicePose>;
  13048. private _onVREnabled;
  13049. private _specsVersion;
  13050. private _attached;
  13051. private _frameData;
  13052. protected _descendants: Array<Node>;
  13053. private _deviceRoomPosition;
  13054. /** @hidden */
  13055. _deviceRoomRotationQuaternion: Quaternion;
  13056. private _standingMatrix;
  13057. /**
  13058. * Represents device position in babylon space.
  13059. */
  13060. devicePosition: Vector3;
  13061. /**
  13062. * Represents device rotation in babylon space.
  13063. */
  13064. deviceRotationQuaternion: Quaternion;
  13065. /**
  13066. * The scale of the device to be used when translating from device space to babylon space.
  13067. */
  13068. deviceScaleFactor: number;
  13069. private _deviceToWorld;
  13070. private _worldToDevice;
  13071. /**
  13072. * References to the webVR controllers for the vrDevice.
  13073. */
  13074. controllers: Array<WebVRController>;
  13075. /**
  13076. * Emits an event when a controller is attached.
  13077. */
  13078. onControllersAttachedObservable: Observable<WebVRController[]>;
  13079. /**
  13080. * Emits an event when a controller's mesh has been loaded;
  13081. */
  13082. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13083. /**
  13084. * Emits an event when the HMD's pose has been updated.
  13085. */
  13086. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13087. private _poseSet;
  13088. /**
  13089. * If the rig cameras be used as parent instead of this camera.
  13090. */
  13091. rigParenting: boolean;
  13092. private _lightOnControllers;
  13093. private _defaultHeight?;
  13094. /**
  13095. * Instantiates a WebVRFreeCamera.
  13096. * @param name The name of the WebVRFreeCamera
  13097. * @param position The starting anchor position for the camera
  13098. * @param scene The scene the camera belongs to
  13099. * @param webVROptions a set of customizable options for the webVRCamera
  13100. */
  13101. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13102. /**
  13103. * Gets the device distance from the ground in meters.
  13104. * @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.
  13105. */
  13106. deviceDistanceToRoomGround(): number;
  13107. /**
  13108. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13109. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13110. */
  13111. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13112. /**
  13113. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13114. * @returns A promise with a boolean set to if the standing matrix is supported.
  13115. */
  13116. useStandingMatrixAsync(): Promise<boolean>;
  13117. /**
  13118. * Disposes the camera
  13119. */
  13120. dispose(): void;
  13121. /**
  13122. * Gets a vrController by name.
  13123. * @param name The name of the controller to retreive
  13124. * @returns the controller matching the name specified or null if not found
  13125. */
  13126. getControllerByName(name: string): Nullable<WebVRController>;
  13127. private _leftController;
  13128. /**
  13129. * The controller corrisponding to the users left hand.
  13130. */
  13131. readonly leftController: Nullable<WebVRController>;
  13132. private _rightController;
  13133. /**
  13134. * The controller corrisponding to the users right hand.
  13135. */
  13136. readonly rightController: Nullable<WebVRController>;
  13137. /**
  13138. * Casts a ray forward from the vrCamera's gaze.
  13139. * @param length Length of the ray (default: 100)
  13140. * @returns the ray corrisponding to the gaze
  13141. */
  13142. getForwardRay(length?: number): Ray;
  13143. /**
  13144. * @hidden
  13145. * Updates the camera based on device's frame data
  13146. */
  13147. _checkInputs(): void;
  13148. /**
  13149. * Updates the poseControlled values based on the input device pose.
  13150. * @param poseData Pose coming from the device
  13151. */
  13152. updateFromDevice(poseData: DevicePose): void;
  13153. private _htmlElementAttached;
  13154. private _detachIfAttached;
  13155. /**
  13156. * WebVR's attach control will start broadcasting frames to the device.
  13157. * Note that in certain browsers (chrome for example) this function must be called
  13158. * within a user-interaction callback. Example:
  13159. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13160. *
  13161. * @param element html element to attach the vrDevice to
  13162. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13163. */
  13164. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13165. /**
  13166. * Detaches the camera from the html element and disables VR
  13167. *
  13168. * @param element html element to detach from
  13169. */
  13170. detachControl(element: HTMLElement): void;
  13171. /**
  13172. * @returns the name of this class
  13173. */
  13174. getClassName(): string;
  13175. /**
  13176. * Calls resetPose on the vrDisplay
  13177. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13178. */
  13179. resetToCurrentRotation(): void;
  13180. /**
  13181. * @hidden
  13182. * Updates the rig cameras (left and right eye)
  13183. */
  13184. _updateRigCameras(): void;
  13185. private _workingVector;
  13186. private _oneVector;
  13187. private _workingMatrix;
  13188. private updateCacheCalled;
  13189. private _correctPositionIfNotTrackPosition;
  13190. /**
  13191. * @hidden
  13192. * Updates the cached values of the camera
  13193. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13194. */
  13195. _updateCache(ignoreParentClass?: boolean): void;
  13196. /**
  13197. * @hidden
  13198. * Get current device position in babylon world
  13199. */
  13200. _computeDevicePosition(): void;
  13201. /**
  13202. * Updates the current device position and rotation in the babylon world
  13203. */
  13204. update(): void;
  13205. /**
  13206. * @hidden
  13207. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13208. * @returns an identity matrix
  13209. */
  13210. _getViewMatrix(): Matrix;
  13211. private _tmpMatrix;
  13212. /**
  13213. * This function is called by the two RIG cameras.
  13214. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13215. * @hidden
  13216. */
  13217. _getWebVRViewMatrix(): Matrix;
  13218. /** @hidden */
  13219. _getWebVRProjectionMatrix(): Matrix;
  13220. private _onGamepadConnectedObserver;
  13221. private _onGamepadDisconnectedObserver;
  13222. private _updateCacheWhenTrackingDisabledObserver;
  13223. /**
  13224. * Initializes the controllers and their meshes
  13225. */
  13226. initControllers(): void;
  13227. }
  13228. }
  13229. declare module "babylonjs/PostProcesses/postProcess" {
  13230. import { Nullable } from "babylonjs/types";
  13231. import { SmartArray } from "babylonjs/Misc/smartArray";
  13232. import { Observable } from "babylonjs/Misc/observable";
  13233. import { Color4, Vector2 } from "babylonjs/Maths/math";
  13234. import { Camera } from "babylonjs/Cameras/camera";
  13235. import { Effect } from "babylonjs/Materials/effect";
  13236. import "babylonjs/Shaders/postprocess.vertex";
  13237. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13238. import { Engine } from "babylonjs/Engines/engine";
  13239. /**
  13240. * Size options for a post process
  13241. */
  13242. export type PostProcessOptions = {
  13243. width: number;
  13244. height: number;
  13245. };
  13246. /**
  13247. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13248. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13249. */
  13250. export class PostProcess {
  13251. /** Name of the PostProcess. */
  13252. name: string;
  13253. /**
  13254. * Gets or sets the unique id of the post process
  13255. */
  13256. uniqueId: number;
  13257. /**
  13258. * Width of the texture to apply the post process on
  13259. */
  13260. width: number;
  13261. /**
  13262. * Height of the texture to apply the post process on
  13263. */
  13264. height: number;
  13265. /**
  13266. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13267. * @hidden
  13268. */
  13269. _outputTexture: Nullable<InternalTexture>;
  13270. /**
  13271. * Sampling mode used by the shader
  13272. * See https://doc.babylonjs.com/classes/3.1/texture
  13273. */
  13274. renderTargetSamplingMode: number;
  13275. /**
  13276. * Clear color to use when screen clearing
  13277. */
  13278. clearColor: Color4;
  13279. /**
  13280. * If the buffer needs to be cleared before applying the post process. (default: true)
  13281. * Should be set to false if shader will overwrite all previous pixels.
  13282. */
  13283. autoClear: boolean;
  13284. /**
  13285. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13286. */
  13287. alphaMode: number;
  13288. /**
  13289. * Sets the setAlphaBlendConstants of the babylon engine
  13290. */
  13291. alphaConstants: Color4;
  13292. /**
  13293. * Animations to be used for the post processing
  13294. */
  13295. animations: import("babylonjs/Animations/animation").Animation[];
  13296. /**
  13297. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13298. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13299. */
  13300. enablePixelPerfectMode: boolean;
  13301. /**
  13302. * Force the postprocess to be applied without taking in account viewport
  13303. */
  13304. forceFullscreenViewport: boolean;
  13305. /**
  13306. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13307. *
  13308. * | Value | Type | Description |
  13309. * | ----- | ----------------------------------- | ----------- |
  13310. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13311. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13312. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13313. *
  13314. */
  13315. scaleMode: number;
  13316. /**
  13317. * Force textures to be a power of two (default: false)
  13318. */
  13319. alwaysForcePOT: boolean;
  13320. private _samples;
  13321. /**
  13322. * Number of sample textures (default: 1)
  13323. */
  13324. samples: number;
  13325. /**
  13326. * Modify the scale of the post process to be the same as the viewport (default: false)
  13327. */
  13328. adaptScaleToCurrentViewport: boolean;
  13329. private _camera;
  13330. private _scene;
  13331. private _engine;
  13332. private _options;
  13333. private _reusable;
  13334. private _textureType;
  13335. /**
  13336. * Smart array of input and output textures for the post process.
  13337. * @hidden
  13338. */
  13339. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  13340. /**
  13341. * The index in _textures that corresponds to the output texture.
  13342. * @hidden
  13343. */
  13344. _currentRenderTextureInd: number;
  13345. private _effect;
  13346. private _samplers;
  13347. private _fragmentUrl;
  13348. private _vertexUrl;
  13349. private _parameters;
  13350. private _scaleRatio;
  13351. protected _indexParameters: any;
  13352. private _shareOutputWithPostProcess;
  13353. private _texelSize;
  13354. private _forcedOutputTexture;
  13355. /**
  13356. * Returns the fragment url or shader name used in the post process.
  13357. * @returns the fragment url or name in the shader store.
  13358. */
  13359. getEffectName(): string;
  13360. /**
  13361. * An event triggered when the postprocess is activated.
  13362. */
  13363. onActivateObservable: Observable<Camera>;
  13364. private _onActivateObserver;
  13365. /**
  13366. * A function that is added to the onActivateObservable
  13367. */
  13368. onActivate: Nullable<(camera: Camera) => void>;
  13369. /**
  13370. * An event triggered when the postprocess changes its size.
  13371. */
  13372. onSizeChangedObservable: Observable<PostProcess>;
  13373. private _onSizeChangedObserver;
  13374. /**
  13375. * A function that is added to the onSizeChangedObservable
  13376. */
  13377. onSizeChanged: (postProcess: PostProcess) => void;
  13378. /**
  13379. * An event triggered when the postprocess applies its effect.
  13380. */
  13381. onApplyObservable: Observable<Effect>;
  13382. private _onApplyObserver;
  13383. /**
  13384. * A function that is added to the onApplyObservable
  13385. */
  13386. onApply: (effect: Effect) => void;
  13387. /**
  13388. * An event triggered before rendering the postprocess
  13389. */
  13390. onBeforeRenderObservable: Observable<Effect>;
  13391. private _onBeforeRenderObserver;
  13392. /**
  13393. * A function that is added to the onBeforeRenderObservable
  13394. */
  13395. onBeforeRender: (effect: Effect) => void;
  13396. /**
  13397. * An event triggered after rendering the postprocess
  13398. */
  13399. onAfterRenderObservable: Observable<Effect>;
  13400. private _onAfterRenderObserver;
  13401. /**
  13402. * A function that is added to the onAfterRenderObservable
  13403. */
  13404. onAfterRender: (efect: Effect) => void;
  13405. /**
  13406. * 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
  13407. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13408. */
  13409. inputTexture: InternalTexture;
  13410. /**
  13411. * Gets the camera which post process is applied to.
  13412. * @returns The camera the post process is applied to.
  13413. */
  13414. getCamera(): Camera;
  13415. /**
  13416. * Gets the texel size of the postprocess.
  13417. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13418. */
  13419. readonly texelSize: Vector2;
  13420. /**
  13421. * Creates a new instance PostProcess
  13422. * @param name The name of the PostProcess.
  13423. * @param fragmentUrl The url of the fragment shader to be used.
  13424. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13425. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13426. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13427. * @param camera The camera to apply the render pass to.
  13428. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13429. * @param engine The engine which the post process will be applied. (default: current engine)
  13430. * @param reusable If the post process can be reused on the same frame. (default: false)
  13431. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13432. * @param textureType Type of textures used when performing the post process. (default: 0)
  13433. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13434. * @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
  13435. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13436. */
  13437. constructor(
  13438. /** Name of the PostProcess. */
  13439. 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);
  13440. /**
  13441. * Gets a string idenfifying the name of the class
  13442. * @returns "PostProcess" string
  13443. */
  13444. getClassName(): string;
  13445. /**
  13446. * Gets the engine which this post process belongs to.
  13447. * @returns The engine the post process was enabled with.
  13448. */
  13449. getEngine(): Engine;
  13450. /**
  13451. * The effect that is created when initializing the post process.
  13452. * @returns The created effect corrisponding the the postprocess.
  13453. */
  13454. getEffect(): Effect;
  13455. /**
  13456. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13457. * @param postProcess The post process to share the output with.
  13458. * @returns This post process.
  13459. */
  13460. shareOutputWith(postProcess: PostProcess): PostProcess;
  13461. /**
  13462. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13463. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13464. */
  13465. useOwnOutput(): void;
  13466. /**
  13467. * Updates the effect with the current post process compile time values and recompiles the shader.
  13468. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13469. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13470. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13471. * @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
  13472. * @param onCompiled Called when the shader has been compiled.
  13473. * @param onError Called if there is an error when compiling a shader.
  13474. */
  13475. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13476. /**
  13477. * The post process is reusable if it can be used multiple times within one frame.
  13478. * @returns If the post process is reusable
  13479. */
  13480. isReusable(): boolean;
  13481. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13482. markTextureDirty(): void;
  13483. /**
  13484. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13485. * 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.
  13486. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13487. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13488. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13489. * @returns The target texture that was bound to be written to.
  13490. */
  13491. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13492. /**
  13493. * If the post process is supported.
  13494. */
  13495. readonly isSupported: boolean;
  13496. /**
  13497. * The aspect ratio of the output texture.
  13498. */
  13499. readonly aspectRatio: number;
  13500. /**
  13501. * Get a value indicating if the post-process is ready to be used
  13502. * @returns true if the post-process is ready (shader is compiled)
  13503. */
  13504. isReady(): boolean;
  13505. /**
  13506. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13507. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13508. */
  13509. apply(): Nullable<Effect>;
  13510. private _disposeTextures;
  13511. /**
  13512. * Disposes the post process.
  13513. * @param camera The camera to dispose the post process on.
  13514. */
  13515. dispose(camera?: Camera): void;
  13516. }
  13517. }
  13518. declare module "babylonjs/PostProcesses/postProcessManager" {
  13519. import { Nullable } from "babylonjs/types";
  13520. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13521. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13522. import { Scene } from "babylonjs/scene";
  13523. /**
  13524. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13525. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13526. */
  13527. export class PostProcessManager {
  13528. private _scene;
  13529. private _indexBuffer;
  13530. private _vertexBuffers;
  13531. /**
  13532. * Creates a new instance PostProcess
  13533. * @param scene The scene that the post process is associated with.
  13534. */
  13535. constructor(scene: Scene);
  13536. private _prepareBuffers;
  13537. private _buildIndexBuffer;
  13538. /**
  13539. * Rebuilds the vertex buffers of the manager.
  13540. * @hidden
  13541. */
  13542. _rebuild(): void;
  13543. /**
  13544. * Prepares a frame to be run through a post process.
  13545. * @param sourceTexture The input texture to the post procesess. (default: null)
  13546. * @param postProcesses An array of post processes to be run. (default: null)
  13547. * @returns True if the post processes were able to be run.
  13548. * @hidden
  13549. */
  13550. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13551. /**
  13552. * Manually render a set of post processes to a texture.
  13553. * @param postProcesses An array of post processes to be run.
  13554. * @param targetTexture The target texture to render to.
  13555. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13556. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13557. * @param lodLevel defines which lod of the texture to render to
  13558. */
  13559. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13560. /**
  13561. * Finalize the result of the output of the postprocesses.
  13562. * @param doNotPresent If true the result will not be displayed to the screen.
  13563. * @param targetTexture The target texture to render to.
  13564. * @param faceIndex The index of the face to bind the target texture to.
  13565. * @param postProcesses The array of post processes to render.
  13566. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13567. * @hidden
  13568. */
  13569. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13570. /**
  13571. * Disposes of the post process manager.
  13572. */
  13573. dispose(): void;
  13574. }
  13575. }
  13576. declare module "babylonjs/Layers/layerSceneComponent" {
  13577. import { Scene } from "babylonjs/scene";
  13578. import { ISceneComponent } from "babylonjs/sceneComponent";
  13579. import { Layer } from "babylonjs/Layers/layer";
  13580. module "babylonjs/abstractScene" {
  13581. interface AbstractScene {
  13582. /**
  13583. * The list of layers (background and foreground) of the scene
  13584. */
  13585. layers: Array<Layer>;
  13586. }
  13587. }
  13588. /**
  13589. * Defines the layer scene component responsible to manage any layers
  13590. * in a given scene.
  13591. */
  13592. export class LayerSceneComponent implements ISceneComponent {
  13593. /**
  13594. * The component name helpfull to identify the component in the list of scene components.
  13595. */
  13596. readonly name: string;
  13597. /**
  13598. * The scene the component belongs to.
  13599. */
  13600. scene: Scene;
  13601. private _engine;
  13602. /**
  13603. * Creates a new instance of the component for the given scene
  13604. * @param scene Defines the scene to register the component in
  13605. */
  13606. constructor(scene: Scene);
  13607. /**
  13608. * Registers the component in a given scene
  13609. */
  13610. register(): void;
  13611. /**
  13612. * Rebuilds the elements related to this component in case of
  13613. * context lost for instance.
  13614. */
  13615. rebuild(): void;
  13616. /**
  13617. * Disposes the component and the associated ressources.
  13618. */
  13619. dispose(): void;
  13620. private _draw;
  13621. private _drawCameraPredicate;
  13622. private _drawCameraBackground;
  13623. private _drawCameraForeground;
  13624. private _drawRenderTargetPredicate;
  13625. private _drawRenderTargetBackground;
  13626. private _drawRenderTargetForeground;
  13627. }
  13628. }
  13629. declare module "babylonjs/Shaders/layer.fragment" {
  13630. /** @hidden */
  13631. export var layerPixelShader: {
  13632. name: string;
  13633. shader: string;
  13634. };
  13635. }
  13636. declare module "babylonjs/Shaders/layer.vertex" {
  13637. /** @hidden */
  13638. export var layerVertexShader: {
  13639. name: string;
  13640. shader: string;
  13641. };
  13642. }
  13643. declare module "babylonjs/Layers/layer" {
  13644. import { Observable } from "babylonjs/Misc/observable";
  13645. import { Nullable } from "babylonjs/types";
  13646. import { Scene } from "babylonjs/scene";
  13647. import { Vector2, Color4 } from "babylonjs/Maths/math";
  13648. import { Texture } from "babylonjs/Materials/Textures/texture";
  13649. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13650. import "babylonjs/Shaders/layer.fragment";
  13651. import "babylonjs/Shaders/layer.vertex";
  13652. /**
  13653. * This represents a full screen 2d layer.
  13654. * This can be useful to display a picture in the background of your scene for instance.
  13655. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13656. */
  13657. export class Layer {
  13658. /**
  13659. * Define the name of the layer.
  13660. */
  13661. name: string;
  13662. /**
  13663. * Define the texture the layer should display.
  13664. */
  13665. texture: Nullable<Texture>;
  13666. /**
  13667. * Is the layer in background or foreground.
  13668. */
  13669. isBackground: boolean;
  13670. /**
  13671. * Define the color of the layer (instead of texture).
  13672. */
  13673. color: Color4;
  13674. /**
  13675. * Define the scale of the layer in order to zoom in out of the texture.
  13676. */
  13677. scale: Vector2;
  13678. /**
  13679. * Define an offset for the layer in order to shift the texture.
  13680. */
  13681. offset: Vector2;
  13682. /**
  13683. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  13684. */
  13685. alphaBlendingMode: number;
  13686. /**
  13687. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  13688. * Alpha test will not mix with the background color in case of transparency.
  13689. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  13690. */
  13691. alphaTest: boolean;
  13692. /**
  13693. * Define a mask to restrict the layer to only some of the scene cameras.
  13694. */
  13695. layerMask: number;
  13696. /**
  13697. * Define the list of render target the layer is visible into.
  13698. */
  13699. renderTargetTextures: RenderTargetTexture[];
  13700. /**
  13701. * Define if the layer is only used in renderTarget or if it also
  13702. * renders in the main frame buffer of the canvas.
  13703. */
  13704. renderOnlyInRenderTargetTextures: boolean;
  13705. private _scene;
  13706. private _vertexBuffers;
  13707. private _indexBuffer;
  13708. private _effect;
  13709. private _alphaTestEffect;
  13710. /**
  13711. * An event triggered when the layer is disposed.
  13712. */
  13713. onDisposeObservable: Observable<Layer>;
  13714. private _onDisposeObserver;
  13715. /**
  13716. * Back compatibility with callback before the onDisposeObservable existed.
  13717. * The set callback will be triggered when the layer has been disposed.
  13718. */
  13719. onDispose: () => void;
  13720. /**
  13721. * An event triggered before rendering the scene
  13722. */
  13723. onBeforeRenderObservable: Observable<Layer>;
  13724. private _onBeforeRenderObserver;
  13725. /**
  13726. * Back compatibility with callback before the onBeforeRenderObservable existed.
  13727. * The set callback will be triggered just before rendering the layer.
  13728. */
  13729. onBeforeRender: () => void;
  13730. /**
  13731. * An event triggered after rendering the scene
  13732. */
  13733. onAfterRenderObservable: Observable<Layer>;
  13734. private _onAfterRenderObserver;
  13735. /**
  13736. * Back compatibility with callback before the onAfterRenderObservable existed.
  13737. * The set callback will be triggered just after rendering the layer.
  13738. */
  13739. onAfterRender: () => void;
  13740. /**
  13741. * Instantiates a new layer.
  13742. * This represents a full screen 2d layer.
  13743. * This can be useful to display a picture in the background of your scene for instance.
  13744. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13745. * @param name Define the name of the layer in the scene
  13746. * @param imgUrl Define the url of the texture to display in the layer
  13747. * @param scene Define the scene the layer belongs to
  13748. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  13749. * @param color Defines a color for the layer
  13750. */
  13751. constructor(
  13752. /**
  13753. * Define the name of the layer.
  13754. */
  13755. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  13756. private _createIndexBuffer;
  13757. /** @hidden */
  13758. _rebuild(): void;
  13759. /**
  13760. * Renders the layer in the scene.
  13761. */
  13762. render(): void;
  13763. /**
  13764. * Disposes and releases the associated ressources.
  13765. */
  13766. dispose(): void;
  13767. }
  13768. }
  13769. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  13770. import { Scene } from "babylonjs/scene";
  13771. import { ISceneComponent } from "babylonjs/sceneComponent";
  13772. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  13773. module "babylonjs/abstractScene" {
  13774. interface AbstractScene {
  13775. /**
  13776. * The list of procedural textures added to the scene
  13777. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13778. */
  13779. proceduralTextures: Array<ProceduralTexture>;
  13780. }
  13781. }
  13782. /**
  13783. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  13784. * in a given scene.
  13785. */
  13786. export class ProceduralTextureSceneComponent implements ISceneComponent {
  13787. /**
  13788. * The component name helpfull to identify the component in the list of scene components.
  13789. */
  13790. readonly name: string;
  13791. /**
  13792. * The scene the component belongs to.
  13793. */
  13794. scene: Scene;
  13795. /**
  13796. * Creates a new instance of the component for the given scene
  13797. * @param scene Defines the scene to register the component in
  13798. */
  13799. constructor(scene: Scene);
  13800. /**
  13801. * Registers the component in a given scene
  13802. */
  13803. register(): void;
  13804. /**
  13805. * Rebuilds the elements related to this component in case of
  13806. * context lost for instance.
  13807. */
  13808. rebuild(): void;
  13809. /**
  13810. * Disposes the component and the associated ressources.
  13811. */
  13812. dispose(): void;
  13813. private _beforeClear;
  13814. }
  13815. }
  13816. declare module "babylonjs/Shaders/procedural.vertex" {
  13817. /** @hidden */
  13818. export var proceduralVertexShader: {
  13819. name: string;
  13820. shader: string;
  13821. };
  13822. }
  13823. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  13824. import { Observable } from "babylonjs/Misc/observable";
  13825. import { Nullable } from "babylonjs/types";
  13826. import { Scene } from "babylonjs/scene";
  13827. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  13828. import { Effect } from "babylonjs/Materials/effect";
  13829. import { Texture } from "babylonjs/Materials/Textures/texture";
  13830. import "babylonjs/Shaders/procedural.vertex";
  13831. /**
  13832. * 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.
  13833. * This is the base class of any Procedural texture and contains most of the shareable code.
  13834. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13835. */
  13836. export class ProceduralTexture extends Texture {
  13837. isCube: boolean;
  13838. /**
  13839. * Define if the texture is enabled or not (disabled texture will not render)
  13840. */
  13841. isEnabled: boolean;
  13842. /**
  13843. * Define if the texture must be cleared before rendering (default is true)
  13844. */
  13845. autoClear: boolean;
  13846. /**
  13847. * Callback called when the texture is generated
  13848. */
  13849. onGenerated: () => void;
  13850. /**
  13851. * Event raised when the texture is generated
  13852. */
  13853. onGeneratedObservable: Observable<ProceduralTexture>;
  13854. /** @hidden */
  13855. _generateMipMaps: boolean;
  13856. /** @hidden **/
  13857. _effect: Effect;
  13858. /** @hidden */
  13859. _textures: {
  13860. [key: string]: Texture;
  13861. };
  13862. private _size;
  13863. private _currentRefreshId;
  13864. private _refreshRate;
  13865. private _vertexBuffers;
  13866. private _indexBuffer;
  13867. private _uniforms;
  13868. private _samplers;
  13869. private _fragment;
  13870. private _floats;
  13871. private _ints;
  13872. private _floatsArrays;
  13873. private _colors3;
  13874. private _colors4;
  13875. private _vectors2;
  13876. private _vectors3;
  13877. private _matrices;
  13878. private _fallbackTexture;
  13879. private _fallbackTextureUsed;
  13880. private _engine;
  13881. private _cachedDefines;
  13882. private _contentUpdateId;
  13883. private _contentData;
  13884. /**
  13885. * Instantiates a new procedural texture.
  13886. * 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.
  13887. * This is the base class of any Procedural texture and contains most of the shareable code.
  13888. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13889. * @param name Define the name of the texture
  13890. * @param size Define the size of the texture to create
  13891. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  13892. * @param scene Define the scene the texture belongs to
  13893. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  13894. * @param generateMipMaps Define if the texture should creates mip maps or not
  13895. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  13896. */
  13897. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  13898. /**
  13899. * The effect that is created when initializing the post process.
  13900. * @returns The created effect corrisponding the the postprocess.
  13901. */
  13902. getEffect(): Effect;
  13903. /**
  13904. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  13905. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  13906. */
  13907. getContent(): Nullable<ArrayBufferView>;
  13908. private _createIndexBuffer;
  13909. /** @hidden */
  13910. _rebuild(): void;
  13911. /**
  13912. * Resets the texture in order to recreate its associated resources.
  13913. * This can be called in case of context loss
  13914. */
  13915. reset(): void;
  13916. protected _getDefines(): string;
  13917. /**
  13918. * Is the texture ready to be used ? (rendered at least once)
  13919. * @returns true if ready, otherwise, false.
  13920. */
  13921. isReady(): boolean;
  13922. /**
  13923. * Resets the refresh counter of the texture and start bak from scratch.
  13924. * Could be useful to regenerate the texture if it is setup to render only once.
  13925. */
  13926. resetRefreshCounter(): void;
  13927. /**
  13928. * Set the fragment shader to use in order to render the texture.
  13929. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  13930. */
  13931. setFragment(fragment: any): void;
  13932. /**
  13933. * Define the refresh rate of the texture or the rendering frequency.
  13934. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  13935. */
  13936. refreshRate: number;
  13937. /** @hidden */
  13938. _shouldRender(): boolean;
  13939. /**
  13940. * Get the size the texture is rendering at.
  13941. * @returns the size (texture is always squared)
  13942. */
  13943. getRenderSize(): number;
  13944. /**
  13945. * Resize the texture to new value.
  13946. * @param size Define the new size the texture should have
  13947. * @param generateMipMaps Define whether the new texture should create mip maps
  13948. */
  13949. resize(size: number, generateMipMaps: boolean): void;
  13950. private _checkUniform;
  13951. /**
  13952. * Set a texture in the shader program used to render.
  13953. * @param name Define the name of the uniform samplers as defined in the shader
  13954. * @param texture Define the texture to bind to this sampler
  13955. * @return the texture itself allowing "fluent" like uniform updates
  13956. */
  13957. setTexture(name: string, texture: Texture): ProceduralTexture;
  13958. /**
  13959. * Set a float in the shader.
  13960. * @param name Define the name of the uniform as defined in the shader
  13961. * @param value Define the value to give to the uniform
  13962. * @return the texture itself allowing "fluent" like uniform updates
  13963. */
  13964. setFloat(name: string, value: number): ProceduralTexture;
  13965. /**
  13966. * Set a int in the shader.
  13967. * @param name Define the name of the uniform as defined in the shader
  13968. * @param value Define the value to give to the uniform
  13969. * @return the texture itself allowing "fluent" like uniform updates
  13970. */
  13971. setInt(name: string, value: number): ProceduralTexture;
  13972. /**
  13973. * Set an array of floats in the shader.
  13974. * @param name Define the name of the uniform as defined in the shader
  13975. * @param value Define the value to give to the uniform
  13976. * @return the texture itself allowing "fluent" like uniform updates
  13977. */
  13978. setFloats(name: string, value: number[]): ProceduralTexture;
  13979. /**
  13980. * Set a vec3 in the shader from a Color3.
  13981. * @param name Define the name of the uniform as defined in the shader
  13982. * @param value Define the value to give to the uniform
  13983. * @return the texture itself allowing "fluent" like uniform updates
  13984. */
  13985. setColor3(name: string, value: Color3): ProceduralTexture;
  13986. /**
  13987. * Set a vec4 in the shader from a Color4.
  13988. * @param name Define the name of the uniform as defined in the shader
  13989. * @param value Define the value to give to the uniform
  13990. * @return the texture itself allowing "fluent" like uniform updates
  13991. */
  13992. setColor4(name: string, value: Color4): ProceduralTexture;
  13993. /**
  13994. * Set a vec2 in the shader from a Vector2.
  13995. * @param name Define the name of the uniform as defined in the shader
  13996. * @param value Define the value to give to the uniform
  13997. * @return the texture itself allowing "fluent" like uniform updates
  13998. */
  13999. setVector2(name: string, value: Vector2): ProceduralTexture;
  14000. /**
  14001. * Set a vec3 in the shader from a Vector3.
  14002. * @param name Define the name of the uniform as defined in the shader
  14003. * @param value Define the value to give to the uniform
  14004. * @return the texture itself allowing "fluent" like uniform updates
  14005. */
  14006. setVector3(name: string, value: Vector3): ProceduralTexture;
  14007. /**
  14008. * Set a mat4 in the shader from a MAtrix.
  14009. * @param name Define the name of the uniform as defined in the shader
  14010. * @param value Define the value to give to the uniform
  14011. * @return the texture itself allowing "fluent" like uniform updates
  14012. */
  14013. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14014. /**
  14015. * Render the texture to its associated render target.
  14016. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14017. */
  14018. render(useCameraPostProcess?: boolean): void;
  14019. /**
  14020. * Clone the texture.
  14021. * @returns the cloned texture
  14022. */
  14023. clone(): ProceduralTexture;
  14024. /**
  14025. * Dispose the texture and release its asoociated resources.
  14026. */
  14027. dispose(): void;
  14028. }
  14029. }
  14030. declare module "babylonjs/Particles/baseParticleSystem" {
  14031. import { Nullable } from "babylonjs/types";
  14032. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14033. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14034. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14035. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14036. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14037. import { Scene } from "babylonjs/scene";
  14038. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14039. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14040. import { Texture } from "babylonjs/Materials/Textures/texture";
  14041. import { Animation } from "babylonjs/Animations/animation";
  14042. /**
  14043. * This represents the base class for particle system in Babylon.
  14044. * 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.
  14045. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14046. * @example https://doc.babylonjs.com/babylon101/particles
  14047. */
  14048. export class BaseParticleSystem {
  14049. /**
  14050. * Source color is added to the destination color without alpha affecting the result
  14051. */
  14052. static BLENDMODE_ONEONE: number;
  14053. /**
  14054. * Blend current color and particle color using particle’s alpha
  14055. */
  14056. static BLENDMODE_STANDARD: number;
  14057. /**
  14058. * Add current color and particle color multiplied by particle’s alpha
  14059. */
  14060. static BLENDMODE_ADD: number;
  14061. /**
  14062. * Multiply current color with particle color
  14063. */
  14064. static BLENDMODE_MULTIPLY: number;
  14065. /**
  14066. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14067. */
  14068. static BLENDMODE_MULTIPLYADD: number;
  14069. /**
  14070. * List of animations used by the particle system.
  14071. */
  14072. animations: Animation[];
  14073. /**
  14074. * The id of the Particle system.
  14075. */
  14076. id: string;
  14077. /**
  14078. * The friendly name of the Particle system.
  14079. */
  14080. name: string;
  14081. /**
  14082. * The rendering group used by the Particle system to chose when to render.
  14083. */
  14084. renderingGroupId: number;
  14085. /**
  14086. * The emitter represents the Mesh or position we are attaching the particle system to.
  14087. */
  14088. emitter: Nullable<AbstractMesh | Vector3>;
  14089. /**
  14090. * The maximum number of particles to emit per frame
  14091. */
  14092. emitRate: number;
  14093. /**
  14094. * If you want to launch only a few particles at once, that can be done, as well.
  14095. */
  14096. manualEmitCount: number;
  14097. /**
  14098. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14099. */
  14100. updateSpeed: number;
  14101. /**
  14102. * The amount of time the particle system is running (depends of the overall update speed).
  14103. */
  14104. targetStopDuration: number;
  14105. /**
  14106. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14107. */
  14108. disposeOnStop: boolean;
  14109. /**
  14110. * Minimum power of emitting particles.
  14111. */
  14112. minEmitPower: number;
  14113. /**
  14114. * Maximum power of emitting particles.
  14115. */
  14116. maxEmitPower: number;
  14117. /**
  14118. * Minimum life time of emitting particles.
  14119. */
  14120. minLifeTime: number;
  14121. /**
  14122. * Maximum life time of emitting particles.
  14123. */
  14124. maxLifeTime: number;
  14125. /**
  14126. * Minimum Size of emitting particles.
  14127. */
  14128. minSize: number;
  14129. /**
  14130. * Maximum Size of emitting particles.
  14131. */
  14132. maxSize: number;
  14133. /**
  14134. * Minimum scale of emitting particles on X axis.
  14135. */
  14136. minScaleX: number;
  14137. /**
  14138. * Maximum scale of emitting particles on X axis.
  14139. */
  14140. maxScaleX: number;
  14141. /**
  14142. * Minimum scale of emitting particles on Y axis.
  14143. */
  14144. minScaleY: number;
  14145. /**
  14146. * Maximum scale of emitting particles on Y axis.
  14147. */
  14148. maxScaleY: number;
  14149. /**
  14150. * Gets or sets the minimal initial rotation in radians.
  14151. */
  14152. minInitialRotation: number;
  14153. /**
  14154. * Gets or sets the maximal initial rotation in radians.
  14155. */
  14156. maxInitialRotation: number;
  14157. /**
  14158. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14159. */
  14160. minAngularSpeed: number;
  14161. /**
  14162. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14163. */
  14164. maxAngularSpeed: number;
  14165. /**
  14166. * The texture used to render each particle. (this can be a spritesheet)
  14167. */
  14168. particleTexture: Nullable<Texture>;
  14169. /**
  14170. * The layer mask we are rendering the particles through.
  14171. */
  14172. layerMask: number;
  14173. /**
  14174. * This can help using your own shader to render the particle system.
  14175. * The according effect will be created
  14176. */
  14177. customShader: any;
  14178. /**
  14179. * By default particle system starts as soon as they are created. This prevents the
  14180. * automatic start to happen and let you decide when to start emitting particles.
  14181. */
  14182. preventAutoStart: boolean;
  14183. private _noiseTexture;
  14184. /**
  14185. * Gets or sets a texture used to add random noise to particle positions
  14186. */
  14187. noiseTexture: Nullable<ProceduralTexture>;
  14188. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14189. noiseStrength: Vector3;
  14190. /**
  14191. * Callback triggered when the particle animation is ending.
  14192. */
  14193. onAnimationEnd: Nullable<() => void>;
  14194. /**
  14195. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14196. */
  14197. blendMode: number;
  14198. /**
  14199. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14200. * to override the particles.
  14201. */
  14202. forceDepthWrite: boolean;
  14203. /** 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 */
  14204. preWarmCycles: number;
  14205. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14206. preWarmStepOffset: number;
  14207. /**
  14208. * 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)
  14209. */
  14210. spriteCellChangeSpeed: number;
  14211. /**
  14212. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14213. */
  14214. startSpriteCellID: number;
  14215. /**
  14216. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14217. */
  14218. endSpriteCellID: number;
  14219. /**
  14220. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14221. */
  14222. spriteCellWidth: number;
  14223. /**
  14224. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14225. */
  14226. spriteCellHeight: number;
  14227. /**
  14228. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14229. */
  14230. spriteRandomStartCell: boolean;
  14231. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14232. translationPivot: Vector2;
  14233. /** @hidden */
  14234. protected _isAnimationSheetEnabled: boolean;
  14235. /**
  14236. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14237. */
  14238. beginAnimationOnStart: boolean;
  14239. /**
  14240. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14241. */
  14242. beginAnimationFrom: number;
  14243. /**
  14244. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14245. */
  14246. beginAnimationTo: number;
  14247. /**
  14248. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14249. */
  14250. beginAnimationLoop: boolean;
  14251. /**
  14252. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14253. */
  14254. isAnimationSheetEnabled: boolean;
  14255. /**
  14256. * Get hosting scene
  14257. * @returns the scene
  14258. */
  14259. getScene(): Scene;
  14260. /**
  14261. * You can use gravity if you want to give an orientation to your particles.
  14262. */
  14263. gravity: Vector3;
  14264. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14265. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14266. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14267. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14268. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14269. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14270. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14271. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14272. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14273. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14274. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14275. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14276. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14277. /**
  14278. * Defines the delay in milliseconds before starting the system (0 by default)
  14279. */
  14280. startDelay: number;
  14281. /**
  14282. * Gets the current list of drag gradients.
  14283. * You must use addDragGradient and removeDragGradient to udpate this list
  14284. * @returns the list of drag gradients
  14285. */
  14286. getDragGradients(): Nullable<Array<FactorGradient>>;
  14287. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14288. limitVelocityDamping: number;
  14289. /**
  14290. * Gets the current list of limit velocity gradients.
  14291. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14292. * @returns the list of limit velocity gradients
  14293. */
  14294. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14295. /**
  14296. * Gets the current list of color gradients.
  14297. * You must use addColorGradient and removeColorGradient to udpate this list
  14298. * @returns the list of color gradients
  14299. */
  14300. getColorGradients(): Nullable<Array<ColorGradient>>;
  14301. /**
  14302. * Gets the current list of size gradients.
  14303. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14304. * @returns the list of size gradients
  14305. */
  14306. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14307. /**
  14308. * Gets the current list of color remap gradients.
  14309. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14310. * @returns the list of color remap gradients
  14311. */
  14312. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14313. /**
  14314. * Gets the current list of alpha remap gradients.
  14315. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14316. * @returns the list of alpha remap gradients
  14317. */
  14318. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14319. /**
  14320. * Gets the current list of life time gradients.
  14321. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14322. * @returns the list of life time gradients
  14323. */
  14324. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14325. /**
  14326. * Gets the current list of angular speed gradients.
  14327. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14328. * @returns the list of angular speed gradients
  14329. */
  14330. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14331. /**
  14332. * Gets the current list of velocity gradients.
  14333. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14334. * @returns the list of velocity gradients
  14335. */
  14336. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14337. /**
  14338. * Gets the current list of start size gradients.
  14339. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14340. * @returns the list of start size gradients
  14341. */
  14342. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14343. /**
  14344. * Gets the current list of emit rate gradients.
  14345. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14346. * @returns the list of emit rate gradients
  14347. */
  14348. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14349. /**
  14350. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14351. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14352. */
  14353. direction1: Vector3;
  14354. /**
  14355. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14356. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14357. */
  14358. direction2: Vector3;
  14359. /**
  14360. * 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.
  14361. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14362. */
  14363. minEmitBox: Vector3;
  14364. /**
  14365. * 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.
  14366. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14367. */
  14368. maxEmitBox: Vector3;
  14369. /**
  14370. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14371. */
  14372. color1: Color4;
  14373. /**
  14374. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14375. */
  14376. color2: Color4;
  14377. /**
  14378. * Color the particle will have at the end of its lifetime
  14379. */
  14380. colorDead: Color4;
  14381. /**
  14382. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14383. */
  14384. textureMask: Color4;
  14385. /**
  14386. * The particle emitter type defines the emitter used by the particle system.
  14387. * It can be for example box, sphere, or cone...
  14388. */
  14389. particleEmitterType: IParticleEmitterType;
  14390. /** @hidden */
  14391. _isSubEmitter: boolean;
  14392. /**
  14393. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14394. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14395. */
  14396. billboardMode: number;
  14397. protected _isBillboardBased: boolean;
  14398. /**
  14399. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14400. */
  14401. isBillboardBased: boolean;
  14402. /**
  14403. * The scene the particle system belongs to.
  14404. */
  14405. protected _scene: Scene;
  14406. /**
  14407. * Local cache of defines for image processing.
  14408. */
  14409. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14410. /**
  14411. * Default configuration related to image processing available in the standard Material.
  14412. */
  14413. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14414. /**
  14415. * Gets the image processing configuration used either in this material.
  14416. */
  14417. /**
  14418. * Sets the Default image processing configuration used either in the this material.
  14419. *
  14420. * If sets to null, the scene one is in use.
  14421. */
  14422. imageProcessingConfiguration: ImageProcessingConfiguration;
  14423. /**
  14424. * Attaches a new image processing configuration to the Standard Material.
  14425. * @param configuration
  14426. */
  14427. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14428. /** @hidden */
  14429. protected _reset(): void;
  14430. /** @hidden */
  14431. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14432. /**
  14433. * Instantiates a particle system.
  14434. * 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.
  14435. * @param name The name of the particle system
  14436. */
  14437. constructor(name: string);
  14438. /**
  14439. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14440. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14441. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14442. * @returns the emitter
  14443. */
  14444. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14445. /**
  14446. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14447. * @param radius The radius of the hemisphere to emit from
  14448. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14449. * @returns the emitter
  14450. */
  14451. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14452. /**
  14453. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14454. * @param radius The radius of the sphere to emit from
  14455. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14456. * @returns the emitter
  14457. */
  14458. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14459. /**
  14460. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14461. * @param radius The radius of the sphere to emit from
  14462. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14463. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14464. * @returns the emitter
  14465. */
  14466. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14467. /**
  14468. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14469. * @param radius The radius of the emission cylinder
  14470. * @param height The height of the emission cylinder
  14471. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14472. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14473. * @returns the emitter
  14474. */
  14475. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14476. /**
  14477. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14478. * @param radius The radius of the cylinder to emit from
  14479. * @param height The height of the emission cylinder
  14480. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14481. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14482. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14483. * @returns the emitter
  14484. */
  14485. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14486. /**
  14487. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14488. * @param radius The radius of the cone to emit from
  14489. * @param angle The base angle of the cone
  14490. * @returns the emitter
  14491. */
  14492. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14493. /**
  14494. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14495. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14496. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14497. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14498. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14499. * @returns the emitter
  14500. */
  14501. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14502. }
  14503. }
  14504. declare module "babylonjs/Particles/subEmitter" {
  14505. import { Scene } from "babylonjs/scene";
  14506. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  14507. /**
  14508. * Type of sub emitter
  14509. */
  14510. export enum SubEmitterType {
  14511. /**
  14512. * Attached to the particle over it's lifetime
  14513. */
  14514. ATTACHED = 0,
  14515. /**
  14516. * Created when the particle dies
  14517. */
  14518. END = 1
  14519. }
  14520. /**
  14521. * Sub emitter class used to emit particles from an existing particle
  14522. */
  14523. export class SubEmitter {
  14524. /**
  14525. * the particle system to be used by the sub emitter
  14526. */
  14527. particleSystem: ParticleSystem;
  14528. /**
  14529. * Type of the submitter (Default: END)
  14530. */
  14531. type: SubEmitterType;
  14532. /**
  14533. * 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)
  14534. * Note: This only is supported when using an emitter of type Mesh
  14535. */
  14536. inheritDirection: boolean;
  14537. /**
  14538. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14539. */
  14540. inheritedVelocityAmount: number;
  14541. /**
  14542. * Creates a sub emitter
  14543. * @param particleSystem the particle system to be used by the sub emitter
  14544. */
  14545. constructor(
  14546. /**
  14547. * the particle system to be used by the sub emitter
  14548. */
  14549. particleSystem: ParticleSystem);
  14550. /**
  14551. * Clones the sub emitter
  14552. * @returns the cloned sub emitter
  14553. */
  14554. clone(): SubEmitter;
  14555. /**
  14556. * Serialize current object to a JSON object
  14557. * @returns the serialized object
  14558. */
  14559. serialize(): any;
  14560. /** @hidden */
  14561. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14562. /**
  14563. * Creates a new SubEmitter from a serialized JSON version
  14564. * @param serializationObject defines the JSON object to read from
  14565. * @param scene defines the hosting scene
  14566. * @param rootUrl defines the rootUrl for data loading
  14567. * @returns a new SubEmitter
  14568. */
  14569. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14570. /** Release associated resources */
  14571. dispose(): void;
  14572. }
  14573. }
  14574. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  14575. /** @hidden */
  14576. export var clipPlaneFragmentDeclaration: {
  14577. name: string;
  14578. shader: string;
  14579. };
  14580. }
  14581. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  14582. /** @hidden */
  14583. export var imageProcessingDeclaration: {
  14584. name: string;
  14585. shader: string;
  14586. };
  14587. }
  14588. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  14589. /** @hidden */
  14590. export var imageProcessingFunctions: {
  14591. name: string;
  14592. shader: string;
  14593. };
  14594. }
  14595. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  14596. /** @hidden */
  14597. export var clipPlaneFragment: {
  14598. name: string;
  14599. shader: string;
  14600. };
  14601. }
  14602. declare module "babylonjs/Shaders/particles.fragment" {
  14603. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  14604. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  14605. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  14606. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  14607. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  14608. /** @hidden */
  14609. export var particlesPixelShader: {
  14610. name: string;
  14611. shader: string;
  14612. };
  14613. }
  14614. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  14615. /** @hidden */
  14616. export var clipPlaneVertexDeclaration: {
  14617. name: string;
  14618. shader: string;
  14619. };
  14620. }
  14621. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  14622. /** @hidden */
  14623. export var clipPlaneVertex: {
  14624. name: string;
  14625. shader: string;
  14626. };
  14627. }
  14628. declare module "babylonjs/Shaders/particles.vertex" {
  14629. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  14630. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  14631. /** @hidden */
  14632. export var particlesVertexShader: {
  14633. name: string;
  14634. shader: string;
  14635. };
  14636. }
  14637. declare module "babylonjs/Particles/particleSystem" {
  14638. import { Nullable } from "babylonjs/types";
  14639. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  14640. import { Observable } from "babylonjs/Misc/observable";
  14641. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  14642. import { Effect } from "babylonjs/Materials/effect";
  14643. import { Scene, IDisposable } from "babylonjs/scene";
  14644. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  14645. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  14646. import { Particle } from "babylonjs/Particles/particle";
  14647. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  14648. import "babylonjs/Shaders/particles.fragment";
  14649. import "babylonjs/Shaders/particles.vertex";
  14650. /**
  14651. * This represents a particle system in Babylon.
  14652. * 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.
  14653. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14654. * @example https://doc.babylonjs.com/babylon101/particles
  14655. */
  14656. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14657. /**
  14658. * Billboard mode will only apply to Y axis
  14659. */
  14660. static readonly BILLBOARDMODE_Y: number;
  14661. /**
  14662. * Billboard mode will apply to all axes
  14663. */
  14664. static readonly BILLBOARDMODE_ALL: number;
  14665. /**
  14666. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14667. */
  14668. static readonly BILLBOARDMODE_STRETCHED: number;
  14669. /**
  14670. * This function can be defined to provide custom update for active particles.
  14671. * This function will be called instead of regular update (age, position, color, etc.).
  14672. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14673. */
  14674. updateFunction: (particles: Particle[]) => void;
  14675. private _emitterWorldMatrix;
  14676. /**
  14677. * This function can be defined to specify initial direction for every new particle.
  14678. * It by default use the emitterType defined function
  14679. */
  14680. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14681. /**
  14682. * This function can be defined to specify initial position for every new particle.
  14683. * It by default use the emitterType defined function
  14684. */
  14685. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14686. /**
  14687. * @hidden
  14688. */
  14689. _inheritedVelocityOffset: Vector3;
  14690. /**
  14691. * An event triggered when the system is disposed
  14692. */
  14693. onDisposeObservable: Observable<ParticleSystem>;
  14694. private _onDisposeObserver;
  14695. /**
  14696. * Sets a callback that will be triggered when the system is disposed
  14697. */
  14698. onDispose: () => void;
  14699. private _particles;
  14700. private _epsilon;
  14701. private _capacity;
  14702. private _stockParticles;
  14703. private _newPartsExcess;
  14704. private _vertexData;
  14705. private _vertexBuffer;
  14706. private _vertexBuffers;
  14707. private _spriteBuffer;
  14708. private _indexBuffer;
  14709. private _effect;
  14710. private _customEffect;
  14711. private _cachedDefines;
  14712. private _scaledColorStep;
  14713. private _colorDiff;
  14714. private _scaledDirection;
  14715. private _scaledGravity;
  14716. private _currentRenderId;
  14717. private _alive;
  14718. private _useInstancing;
  14719. private _started;
  14720. private _stopped;
  14721. private _actualFrame;
  14722. private _scaledUpdateSpeed;
  14723. private _vertexBufferSize;
  14724. /** @hidden */
  14725. _currentEmitRateGradient: Nullable<FactorGradient>;
  14726. /** @hidden */
  14727. _currentEmitRate1: number;
  14728. /** @hidden */
  14729. _currentEmitRate2: number;
  14730. /** @hidden */
  14731. _currentStartSizeGradient: Nullable<FactorGradient>;
  14732. /** @hidden */
  14733. _currentStartSize1: number;
  14734. /** @hidden */
  14735. _currentStartSize2: number;
  14736. private readonly _rawTextureWidth;
  14737. private _rampGradientsTexture;
  14738. private _useRampGradients;
  14739. /** Gets or sets a boolean indicating that ramp gradients must be used
  14740. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14741. */
  14742. useRampGradients: boolean;
  14743. /**
  14744. * 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.
  14745. * 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: [])
  14746. */
  14747. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14748. private _subEmitters;
  14749. /**
  14750. * @hidden
  14751. * If the particle systems emitter should be disposed when the particle system is disposed
  14752. */
  14753. _disposeEmitterOnDispose: boolean;
  14754. /**
  14755. * The current active Sub-systems, this property is used by the root particle system only.
  14756. */
  14757. activeSubSystems: Array<ParticleSystem>;
  14758. private _rootParticleSystem;
  14759. /**
  14760. * Gets the current list of active particles
  14761. */
  14762. readonly particles: Particle[];
  14763. /**
  14764. * Returns the string "ParticleSystem"
  14765. * @returns a string containing the class name
  14766. */
  14767. getClassName(): string;
  14768. /**
  14769. * Instantiates a particle system.
  14770. * 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.
  14771. * @param name The name of the particle system
  14772. * @param capacity The max number of particles alive at the same time
  14773. * @param scene The scene the particle system belongs to
  14774. * @param customEffect a custom effect used to change the way particles are rendered by default
  14775. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14776. * @param epsilon Offset used to render the particles
  14777. */
  14778. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14779. private _addFactorGradient;
  14780. private _removeFactorGradient;
  14781. /**
  14782. * Adds a new life time gradient
  14783. * @param gradient defines the gradient to use (between 0 and 1)
  14784. * @param factor defines the life time factor to affect to the specified gradient
  14785. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14786. * @returns the current particle system
  14787. */
  14788. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14789. /**
  14790. * Remove a specific life time gradient
  14791. * @param gradient defines the gradient to remove
  14792. * @returns the current particle system
  14793. */
  14794. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14795. /**
  14796. * Adds a new size gradient
  14797. * @param gradient defines the gradient to use (between 0 and 1)
  14798. * @param factor defines the size factor to affect to the specified gradient
  14799. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14800. * @returns the current particle system
  14801. */
  14802. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14803. /**
  14804. * Remove a specific size gradient
  14805. * @param gradient defines the gradient to remove
  14806. * @returns the current particle system
  14807. */
  14808. removeSizeGradient(gradient: number): IParticleSystem;
  14809. /**
  14810. * Adds a new color remap gradient
  14811. * @param gradient defines the gradient to use (between 0 and 1)
  14812. * @param min defines the color remap minimal range
  14813. * @param max defines the color remap maximal range
  14814. * @returns the current particle system
  14815. */
  14816. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14817. /**
  14818. * Remove a specific color remap gradient
  14819. * @param gradient defines the gradient to remove
  14820. * @returns the current particle system
  14821. */
  14822. removeColorRemapGradient(gradient: number): IParticleSystem;
  14823. /**
  14824. * Adds a new alpha remap gradient
  14825. * @param gradient defines the gradient to use (between 0 and 1)
  14826. * @param min defines the alpha remap minimal range
  14827. * @param max defines the alpha remap maximal range
  14828. * @returns the current particle system
  14829. */
  14830. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14831. /**
  14832. * Remove a specific alpha remap gradient
  14833. * @param gradient defines the gradient to remove
  14834. * @returns the current particle system
  14835. */
  14836. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  14837. /**
  14838. * Adds a new angular speed gradient
  14839. * @param gradient defines the gradient to use (between 0 and 1)
  14840. * @param factor defines the angular speed to affect to the specified gradient
  14841. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14842. * @returns the current particle system
  14843. */
  14844. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14845. /**
  14846. * Remove a specific angular speed gradient
  14847. * @param gradient defines the gradient to remove
  14848. * @returns the current particle system
  14849. */
  14850. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14851. /**
  14852. * Adds a new velocity gradient
  14853. * @param gradient defines the gradient to use (between 0 and 1)
  14854. * @param factor defines the velocity to affect to the specified gradient
  14855. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14856. * @returns the current particle system
  14857. */
  14858. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14859. /**
  14860. * Remove a specific velocity gradient
  14861. * @param gradient defines the gradient to remove
  14862. * @returns the current particle system
  14863. */
  14864. removeVelocityGradient(gradient: number): IParticleSystem;
  14865. /**
  14866. * Adds a new limit velocity gradient
  14867. * @param gradient defines the gradient to use (between 0 and 1)
  14868. * @param factor defines the limit velocity value to affect to the specified gradient
  14869. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14870. * @returns the current particle system
  14871. */
  14872. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14873. /**
  14874. * Remove a specific limit velocity gradient
  14875. * @param gradient defines the gradient to remove
  14876. * @returns the current particle system
  14877. */
  14878. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14879. /**
  14880. * Adds a new drag gradient
  14881. * @param gradient defines the gradient to use (between 0 and 1)
  14882. * @param factor defines the drag value to affect to the specified gradient
  14883. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14884. * @returns the current particle system
  14885. */
  14886. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14887. /**
  14888. * Remove a specific drag gradient
  14889. * @param gradient defines the gradient to remove
  14890. * @returns the current particle system
  14891. */
  14892. removeDragGradient(gradient: number): IParticleSystem;
  14893. /**
  14894. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14895. * @param gradient defines the gradient to use (between 0 and 1)
  14896. * @param factor defines the emit rate value to affect to the specified gradient
  14897. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14898. * @returns the current particle system
  14899. */
  14900. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14901. /**
  14902. * Remove a specific emit rate gradient
  14903. * @param gradient defines the gradient to remove
  14904. * @returns the current particle system
  14905. */
  14906. removeEmitRateGradient(gradient: number): IParticleSystem;
  14907. /**
  14908. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14909. * @param gradient defines the gradient to use (between 0 and 1)
  14910. * @param factor defines the start size value to affect to the specified gradient
  14911. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14912. * @returns the current particle system
  14913. */
  14914. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14915. /**
  14916. * Remove a specific start size gradient
  14917. * @param gradient defines the gradient to remove
  14918. * @returns the current particle system
  14919. */
  14920. removeStartSizeGradient(gradient: number): IParticleSystem;
  14921. private _createRampGradientTexture;
  14922. /**
  14923. * Gets the current list of ramp gradients.
  14924. * You must use addRampGradient and removeRampGradient to udpate this list
  14925. * @returns the list of ramp gradients
  14926. */
  14927. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14928. /**
  14929. * Adds a new ramp gradient used to remap particle colors
  14930. * @param gradient defines the gradient to use (between 0 and 1)
  14931. * @param color defines the color to affect to the specified gradient
  14932. * @returns the current particle system
  14933. */
  14934. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  14935. /**
  14936. * Remove a specific ramp gradient
  14937. * @param gradient defines the gradient to remove
  14938. * @returns the current particle system
  14939. */
  14940. removeRampGradient(gradient: number): ParticleSystem;
  14941. /**
  14942. * Adds a new color gradient
  14943. * @param gradient defines the gradient to use (between 0 and 1)
  14944. * @param color1 defines the color to affect to the specified gradient
  14945. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14946. * @returns this particle system
  14947. */
  14948. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14949. /**
  14950. * Remove a specific color gradient
  14951. * @param gradient defines the gradient to remove
  14952. * @returns this particle system
  14953. */
  14954. removeColorGradient(gradient: number): IParticleSystem;
  14955. private _fetchR;
  14956. protected _reset(): void;
  14957. private _resetEffect;
  14958. private _createVertexBuffers;
  14959. private _createIndexBuffer;
  14960. /**
  14961. * Gets the maximum number of particles active at the same time.
  14962. * @returns The max number of active particles.
  14963. */
  14964. getCapacity(): number;
  14965. /**
  14966. * Gets whether there are still active particles in the system.
  14967. * @returns True if it is alive, otherwise false.
  14968. */
  14969. isAlive(): boolean;
  14970. /**
  14971. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14972. * @returns True if it has been started, otherwise false.
  14973. */
  14974. isStarted(): boolean;
  14975. private _prepareSubEmitterInternalArray;
  14976. /**
  14977. * Starts the particle system and begins to emit
  14978. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  14979. */
  14980. start(delay?: number): void;
  14981. /**
  14982. * Stops the particle system.
  14983. * @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.
  14984. */
  14985. stop(stopSubEmitters?: boolean): void;
  14986. /**
  14987. * Remove all active particles
  14988. */
  14989. reset(): void;
  14990. /**
  14991. * @hidden (for internal use only)
  14992. */
  14993. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  14994. /**
  14995. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  14996. * Its lifetime will start back at 0.
  14997. */
  14998. recycleParticle: (particle: Particle) => void;
  14999. private _stopSubEmitters;
  15000. private _createParticle;
  15001. private _removeFromRoot;
  15002. private _emitFromParticle;
  15003. private _update;
  15004. /** @hidden */
  15005. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15006. /** @hidden */
  15007. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15008. /** @hidden */
  15009. private _getEffect;
  15010. /**
  15011. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15012. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15013. */
  15014. animate(preWarmOnly?: boolean): void;
  15015. private _appendParticleVertices;
  15016. /**
  15017. * Rebuilds the particle system.
  15018. */
  15019. rebuild(): void;
  15020. /**
  15021. * Is this system ready to be used/rendered
  15022. * @return true if the system is ready
  15023. */
  15024. isReady(): boolean;
  15025. private _render;
  15026. /**
  15027. * Renders the particle system in its current state.
  15028. * @returns the current number of particles
  15029. */
  15030. render(): number;
  15031. /**
  15032. * Disposes the particle system and free the associated resources
  15033. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15034. */
  15035. dispose(disposeTexture?: boolean): void;
  15036. /**
  15037. * Clones the particle system.
  15038. * @param name The name of the cloned object
  15039. * @param newEmitter The new emitter to use
  15040. * @returns the cloned particle system
  15041. */
  15042. clone(name: string, newEmitter: any): ParticleSystem;
  15043. /**
  15044. * Serializes the particle system to a JSON object.
  15045. * @returns the JSON object
  15046. */
  15047. serialize(): any;
  15048. /** @hidden */
  15049. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15050. /** @hidden */
  15051. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15052. /**
  15053. * Parses a JSON object to create a particle system.
  15054. * @param parsedParticleSystem The JSON object to parse
  15055. * @param scene The scene to create the particle system in
  15056. * @param rootUrl The root url to use to load external dependencies like texture
  15057. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15058. * @returns the Parsed particle system
  15059. */
  15060. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15061. }
  15062. }
  15063. declare module "babylonjs/Particles/particle" {
  15064. import { Nullable } from "babylonjs/types";
  15065. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15066. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15067. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15068. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15069. /**
  15070. * A particle represents one of the element emitted by a particle system.
  15071. * This is mainly define by its coordinates, direction, velocity and age.
  15072. */
  15073. export class Particle {
  15074. /**
  15075. * The particle system the particle belongs to.
  15076. */
  15077. particleSystem: ParticleSystem;
  15078. private static _Count;
  15079. /**
  15080. * Unique ID of the particle
  15081. */
  15082. id: number;
  15083. /**
  15084. * The world position of the particle in the scene.
  15085. */
  15086. position: Vector3;
  15087. /**
  15088. * The world direction of the particle in the scene.
  15089. */
  15090. direction: Vector3;
  15091. /**
  15092. * The color of the particle.
  15093. */
  15094. color: Color4;
  15095. /**
  15096. * The color change of the particle per step.
  15097. */
  15098. colorStep: Color4;
  15099. /**
  15100. * Defines how long will the life of the particle be.
  15101. */
  15102. lifeTime: number;
  15103. /**
  15104. * The current age of the particle.
  15105. */
  15106. age: number;
  15107. /**
  15108. * The current size of the particle.
  15109. */
  15110. size: number;
  15111. /**
  15112. * The current scale of the particle.
  15113. */
  15114. scale: Vector2;
  15115. /**
  15116. * The current angle of the particle.
  15117. */
  15118. angle: number;
  15119. /**
  15120. * Defines how fast is the angle changing.
  15121. */
  15122. angularSpeed: number;
  15123. /**
  15124. * Defines the cell index used by the particle to be rendered from a sprite.
  15125. */
  15126. cellIndex: number;
  15127. /**
  15128. * The information required to support color remapping
  15129. */
  15130. remapData: Vector4;
  15131. /** @hidden */
  15132. _randomCellOffset?: number;
  15133. /** @hidden */
  15134. _initialDirection: Nullable<Vector3>;
  15135. /** @hidden */
  15136. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15137. /** @hidden */
  15138. _initialStartSpriteCellID: number;
  15139. /** @hidden */
  15140. _initialEndSpriteCellID: number;
  15141. /** @hidden */
  15142. _currentColorGradient: Nullable<ColorGradient>;
  15143. /** @hidden */
  15144. _currentColor1: Color4;
  15145. /** @hidden */
  15146. _currentColor2: Color4;
  15147. /** @hidden */
  15148. _currentSizeGradient: Nullable<FactorGradient>;
  15149. /** @hidden */
  15150. _currentSize1: number;
  15151. /** @hidden */
  15152. _currentSize2: number;
  15153. /** @hidden */
  15154. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15155. /** @hidden */
  15156. _currentAngularSpeed1: number;
  15157. /** @hidden */
  15158. _currentAngularSpeed2: number;
  15159. /** @hidden */
  15160. _currentVelocityGradient: Nullable<FactorGradient>;
  15161. /** @hidden */
  15162. _currentVelocity1: number;
  15163. /** @hidden */
  15164. _currentVelocity2: number;
  15165. /** @hidden */
  15166. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15167. /** @hidden */
  15168. _currentLimitVelocity1: number;
  15169. /** @hidden */
  15170. _currentLimitVelocity2: number;
  15171. /** @hidden */
  15172. _currentDragGradient: Nullable<FactorGradient>;
  15173. /** @hidden */
  15174. _currentDrag1: number;
  15175. /** @hidden */
  15176. _currentDrag2: number;
  15177. /** @hidden */
  15178. _randomNoiseCoordinates1: Vector3;
  15179. /** @hidden */
  15180. _randomNoiseCoordinates2: Vector3;
  15181. /**
  15182. * Creates a new instance Particle
  15183. * @param particleSystem the particle system the particle belongs to
  15184. */
  15185. constructor(
  15186. /**
  15187. * The particle system the particle belongs to.
  15188. */
  15189. particleSystem: ParticleSystem);
  15190. private updateCellInfoFromSystem;
  15191. /**
  15192. * Defines how the sprite cell index is updated for the particle
  15193. */
  15194. updateCellIndex(): void;
  15195. /** @hidden */
  15196. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15197. /** @hidden */
  15198. _inheritParticleInfoToSubEmitters(): void;
  15199. /** @hidden */
  15200. _reset(): void;
  15201. /**
  15202. * Copy the properties of particle to another one.
  15203. * @param other the particle to copy the information to.
  15204. */
  15205. copyTo(other: Particle): void;
  15206. }
  15207. }
  15208. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15209. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15210. import { Effect } from "babylonjs/Materials/effect";
  15211. import { Particle } from "babylonjs/Particles/particle";
  15212. /**
  15213. * Particle emitter represents a volume emitting particles.
  15214. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15215. */
  15216. export interface IParticleEmitterType {
  15217. /**
  15218. * Called by the particle System when the direction is computed for the created particle.
  15219. * @param worldMatrix is the world matrix of the particle system
  15220. * @param directionToUpdate is the direction vector to update with the result
  15221. * @param particle is the particle we are computed the direction for
  15222. */
  15223. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15224. /**
  15225. * Called by the particle System when the position is computed for the created particle.
  15226. * @param worldMatrix is the world matrix of the particle system
  15227. * @param positionToUpdate is the position vector to update with the result
  15228. * @param particle is the particle we are computed the position for
  15229. */
  15230. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15231. /**
  15232. * Clones the current emitter and returns a copy of it
  15233. * @returns the new emitter
  15234. */
  15235. clone(): IParticleEmitterType;
  15236. /**
  15237. * Called by the GPUParticleSystem to setup the update shader
  15238. * @param effect defines the update shader
  15239. */
  15240. applyToShader(effect: Effect): void;
  15241. /**
  15242. * Returns a string to use to update the GPU particles update shader
  15243. * @returns the effect defines string
  15244. */
  15245. getEffectDefines(): string;
  15246. /**
  15247. * Returns a string representing the class name
  15248. * @returns a string containing the class name
  15249. */
  15250. getClassName(): string;
  15251. /**
  15252. * Serializes the particle system to a JSON object.
  15253. * @returns the JSON object
  15254. */
  15255. serialize(): any;
  15256. /**
  15257. * Parse properties from a JSON object
  15258. * @param serializationObject defines the JSON object
  15259. */
  15260. parse(serializationObject: any): void;
  15261. }
  15262. }
  15263. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15264. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15265. import { Effect } from "babylonjs/Materials/effect";
  15266. import { Particle } from "babylonjs/Particles/particle";
  15267. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15268. /**
  15269. * Particle emitter emitting particles from the inside of a box.
  15270. * It emits the particles randomly between 2 given directions.
  15271. */
  15272. export class BoxParticleEmitter implements IParticleEmitterType {
  15273. /**
  15274. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15275. */
  15276. direction1: Vector3;
  15277. /**
  15278. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15279. */
  15280. direction2: Vector3;
  15281. /**
  15282. * 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.
  15283. */
  15284. minEmitBox: Vector3;
  15285. /**
  15286. * 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.
  15287. */
  15288. maxEmitBox: Vector3;
  15289. /**
  15290. * Creates a new instance BoxParticleEmitter
  15291. */
  15292. constructor();
  15293. /**
  15294. * Called by the particle System when the direction is computed for the created particle.
  15295. * @param worldMatrix is the world matrix of the particle system
  15296. * @param directionToUpdate is the direction vector to update with the result
  15297. * @param particle is the particle we are computed the direction for
  15298. */
  15299. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15300. /**
  15301. * Called by the particle System when the position is computed for the created particle.
  15302. * @param worldMatrix is the world matrix of the particle system
  15303. * @param positionToUpdate is the position vector to update with the result
  15304. * @param particle is the particle we are computed the position for
  15305. */
  15306. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15307. /**
  15308. * Clones the current emitter and returns a copy of it
  15309. * @returns the new emitter
  15310. */
  15311. clone(): BoxParticleEmitter;
  15312. /**
  15313. * Called by the GPUParticleSystem to setup the update shader
  15314. * @param effect defines the update shader
  15315. */
  15316. applyToShader(effect: Effect): void;
  15317. /**
  15318. * Returns a string to use to update the GPU particles update shader
  15319. * @returns a string containng the defines string
  15320. */
  15321. getEffectDefines(): string;
  15322. /**
  15323. * Returns the string "BoxParticleEmitter"
  15324. * @returns a string containing the class name
  15325. */
  15326. getClassName(): string;
  15327. /**
  15328. * Serializes the particle system to a JSON object.
  15329. * @returns the JSON object
  15330. */
  15331. serialize(): any;
  15332. /**
  15333. * Parse properties from a JSON object
  15334. * @param serializationObject defines the JSON object
  15335. */
  15336. parse(serializationObject: any): void;
  15337. }
  15338. }
  15339. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  15340. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15341. import { Effect } from "babylonjs/Materials/effect";
  15342. import { Particle } from "babylonjs/Particles/particle";
  15343. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15344. /**
  15345. * Particle emitter emitting particles from the inside of a cone.
  15346. * It emits the particles alongside the cone volume from the base to the particle.
  15347. * The emission direction might be randomized.
  15348. */
  15349. export class ConeParticleEmitter implements IParticleEmitterType {
  15350. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15351. directionRandomizer: number;
  15352. private _radius;
  15353. private _angle;
  15354. private _height;
  15355. /**
  15356. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15357. */
  15358. radiusRange: number;
  15359. /**
  15360. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15361. */
  15362. heightRange: number;
  15363. /**
  15364. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15365. */
  15366. emitFromSpawnPointOnly: boolean;
  15367. /**
  15368. * Gets or sets the radius of the emission cone
  15369. */
  15370. radius: number;
  15371. /**
  15372. * Gets or sets the angle of the emission cone
  15373. */
  15374. angle: number;
  15375. private _buildHeight;
  15376. /**
  15377. * Creates a new instance ConeParticleEmitter
  15378. * @param radius the radius of the emission cone (1 by default)
  15379. * @param angle the cone base angle (PI by default)
  15380. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15381. */
  15382. constructor(radius?: number, angle?: number,
  15383. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15384. directionRandomizer?: number);
  15385. /**
  15386. * Called by the particle System when the direction is computed for the created particle.
  15387. * @param worldMatrix is the world matrix of the particle system
  15388. * @param directionToUpdate is the direction vector to update with the result
  15389. * @param particle is the particle we are computed the direction for
  15390. */
  15391. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15392. /**
  15393. * Called by the particle System when the position is computed for the created particle.
  15394. * @param worldMatrix is the world matrix of the particle system
  15395. * @param positionToUpdate is the position vector to update with the result
  15396. * @param particle is the particle we are computed the position for
  15397. */
  15398. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15399. /**
  15400. * Clones the current emitter and returns a copy of it
  15401. * @returns the new emitter
  15402. */
  15403. clone(): ConeParticleEmitter;
  15404. /**
  15405. * Called by the GPUParticleSystem to setup the update shader
  15406. * @param effect defines the update shader
  15407. */
  15408. applyToShader(effect: Effect): void;
  15409. /**
  15410. * Returns a string to use to update the GPU particles update shader
  15411. * @returns a string containng the defines string
  15412. */
  15413. getEffectDefines(): string;
  15414. /**
  15415. * Returns the string "ConeParticleEmitter"
  15416. * @returns a string containing the class name
  15417. */
  15418. getClassName(): string;
  15419. /**
  15420. * Serializes the particle system to a JSON object.
  15421. * @returns the JSON object
  15422. */
  15423. serialize(): any;
  15424. /**
  15425. * Parse properties from a JSON object
  15426. * @param serializationObject defines the JSON object
  15427. */
  15428. parse(serializationObject: any): void;
  15429. }
  15430. }
  15431. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  15432. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15433. import { Effect } from "babylonjs/Materials/effect";
  15434. import { Particle } from "babylonjs/Particles/particle";
  15435. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15436. /**
  15437. * Particle emitter emitting particles from the inside of a cylinder.
  15438. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15439. */
  15440. export class CylinderParticleEmitter implements IParticleEmitterType {
  15441. /**
  15442. * The radius of the emission cylinder.
  15443. */
  15444. radius: number;
  15445. /**
  15446. * The height of the emission cylinder.
  15447. */
  15448. height: number;
  15449. /**
  15450. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15451. */
  15452. radiusRange: number;
  15453. /**
  15454. * How much to randomize the particle direction [0-1].
  15455. */
  15456. directionRandomizer: number;
  15457. /**
  15458. * Creates a new instance CylinderParticleEmitter
  15459. * @param radius the radius of the emission cylinder (1 by default)
  15460. * @param height the height of the emission cylinder (1 by default)
  15461. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15462. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15463. */
  15464. constructor(
  15465. /**
  15466. * The radius of the emission cylinder.
  15467. */
  15468. radius?: number,
  15469. /**
  15470. * The height of the emission cylinder.
  15471. */
  15472. height?: number,
  15473. /**
  15474. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15475. */
  15476. radiusRange?: number,
  15477. /**
  15478. * How much to randomize the particle direction [0-1].
  15479. */
  15480. directionRandomizer?: number);
  15481. /**
  15482. * Called by the particle System when the direction is computed for the created particle.
  15483. * @param worldMatrix is the world matrix of the particle system
  15484. * @param directionToUpdate is the direction vector to update with the result
  15485. * @param particle is the particle we are computed the direction for
  15486. */
  15487. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15488. /**
  15489. * Called by the particle System when the position is computed for the created particle.
  15490. * @param worldMatrix is the world matrix of the particle system
  15491. * @param positionToUpdate is the position vector to update with the result
  15492. * @param particle is the particle we are computed the position for
  15493. */
  15494. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15495. /**
  15496. * Clones the current emitter and returns a copy of it
  15497. * @returns the new emitter
  15498. */
  15499. clone(): CylinderParticleEmitter;
  15500. /**
  15501. * Called by the GPUParticleSystem to setup the update shader
  15502. * @param effect defines the update shader
  15503. */
  15504. applyToShader(effect: Effect): void;
  15505. /**
  15506. * Returns a string to use to update the GPU particles update shader
  15507. * @returns a string containng the defines string
  15508. */
  15509. getEffectDefines(): string;
  15510. /**
  15511. * Returns the string "CylinderParticleEmitter"
  15512. * @returns a string containing the class name
  15513. */
  15514. getClassName(): string;
  15515. /**
  15516. * Serializes the particle system to a JSON object.
  15517. * @returns the JSON object
  15518. */
  15519. serialize(): any;
  15520. /**
  15521. * Parse properties from a JSON object
  15522. * @param serializationObject defines the JSON object
  15523. */
  15524. parse(serializationObject: any): void;
  15525. }
  15526. /**
  15527. * Particle emitter emitting particles from the inside of a cylinder.
  15528. * It emits the particles randomly between two vectors.
  15529. */
  15530. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15531. /**
  15532. * The min limit of the emission direction.
  15533. */
  15534. direction1: Vector3;
  15535. /**
  15536. * The max limit of the emission direction.
  15537. */
  15538. direction2: Vector3;
  15539. /**
  15540. * Creates a new instance CylinderDirectedParticleEmitter
  15541. * @param radius the radius of the emission cylinder (1 by default)
  15542. * @param height the height of the emission cylinder (1 by default)
  15543. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15544. * @param direction1 the min limit of the emission direction (up vector by default)
  15545. * @param direction2 the max limit of the emission direction (up vector by default)
  15546. */
  15547. constructor(radius?: number, height?: number, radiusRange?: number,
  15548. /**
  15549. * The min limit of the emission direction.
  15550. */
  15551. direction1?: Vector3,
  15552. /**
  15553. * The max limit of the emission direction.
  15554. */
  15555. direction2?: Vector3);
  15556. /**
  15557. * Called by the particle System when the direction is computed for the created particle.
  15558. * @param worldMatrix is the world matrix of the particle system
  15559. * @param directionToUpdate is the direction vector to update with the result
  15560. * @param particle is the particle we are computed the direction for
  15561. */
  15562. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15563. /**
  15564. * Clones the current emitter and returns a copy of it
  15565. * @returns the new emitter
  15566. */
  15567. clone(): CylinderDirectedParticleEmitter;
  15568. /**
  15569. * Called by the GPUParticleSystem to setup the update shader
  15570. * @param effect defines the update shader
  15571. */
  15572. applyToShader(effect: Effect): void;
  15573. /**
  15574. * Returns a string to use to update the GPU particles update shader
  15575. * @returns a string containng the defines string
  15576. */
  15577. getEffectDefines(): string;
  15578. /**
  15579. * Returns the string "CylinderDirectedParticleEmitter"
  15580. * @returns a string containing the class name
  15581. */
  15582. getClassName(): string;
  15583. /**
  15584. * Serializes the particle system to a JSON object.
  15585. * @returns the JSON object
  15586. */
  15587. serialize(): any;
  15588. /**
  15589. * Parse properties from a JSON object
  15590. * @param serializationObject defines the JSON object
  15591. */
  15592. parse(serializationObject: any): void;
  15593. }
  15594. }
  15595. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  15596. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15597. import { Effect } from "babylonjs/Materials/effect";
  15598. import { Particle } from "babylonjs/Particles/particle";
  15599. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15600. /**
  15601. * Particle emitter emitting particles from the inside of a hemisphere.
  15602. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15603. */
  15604. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15605. /**
  15606. * The radius of the emission hemisphere.
  15607. */
  15608. radius: number;
  15609. /**
  15610. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15611. */
  15612. radiusRange: number;
  15613. /**
  15614. * How much to randomize the particle direction [0-1].
  15615. */
  15616. directionRandomizer: number;
  15617. /**
  15618. * Creates a new instance HemisphericParticleEmitter
  15619. * @param radius the radius of the emission hemisphere (1 by default)
  15620. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15621. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15622. */
  15623. constructor(
  15624. /**
  15625. * The radius of the emission hemisphere.
  15626. */
  15627. radius?: number,
  15628. /**
  15629. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15630. */
  15631. radiusRange?: number,
  15632. /**
  15633. * How much to randomize the particle direction [0-1].
  15634. */
  15635. directionRandomizer?: number);
  15636. /**
  15637. * Called by the particle System when the direction is computed for the created particle.
  15638. * @param worldMatrix is the world matrix of the particle system
  15639. * @param directionToUpdate is the direction vector to update with the result
  15640. * @param particle is the particle we are computed the direction for
  15641. */
  15642. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15643. /**
  15644. * Called by the particle System when the position is computed for the created particle.
  15645. * @param worldMatrix is the world matrix of the particle system
  15646. * @param positionToUpdate is the position vector to update with the result
  15647. * @param particle is the particle we are computed the position for
  15648. */
  15649. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15650. /**
  15651. * Clones the current emitter and returns a copy of it
  15652. * @returns the new emitter
  15653. */
  15654. clone(): HemisphericParticleEmitter;
  15655. /**
  15656. * Called by the GPUParticleSystem to setup the update shader
  15657. * @param effect defines the update shader
  15658. */
  15659. applyToShader(effect: Effect): void;
  15660. /**
  15661. * Returns a string to use to update the GPU particles update shader
  15662. * @returns a string containng the defines string
  15663. */
  15664. getEffectDefines(): string;
  15665. /**
  15666. * Returns the string "HemisphericParticleEmitter"
  15667. * @returns a string containing the class name
  15668. */
  15669. getClassName(): string;
  15670. /**
  15671. * Serializes the particle system to a JSON object.
  15672. * @returns the JSON object
  15673. */
  15674. serialize(): any;
  15675. /**
  15676. * Parse properties from a JSON object
  15677. * @param serializationObject defines the JSON object
  15678. */
  15679. parse(serializationObject: any): void;
  15680. }
  15681. }
  15682. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  15683. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15684. import { Effect } from "babylonjs/Materials/effect";
  15685. import { Particle } from "babylonjs/Particles/particle";
  15686. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15687. /**
  15688. * Particle emitter emitting particles from a point.
  15689. * It emits the particles randomly between 2 given directions.
  15690. */
  15691. export class PointParticleEmitter implements IParticleEmitterType {
  15692. /**
  15693. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15694. */
  15695. direction1: Vector3;
  15696. /**
  15697. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15698. */
  15699. direction2: Vector3;
  15700. /**
  15701. * Creates a new instance PointParticleEmitter
  15702. */
  15703. constructor();
  15704. /**
  15705. * Called by the particle System when the direction is computed for the created particle.
  15706. * @param worldMatrix is the world matrix of the particle system
  15707. * @param directionToUpdate is the direction vector to update with the result
  15708. * @param particle is the particle we are computed the direction for
  15709. */
  15710. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15711. /**
  15712. * Called by the particle System when the position is computed for the created particle.
  15713. * @param worldMatrix is the world matrix of the particle system
  15714. * @param positionToUpdate is the position vector to update with the result
  15715. * @param particle is the particle we are computed the position for
  15716. */
  15717. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15718. /**
  15719. * Clones the current emitter and returns a copy of it
  15720. * @returns the new emitter
  15721. */
  15722. clone(): PointParticleEmitter;
  15723. /**
  15724. * Called by the GPUParticleSystem to setup the update shader
  15725. * @param effect defines the update shader
  15726. */
  15727. applyToShader(effect: Effect): void;
  15728. /**
  15729. * Returns a string to use to update the GPU particles update shader
  15730. * @returns a string containng the defines string
  15731. */
  15732. getEffectDefines(): string;
  15733. /**
  15734. * Returns the string "PointParticleEmitter"
  15735. * @returns a string containing the class name
  15736. */
  15737. getClassName(): string;
  15738. /**
  15739. * Serializes the particle system to a JSON object.
  15740. * @returns the JSON object
  15741. */
  15742. serialize(): any;
  15743. /**
  15744. * Parse properties from a JSON object
  15745. * @param serializationObject defines the JSON object
  15746. */
  15747. parse(serializationObject: any): void;
  15748. }
  15749. }
  15750. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  15751. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15752. import { Effect } from "babylonjs/Materials/effect";
  15753. import { Particle } from "babylonjs/Particles/particle";
  15754. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15755. /**
  15756. * Particle emitter emitting particles from the inside of a sphere.
  15757. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15758. */
  15759. export class SphereParticleEmitter implements IParticleEmitterType {
  15760. /**
  15761. * The radius of the emission sphere.
  15762. */
  15763. radius: number;
  15764. /**
  15765. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15766. */
  15767. radiusRange: number;
  15768. /**
  15769. * How much to randomize the particle direction [0-1].
  15770. */
  15771. directionRandomizer: number;
  15772. /**
  15773. * Creates a new instance SphereParticleEmitter
  15774. * @param radius the radius of the emission sphere (1 by default)
  15775. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15776. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15777. */
  15778. constructor(
  15779. /**
  15780. * The radius of the emission sphere.
  15781. */
  15782. radius?: number,
  15783. /**
  15784. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15785. */
  15786. radiusRange?: number,
  15787. /**
  15788. * How much to randomize the particle direction [0-1].
  15789. */
  15790. directionRandomizer?: number);
  15791. /**
  15792. * Called by the particle System when the direction is computed for the created particle.
  15793. * @param worldMatrix is the world matrix of the particle system
  15794. * @param directionToUpdate is the direction vector to update with the result
  15795. * @param particle is the particle we are computed the direction for
  15796. */
  15797. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15798. /**
  15799. * Called by the particle System when the position is computed for the created particle.
  15800. * @param worldMatrix is the world matrix of the particle system
  15801. * @param positionToUpdate is the position vector to update with the result
  15802. * @param particle is the particle we are computed the position for
  15803. */
  15804. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15805. /**
  15806. * Clones the current emitter and returns a copy of it
  15807. * @returns the new emitter
  15808. */
  15809. clone(): SphereParticleEmitter;
  15810. /**
  15811. * Called by the GPUParticleSystem to setup the update shader
  15812. * @param effect defines the update shader
  15813. */
  15814. applyToShader(effect: Effect): void;
  15815. /**
  15816. * Returns a string to use to update the GPU particles update shader
  15817. * @returns a string containng the defines string
  15818. */
  15819. getEffectDefines(): string;
  15820. /**
  15821. * Returns the string "SphereParticleEmitter"
  15822. * @returns a string containing the class name
  15823. */
  15824. getClassName(): string;
  15825. /**
  15826. * Serializes the particle system to a JSON object.
  15827. * @returns the JSON object
  15828. */
  15829. serialize(): any;
  15830. /**
  15831. * Parse properties from a JSON object
  15832. * @param serializationObject defines the JSON object
  15833. */
  15834. parse(serializationObject: any): void;
  15835. }
  15836. /**
  15837. * Particle emitter emitting particles from the inside of a sphere.
  15838. * It emits the particles randomly between two vectors.
  15839. */
  15840. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  15841. /**
  15842. * The min limit of the emission direction.
  15843. */
  15844. direction1: Vector3;
  15845. /**
  15846. * The max limit of the emission direction.
  15847. */
  15848. direction2: Vector3;
  15849. /**
  15850. * Creates a new instance SphereDirectedParticleEmitter
  15851. * @param radius the radius of the emission sphere (1 by default)
  15852. * @param direction1 the min limit of the emission direction (up vector by default)
  15853. * @param direction2 the max limit of the emission direction (up vector by default)
  15854. */
  15855. constructor(radius?: number,
  15856. /**
  15857. * The min limit of the emission direction.
  15858. */
  15859. direction1?: Vector3,
  15860. /**
  15861. * The max limit of the emission direction.
  15862. */
  15863. direction2?: Vector3);
  15864. /**
  15865. * Called by the particle System when the direction is computed for the created particle.
  15866. * @param worldMatrix is the world matrix of the particle system
  15867. * @param directionToUpdate is the direction vector to update with the result
  15868. * @param particle is the particle we are computed the direction for
  15869. */
  15870. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15871. /**
  15872. * Clones the current emitter and returns a copy of it
  15873. * @returns the new emitter
  15874. */
  15875. clone(): SphereDirectedParticleEmitter;
  15876. /**
  15877. * Called by the GPUParticleSystem to setup the update shader
  15878. * @param effect defines the update shader
  15879. */
  15880. applyToShader(effect: Effect): void;
  15881. /**
  15882. * Returns a string to use to update the GPU particles update shader
  15883. * @returns a string containng the defines string
  15884. */
  15885. getEffectDefines(): string;
  15886. /**
  15887. * Returns the string "SphereDirectedParticleEmitter"
  15888. * @returns a string containing the class name
  15889. */
  15890. getClassName(): string;
  15891. /**
  15892. * Serializes the particle system to a JSON object.
  15893. * @returns the JSON object
  15894. */
  15895. serialize(): any;
  15896. /**
  15897. * Parse properties from a JSON object
  15898. * @param serializationObject defines the JSON object
  15899. */
  15900. parse(serializationObject: any): void;
  15901. }
  15902. }
  15903. declare module "babylonjs/Particles/EmitterTypes/index" {
  15904. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  15905. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  15906. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  15907. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  15908. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15909. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  15910. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  15911. }
  15912. declare module "babylonjs/Particles/IParticleSystem" {
  15913. import { Nullable } from "babylonjs/types";
  15914. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  15915. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15916. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15917. import { Texture } from "babylonjs/Materials/Textures/texture";
  15918. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  15919. import { Scene } from "babylonjs/scene";
  15920. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  15921. import { Animation } from "babylonjs/Animations/animation";
  15922. /**
  15923. * Interface representing a particle system in Babylon.js.
  15924. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  15925. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  15926. */
  15927. export interface IParticleSystem {
  15928. /**
  15929. * List of animations used by the particle system.
  15930. */
  15931. animations: Animation[];
  15932. /**
  15933. * The id of the Particle system.
  15934. */
  15935. id: string;
  15936. /**
  15937. * The name of the Particle system.
  15938. */
  15939. name: string;
  15940. /**
  15941. * The emitter represents the Mesh or position we are attaching the particle system to.
  15942. */
  15943. emitter: Nullable<AbstractMesh | Vector3>;
  15944. /**
  15945. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15946. */
  15947. isBillboardBased: boolean;
  15948. /**
  15949. * The rendering group used by the Particle system to chose when to render.
  15950. */
  15951. renderingGroupId: number;
  15952. /**
  15953. * The layer mask we are rendering the particles through.
  15954. */
  15955. layerMask: number;
  15956. /**
  15957. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  15958. */
  15959. updateSpeed: number;
  15960. /**
  15961. * The amount of time the particle system is running (depends of the overall update speed).
  15962. */
  15963. targetStopDuration: number;
  15964. /**
  15965. * The texture used to render each particle. (this can be a spritesheet)
  15966. */
  15967. particleTexture: Nullable<Texture>;
  15968. /**
  15969. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  15970. */
  15971. blendMode: number;
  15972. /**
  15973. * Minimum life time of emitting particles.
  15974. */
  15975. minLifeTime: number;
  15976. /**
  15977. * Maximum life time of emitting particles.
  15978. */
  15979. maxLifeTime: number;
  15980. /**
  15981. * Minimum Size of emitting particles.
  15982. */
  15983. minSize: number;
  15984. /**
  15985. * Maximum Size of emitting particles.
  15986. */
  15987. maxSize: number;
  15988. /**
  15989. * Minimum scale of emitting particles on X axis.
  15990. */
  15991. minScaleX: number;
  15992. /**
  15993. * Maximum scale of emitting particles on X axis.
  15994. */
  15995. maxScaleX: number;
  15996. /**
  15997. * Minimum scale of emitting particles on Y axis.
  15998. */
  15999. minScaleY: number;
  16000. /**
  16001. * Maximum scale of emitting particles on Y axis.
  16002. */
  16003. maxScaleY: number;
  16004. /**
  16005. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16006. */
  16007. color1: Color4;
  16008. /**
  16009. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16010. */
  16011. color2: Color4;
  16012. /**
  16013. * Color the particle will have at the end of its lifetime.
  16014. */
  16015. colorDead: Color4;
  16016. /**
  16017. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16018. */
  16019. emitRate: number;
  16020. /**
  16021. * You can use gravity if you want to give an orientation to your particles.
  16022. */
  16023. gravity: Vector3;
  16024. /**
  16025. * Minimum power of emitting particles.
  16026. */
  16027. minEmitPower: number;
  16028. /**
  16029. * Maximum power of emitting particles.
  16030. */
  16031. maxEmitPower: number;
  16032. /**
  16033. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16034. */
  16035. minAngularSpeed: number;
  16036. /**
  16037. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16038. */
  16039. maxAngularSpeed: number;
  16040. /**
  16041. * Gets or sets the minimal initial rotation in radians.
  16042. */
  16043. minInitialRotation: number;
  16044. /**
  16045. * Gets or sets the maximal initial rotation in radians.
  16046. */
  16047. maxInitialRotation: number;
  16048. /**
  16049. * The particle emitter type defines the emitter used by the particle system.
  16050. * It can be for example box, sphere, or cone...
  16051. */
  16052. particleEmitterType: Nullable<IParticleEmitterType>;
  16053. /**
  16054. * Defines the delay in milliseconds before starting the system (0 by default)
  16055. */
  16056. startDelay: number;
  16057. /**
  16058. * 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
  16059. */
  16060. preWarmCycles: number;
  16061. /**
  16062. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16063. */
  16064. preWarmStepOffset: number;
  16065. /**
  16066. * 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)
  16067. */
  16068. spriteCellChangeSpeed: number;
  16069. /**
  16070. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16071. */
  16072. startSpriteCellID: number;
  16073. /**
  16074. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16075. */
  16076. endSpriteCellID: number;
  16077. /**
  16078. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16079. */
  16080. spriteCellWidth: number;
  16081. /**
  16082. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16083. */
  16084. spriteCellHeight: number;
  16085. /**
  16086. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16087. */
  16088. spriteRandomStartCell: boolean;
  16089. /**
  16090. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16091. */
  16092. isAnimationSheetEnabled: boolean;
  16093. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16094. translationPivot: Vector2;
  16095. /**
  16096. * Gets or sets a texture used to add random noise to particle positions
  16097. */
  16098. noiseTexture: Nullable<BaseTexture>;
  16099. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16100. noiseStrength: Vector3;
  16101. /**
  16102. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16103. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16104. */
  16105. billboardMode: number;
  16106. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16107. limitVelocityDamping: number;
  16108. /**
  16109. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16110. */
  16111. beginAnimationOnStart: boolean;
  16112. /**
  16113. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16114. */
  16115. beginAnimationFrom: number;
  16116. /**
  16117. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16118. */
  16119. beginAnimationTo: number;
  16120. /**
  16121. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16122. */
  16123. beginAnimationLoop: boolean;
  16124. /**
  16125. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16126. */
  16127. disposeOnStop: boolean;
  16128. /**
  16129. * Gets the maximum number of particles active at the same time.
  16130. * @returns The max number of active particles.
  16131. */
  16132. getCapacity(): number;
  16133. /**
  16134. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16135. * @returns True if it has been started, otherwise false.
  16136. */
  16137. isStarted(): boolean;
  16138. /**
  16139. * Animates the particle system for this frame.
  16140. */
  16141. animate(): void;
  16142. /**
  16143. * Renders the particle system in its current state.
  16144. * @returns the current number of particles
  16145. */
  16146. render(): number;
  16147. /**
  16148. * Dispose the particle system and frees its associated resources.
  16149. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16150. */
  16151. dispose(disposeTexture?: boolean): void;
  16152. /**
  16153. * Clones the particle system.
  16154. * @param name The name of the cloned object
  16155. * @param newEmitter The new emitter to use
  16156. * @returns the cloned particle system
  16157. */
  16158. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16159. /**
  16160. * Serializes the particle system to a JSON object.
  16161. * @returns the JSON object
  16162. */
  16163. serialize(): any;
  16164. /**
  16165. * Rebuild the particle system
  16166. */
  16167. rebuild(): void;
  16168. /**
  16169. * Starts the particle system and begins to emit
  16170. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16171. */
  16172. start(delay?: number): void;
  16173. /**
  16174. * Stops the particle system.
  16175. */
  16176. stop(): void;
  16177. /**
  16178. * Remove all active particles
  16179. */
  16180. reset(): void;
  16181. /**
  16182. * Is this system ready to be used/rendered
  16183. * @return true if the system is ready
  16184. */
  16185. isReady(): boolean;
  16186. /**
  16187. * Adds a new color gradient
  16188. * @param gradient defines the gradient to use (between 0 and 1)
  16189. * @param color1 defines the color to affect to the specified gradient
  16190. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16191. * @returns the current particle system
  16192. */
  16193. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16194. /**
  16195. * Remove a specific color gradient
  16196. * @param gradient defines the gradient to remove
  16197. * @returns the current particle system
  16198. */
  16199. removeColorGradient(gradient: number): IParticleSystem;
  16200. /**
  16201. * Adds a new size gradient
  16202. * @param gradient defines the gradient to use (between 0 and 1)
  16203. * @param factor defines the size factor to affect to the specified gradient
  16204. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16205. * @returns the current particle system
  16206. */
  16207. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16208. /**
  16209. * Remove a specific size gradient
  16210. * @param gradient defines the gradient to remove
  16211. * @returns the current particle system
  16212. */
  16213. removeSizeGradient(gradient: number): IParticleSystem;
  16214. /**
  16215. * Gets the current list of color gradients.
  16216. * You must use addColorGradient and removeColorGradient to udpate this list
  16217. * @returns the list of color gradients
  16218. */
  16219. getColorGradients(): Nullable<Array<ColorGradient>>;
  16220. /**
  16221. * Gets the current list of size gradients.
  16222. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16223. * @returns the list of size gradients
  16224. */
  16225. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16226. /**
  16227. * Gets the current list of angular speed gradients.
  16228. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16229. * @returns the list of angular speed gradients
  16230. */
  16231. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16232. /**
  16233. * Adds a new angular speed gradient
  16234. * @param gradient defines the gradient to use (between 0 and 1)
  16235. * @param factor defines the angular speed to affect to the specified gradient
  16236. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16237. * @returns the current particle system
  16238. */
  16239. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16240. /**
  16241. * Remove a specific angular speed gradient
  16242. * @param gradient defines the gradient to remove
  16243. * @returns the current particle system
  16244. */
  16245. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16246. /**
  16247. * Gets the current list of velocity gradients.
  16248. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16249. * @returns the list of velocity gradients
  16250. */
  16251. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16252. /**
  16253. * Adds a new velocity gradient
  16254. * @param gradient defines the gradient to use (between 0 and 1)
  16255. * @param factor defines the velocity to affect to the specified gradient
  16256. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16257. * @returns the current particle system
  16258. */
  16259. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16260. /**
  16261. * Remove a specific velocity gradient
  16262. * @param gradient defines the gradient to remove
  16263. * @returns the current particle system
  16264. */
  16265. removeVelocityGradient(gradient: number): IParticleSystem;
  16266. /**
  16267. * Gets the current list of limit velocity gradients.
  16268. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16269. * @returns the list of limit velocity gradients
  16270. */
  16271. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16272. /**
  16273. * Adds a new limit velocity gradient
  16274. * @param gradient defines the gradient to use (between 0 and 1)
  16275. * @param factor defines the limit velocity to affect to the specified gradient
  16276. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16277. * @returns the current particle system
  16278. */
  16279. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16280. /**
  16281. * Remove a specific limit velocity gradient
  16282. * @param gradient defines the gradient to remove
  16283. * @returns the current particle system
  16284. */
  16285. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16286. /**
  16287. * Adds a new drag gradient
  16288. * @param gradient defines the gradient to use (between 0 and 1)
  16289. * @param factor defines the drag to affect to the specified gradient
  16290. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16291. * @returns the current particle system
  16292. */
  16293. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16294. /**
  16295. * Remove a specific drag gradient
  16296. * @param gradient defines the gradient to remove
  16297. * @returns the current particle system
  16298. */
  16299. removeDragGradient(gradient: number): IParticleSystem;
  16300. /**
  16301. * Gets the current list of drag gradients.
  16302. * You must use addDragGradient and removeDragGradient to udpate this list
  16303. * @returns the list of drag gradients
  16304. */
  16305. getDragGradients(): Nullable<Array<FactorGradient>>;
  16306. /**
  16307. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16308. * @param gradient defines the gradient to use (between 0 and 1)
  16309. * @param factor defines the emit rate to affect to the specified gradient
  16310. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16311. * @returns the current particle system
  16312. */
  16313. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16314. /**
  16315. * Remove a specific emit rate gradient
  16316. * @param gradient defines the gradient to remove
  16317. * @returns the current particle system
  16318. */
  16319. removeEmitRateGradient(gradient: number): IParticleSystem;
  16320. /**
  16321. * Gets the current list of emit rate gradients.
  16322. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16323. * @returns the list of emit rate gradients
  16324. */
  16325. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16326. /**
  16327. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16328. * @param gradient defines the gradient to use (between 0 and 1)
  16329. * @param factor defines the start size to affect to the specified gradient
  16330. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16331. * @returns the current particle system
  16332. */
  16333. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16334. /**
  16335. * Remove a specific start size gradient
  16336. * @param gradient defines the gradient to remove
  16337. * @returns the current particle system
  16338. */
  16339. removeStartSizeGradient(gradient: number): IParticleSystem;
  16340. /**
  16341. * Gets the current list of start size gradients.
  16342. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16343. * @returns the list of start size gradients
  16344. */
  16345. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16346. /**
  16347. * Adds a new life time gradient
  16348. * @param gradient defines the gradient to use (between 0 and 1)
  16349. * @param factor defines the life time factor to affect to the specified gradient
  16350. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16351. * @returns the current particle system
  16352. */
  16353. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16354. /**
  16355. * Remove a specific life time gradient
  16356. * @param gradient defines the gradient to remove
  16357. * @returns the current particle system
  16358. */
  16359. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16360. /**
  16361. * Gets the current list of life time gradients.
  16362. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16363. * @returns the list of life time gradients
  16364. */
  16365. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16366. /**
  16367. * Gets the current list of color gradients.
  16368. * You must use addColorGradient and removeColorGradient to udpate this list
  16369. * @returns the list of color gradients
  16370. */
  16371. getColorGradients(): Nullable<Array<ColorGradient>>;
  16372. /**
  16373. * Adds a new ramp gradient used to remap particle colors
  16374. * @param gradient defines the gradient to use (between 0 and 1)
  16375. * @param color defines the color to affect to the specified gradient
  16376. * @returns the current particle system
  16377. */
  16378. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16379. /**
  16380. * Gets the current list of ramp gradients.
  16381. * You must use addRampGradient and removeRampGradient to udpate this list
  16382. * @returns the list of ramp gradients
  16383. */
  16384. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16385. /** Gets or sets a boolean indicating that ramp gradients must be used
  16386. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16387. */
  16388. useRampGradients: boolean;
  16389. /**
  16390. * Adds a new color remap gradient
  16391. * @param gradient defines the gradient to use (between 0 and 1)
  16392. * @param min defines the color remap minimal range
  16393. * @param max defines the color remap maximal range
  16394. * @returns the current particle system
  16395. */
  16396. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16397. /**
  16398. * Gets the current list of color remap gradients.
  16399. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16400. * @returns the list of color remap gradients
  16401. */
  16402. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16403. /**
  16404. * Adds a new alpha remap gradient
  16405. * @param gradient defines the gradient to use (between 0 and 1)
  16406. * @param min defines the alpha remap minimal range
  16407. * @param max defines the alpha remap maximal range
  16408. * @returns the current particle system
  16409. */
  16410. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16411. /**
  16412. * Gets the current list of alpha remap gradients.
  16413. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16414. * @returns the list of alpha remap gradients
  16415. */
  16416. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16417. /**
  16418. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16419. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16420. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16421. * @returns the emitter
  16422. */
  16423. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16424. /**
  16425. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16426. * @param radius The radius of the hemisphere to emit from
  16427. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16428. * @returns the emitter
  16429. */
  16430. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16431. /**
  16432. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16433. * @param radius The radius of the sphere to emit from
  16434. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16435. * @returns the emitter
  16436. */
  16437. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16438. /**
  16439. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16440. * @param radius The radius of the sphere to emit from
  16441. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16442. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16443. * @returns the emitter
  16444. */
  16445. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16446. /**
  16447. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16448. * @param radius The radius of the emission cylinder
  16449. * @param height The height of the emission cylinder
  16450. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16451. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16452. * @returns the emitter
  16453. */
  16454. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16455. /**
  16456. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16457. * @param radius The radius of the cylinder to emit from
  16458. * @param height The height of the emission cylinder
  16459. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16460. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16461. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16462. * @returns the emitter
  16463. */
  16464. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16465. /**
  16466. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16467. * @param radius The radius of the cone to emit from
  16468. * @param angle The base angle of the cone
  16469. * @returns the emitter
  16470. */
  16471. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16472. /**
  16473. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16474. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16475. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16476. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16477. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16478. * @returns the emitter
  16479. */
  16480. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16481. /**
  16482. * Get hosting scene
  16483. * @returns the scene
  16484. */
  16485. getScene(): Scene;
  16486. }
  16487. }
  16488. declare module "babylonjs/Meshes/instancedMesh" {
  16489. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16490. import { Vector3 } from "babylonjs/Maths/math";
  16491. import { Camera } from "babylonjs/Cameras/camera";
  16492. import { Node } from "babylonjs/node";
  16493. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16494. import { Mesh } from "babylonjs/Meshes/mesh";
  16495. import { Material } from "babylonjs/Materials/material";
  16496. import { Skeleton } from "babylonjs/Bones/skeleton";
  16497. /**
  16498. * Creates an instance based on a source mesh.
  16499. */
  16500. export class InstancedMesh extends AbstractMesh {
  16501. private _sourceMesh;
  16502. private _currentLOD;
  16503. /** @hidden */
  16504. _indexInSourceMeshInstanceArray: number;
  16505. constructor(name: string, source: Mesh);
  16506. /**
  16507. * Returns the string "InstancedMesh".
  16508. */
  16509. getClassName(): string;
  16510. /**
  16511. * If the source mesh receives shadows
  16512. */
  16513. readonly receiveShadows: boolean;
  16514. /**
  16515. * The material of the source mesh
  16516. */
  16517. readonly material: Nullable<Material>;
  16518. /**
  16519. * Visibility of the source mesh
  16520. */
  16521. readonly visibility: number;
  16522. /**
  16523. * Skeleton of the source mesh
  16524. */
  16525. readonly skeleton: Nullable<Skeleton>;
  16526. /**
  16527. * Rendering ground id of the source mesh
  16528. */
  16529. renderingGroupId: number;
  16530. /**
  16531. * Returns the total number of vertices (integer).
  16532. */
  16533. getTotalVertices(): number;
  16534. /**
  16535. * Returns a positive integer : the total number of indices in this mesh geometry.
  16536. * @returns the numner of indices or zero if the mesh has no geometry.
  16537. */
  16538. getTotalIndices(): number;
  16539. /**
  16540. * The source mesh of the instance
  16541. */
  16542. readonly sourceMesh: Mesh;
  16543. /**
  16544. * Is this node ready to be used/rendered
  16545. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16546. * @return {boolean} is it ready
  16547. */
  16548. isReady(completeCheck?: boolean): boolean;
  16549. /**
  16550. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16551. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16552. * @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.
  16553. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16554. */
  16555. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16556. /**
  16557. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16558. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16559. * The `data` are either a numeric array either a Float32Array.
  16560. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16561. * 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).
  16562. * Note that a new underlying VertexBuffer object is created each call.
  16563. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16564. *
  16565. * Possible `kind` values :
  16566. * - VertexBuffer.PositionKind
  16567. * - VertexBuffer.UVKind
  16568. * - VertexBuffer.UV2Kind
  16569. * - VertexBuffer.UV3Kind
  16570. * - VertexBuffer.UV4Kind
  16571. * - VertexBuffer.UV5Kind
  16572. * - VertexBuffer.UV6Kind
  16573. * - VertexBuffer.ColorKind
  16574. * - VertexBuffer.MatricesIndicesKind
  16575. * - VertexBuffer.MatricesIndicesExtraKind
  16576. * - VertexBuffer.MatricesWeightsKind
  16577. * - VertexBuffer.MatricesWeightsExtraKind
  16578. *
  16579. * Returns the Mesh.
  16580. */
  16581. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16582. /**
  16583. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16584. * If the mesh has no geometry, it is simply returned as it is.
  16585. * The `data` are either a numeric array either a Float32Array.
  16586. * No new underlying VertexBuffer object is created.
  16587. * 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.
  16588. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16589. *
  16590. * Possible `kind` values :
  16591. * - VertexBuffer.PositionKind
  16592. * - VertexBuffer.UVKind
  16593. * - VertexBuffer.UV2Kind
  16594. * - VertexBuffer.UV3Kind
  16595. * - VertexBuffer.UV4Kind
  16596. * - VertexBuffer.UV5Kind
  16597. * - VertexBuffer.UV6Kind
  16598. * - VertexBuffer.ColorKind
  16599. * - VertexBuffer.MatricesIndicesKind
  16600. * - VertexBuffer.MatricesIndicesExtraKind
  16601. * - VertexBuffer.MatricesWeightsKind
  16602. * - VertexBuffer.MatricesWeightsExtraKind
  16603. *
  16604. * Returns the Mesh.
  16605. */
  16606. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16607. /**
  16608. * Sets the mesh indices.
  16609. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16610. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16611. * This method creates a new index buffer each call.
  16612. * Returns the Mesh.
  16613. */
  16614. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16615. /**
  16616. * Boolean : True if the mesh owns the requested kind of data.
  16617. */
  16618. isVerticesDataPresent(kind: string): boolean;
  16619. /**
  16620. * Returns an array of indices (IndicesArray).
  16621. */
  16622. getIndices(): Nullable<IndicesArray>;
  16623. readonly _positions: Nullable<Vector3[]>;
  16624. /**
  16625. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16626. * This means the mesh underlying bounding box and sphere are recomputed.
  16627. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16628. * @returns the current mesh
  16629. */
  16630. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16631. /** @hidden */
  16632. _preActivate(): InstancedMesh;
  16633. /** @hidden */
  16634. _activate(renderId: number): InstancedMesh;
  16635. /**
  16636. * Returns the current associated LOD AbstractMesh.
  16637. */
  16638. getLOD(camera: Camera): AbstractMesh;
  16639. /** @hidden */
  16640. _syncSubMeshes(): InstancedMesh;
  16641. /** @hidden */
  16642. _generatePointsArray(): boolean;
  16643. /**
  16644. * Creates a new InstancedMesh from the current mesh.
  16645. * - name (string) : the cloned mesh name
  16646. * - newParent (optional Node) : the optional Node to parent the clone to.
  16647. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16648. *
  16649. * Returns the clone.
  16650. */
  16651. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16652. /**
  16653. * Disposes the InstancedMesh.
  16654. * Returns nothing.
  16655. */
  16656. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16657. }
  16658. }
  16659. declare module "babylonjs/Materials/shaderMaterial" {
  16660. import { Scene } from "babylonjs/scene";
  16661. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  16662. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16663. import { Mesh } from "babylonjs/Meshes/mesh";
  16664. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16665. import { Texture } from "babylonjs/Materials/Textures/texture";
  16666. import { Material } from "babylonjs/Materials/material";
  16667. /**
  16668. * Defines the options associated with the creation of a shader material.
  16669. */
  16670. export interface IShaderMaterialOptions {
  16671. /**
  16672. * Does the material work in alpha blend mode
  16673. */
  16674. needAlphaBlending: boolean;
  16675. /**
  16676. * Does the material work in alpha test mode
  16677. */
  16678. needAlphaTesting: boolean;
  16679. /**
  16680. * The list of attribute names used in the shader
  16681. */
  16682. attributes: string[];
  16683. /**
  16684. * The list of unifrom names used in the shader
  16685. */
  16686. uniforms: string[];
  16687. /**
  16688. * The list of UBO names used in the shader
  16689. */
  16690. uniformBuffers: string[];
  16691. /**
  16692. * The list of sampler names used in the shader
  16693. */
  16694. samplers: string[];
  16695. /**
  16696. * The list of defines used in the shader
  16697. */
  16698. defines: string[];
  16699. }
  16700. /**
  16701. * 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.
  16702. *
  16703. * This returned material effects how the mesh will look based on the code in the shaders.
  16704. *
  16705. * @see http://doc.babylonjs.com/how_to/shader_material
  16706. */
  16707. export class ShaderMaterial extends Material {
  16708. private _shaderPath;
  16709. private _options;
  16710. private _textures;
  16711. private _textureArrays;
  16712. private _floats;
  16713. private _ints;
  16714. private _floatsArrays;
  16715. private _colors3;
  16716. private _colors3Arrays;
  16717. private _colors4;
  16718. private _vectors2;
  16719. private _vectors3;
  16720. private _vectors4;
  16721. private _matrices;
  16722. private _matrices3x3;
  16723. private _matrices2x2;
  16724. private _vectors2Arrays;
  16725. private _vectors3Arrays;
  16726. private _cachedWorldViewMatrix;
  16727. private _renderId;
  16728. /**
  16729. * Instantiate a new shader material.
  16730. * 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.
  16731. * This returned material effects how the mesh will look based on the code in the shaders.
  16732. * @see http://doc.babylonjs.com/how_to/shader_material
  16733. * @param name Define the name of the material in the scene
  16734. * @param scene Define the scene the material belongs to
  16735. * @param shaderPath Defines the route to the shader code in one of three ways:
  16736. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16737. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16738. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16739. * @param options Define the options used to create the shader
  16740. */
  16741. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16742. /**
  16743. * Gets the current class name of the material e.g. "ShaderMaterial"
  16744. * Mainly use in serialization.
  16745. * @returns the class name
  16746. */
  16747. getClassName(): string;
  16748. /**
  16749. * Specifies if the material will require alpha blending
  16750. * @returns a boolean specifying if alpha blending is needed
  16751. */
  16752. needAlphaBlending(): boolean;
  16753. /**
  16754. * Specifies if this material should be rendered in alpha test mode
  16755. * @returns a boolean specifying if an alpha test is needed.
  16756. */
  16757. needAlphaTesting(): boolean;
  16758. private _checkUniform;
  16759. /**
  16760. * Set a texture in the shader.
  16761. * @param name Define the name of the uniform samplers as defined in the shader
  16762. * @param texture Define the texture to bind to this sampler
  16763. * @return the material itself allowing "fluent" like uniform updates
  16764. */
  16765. setTexture(name: string, texture: Texture): ShaderMaterial;
  16766. /**
  16767. * Set a texture array in the shader.
  16768. * @param name Define the name of the uniform sampler array as defined in the shader
  16769. * @param textures Define the list of textures to bind to this sampler
  16770. * @return the material itself allowing "fluent" like uniform updates
  16771. */
  16772. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  16773. /**
  16774. * Set a float in the shader.
  16775. * @param name Define the name of the uniform as defined in the shader
  16776. * @param value Define the value to give to the uniform
  16777. * @return the material itself allowing "fluent" like uniform updates
  16778. */
  16779. setFloat(name: string, value: number): ShaderMaterial;
  16780. /**
  16781. * Set a int in the shader.
  16782. * @param name Define the name of the uniform as defined in the shader
  16783. * @param value Define the value to give to the uniform
  16784. * @return the material itself allowing "fluent" like uniform updates
  16785. */
  16786. setInt(name: string, value: number): ShaderMaterial;
  16787. /**
  16788. * Set an array of floats in the shader.
  16789. * @param name Define the name of the uniform as defined in the shader
  16790. * @param value Define the value to give to the uniform
  16791. * @return the material itself allowing "fluent" like uniform updates
  16792. */
  16793. setFloats(name: string, value: number[]): ShaderMaterial;
  16794. /**
  16795. * Set a vec3 in the shader from a Color3.
  16796. * @param name Define the name of the uniform as defined in the shader
  16797. * @param value Define the value to give to the uniform
  16798. * @return the material itself allowing "fluent" like uniform updates
  16799. */
  16800. setColor3(name: string, value: Color3): ShaderMaterial;
  16801. /**
  16802. * Set a vec3 array in the shader from a Color3 array.
  16803. * @param name Define the name of the uniform as defined in the shader
  16804. * @param value Define the value to give to the uniform
  16805. * @return the material itself allowing "fluent" like uniform updates
  16806. */
  16807. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16808. /**
  16809. * Set a vec4 in the shader from a Color4.
  16810. * @param name Define the name of the uniform as defined in the shader
  16811. * @param value Define the value to give to the uniform
  16812. * @return the material itself allowing "fluent" like uniform updates
  16813. */
  16814. setColor4(name: string, value: Color4): ShaderMaterial;
  16815. /**
  16816. * Set a vec2 in the shader from a Vector2.
  16817. * @param name Define the name of the uniform as defined in the shader
  16818. * @param value Define the value to give to the uniform
  16819. * @return the material itself allowing "fluent" like uniform updates
  16820. */
  16821. setVector2(name: string, value: Vector2): ShaderMaterial;
  16822. /**
  16823. * Set a vec3 in the shader from a Vector3.
  16824. * @param name Define the name of the uniform as defined in the shader
  16825. * @param value Define the value to give to the uniform
  16826. * @return the material itself allowing "fluent" like uniform updates
  16827. */
  16828. setVector3(name: string, value: Vector3): ShaderMaterial;
  16829. /**
  16830. * Set a vec4 in the shader from a Vector4.
  16831. * @param name Define the name of the uniform as defined in the shader
  16832. * @param value Define the value to give to the uniform
  16833. * @return the material itself allowing "fluent" like uniform updates
  16834. */
  16835. setVector4(name: string, value: Vector4): ShaderMaterial;
  16836. /**
  16837. * Set a mat4 in the shader from a Matrix.
  16838. * @param name Define the name of the uniform as defined in the shader
  16839. * @param value Define the value to give to the uniform
  16840. * @return the material itself allowing "fluent" like uniform updates
  16841. */
  16842. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16843. /**
  16844. * Set a mat3 in the shader from a Float32Array.
  16845. * @param name Define the name of the uniform as defined in the shader
  16846. * @param value Define the value to give to the uniform
  16847. * @return the material itself allowing "fluent" like uniform updates
  16848. */
  16849. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16850. /**
  16851. * Set a mat2 in the shader from a Float32Array.
  16852. * @param name Define the name of the uniform as defined in the shader
  16853. * @param value Define the value to give to the uniform
  16854. * @return the material itself allowing "fluent" like uniform updates
  16855. */
  16856. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16857. /**
  16858. * Set a vec2 array in the shader from a number array.
  16859. * @param name Define the name of the uniform as defined in the shader
  16860. * @param value Define the value to give to the uniform
  16861. * @return the material itself allowing "fluent" like uniform updates
  16862. */
  16863. setArray2(name: string, value: number[]): ShaderMaterial;
  16864. /**
  16865. * Set a vec3 array in the shader from a number array.
  16866. * @param name Define the name of the uniform as defined in the shader
  16867. * @param value Define the value to give to the uniform
  16868. * @return the material itself allowing "fluent" like uniform updates
  16869. */
  16870. setArray3(name: string, value: number[]): ShaderMaterial;
  16871. private _checkCache;
  16872. /**
  16873. * Checks if the material is ready to render the requested mesh
  16874. * @param mesh Define the mesh to render
  16875. * @param useInstances Define whether or not the material is used with instances
  16876. * @returns true if ready, otherwise false
  16877. */
  16878. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16879. /**
  16880. * Binds the world matrix to the material
  16881. * @param world defines the world transformation matrix
  16882. */
  16883. bindOnlyWorldMatrix(world: Matrix): void;
  16884. /**
  16885. * Binds the material to the mesh
  16886. * @param world defines the world transformation matrix
  16887. * @param mesh defines the mesh to bind the material to
  16888. */
  16889. bind(world: Matrix, mesh?: Mesh): void;
  16890. /**
  16891. * Gets the active textures from the material
  16892. * @returns an array of textures
  16893. */
  16894. getActiveTextures(): BaseTexture[];
  16895. /**
  16896. * Specifies if the material uses a texture
  16897. * @param texture defines the texture to check against the material
  16898. * @returns a boolean specifying if the material uses the texture
  16899. */
  16900. hasTexture(texture: BaseTexture): boolean;
  16901. /**
  16902. * Makes a duplicate of the material, and gives it a new name
  16903. * @param name defines the new name for the duplicated material
  16904. * @returns the cloned material
  16905. */
  16906. clone(name: string): ShaderMaterial;
  16907. /**
  16908. * Disposes the material
  16909. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16910. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16911. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16912. */
  16913. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16914. /**
  16915. * Serializes this material in a JSON representation
  16916. * @returns the serialized material object
  16917. */
  16918. serialize(): any;
  16919. /**
  16920. * Creates a shader material from parsed shader material data
  16921. * @param source defines the JSON represnetation of the material
  16922. * @param scene defines the hosting scene
  16923. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16924. * @returns a new material
  16925. */
  16926. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16927. }
  16928. }
  16929. declare module "babylonjs/Shaders/color.fragment" {
  16930. /** @hidden */
  16931. export var colorPixelShader: {
  16932. name: string;
  16933. shader: string;
  16934. };
  16935. }
  16936. declare module "babylonjs/Shaders/color.vertex" {
  16937. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  16938. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  16939. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  16940. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  16941. /** @hidden */
  16942. export var colorVertexShader: {
  16943. name: string;
  16944. shader: string;
  16945. };
  16946. }
  16947. declare module "babylonjs/Meshes/linesMesh" {
  16948. import { Nullable } from "babylonjs/types";
  16949. import { Scene } from "babylonjs/scene";
  16950. import { Color3 } from "babylonjs/Maths/math";
  16951. import { Node } from "babylonjs/node";
  16952. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16953. import { Mesh } from "babylonjs/Meshes/mesh";
  16954. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  16955. import { Effect } from "babylonjs/Materials/effect";
  16956. import { Material } from "babylonjs/Materials/material";
  16957. import "babylonjs/Shaders/color.fragment";
  16958. import "babylonjs/Shaders/color.vertex";
  16959. /**
  16960. * Line mesh
  16961. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16962. */
  16963. export class LinesMesh extends Mesh {
  16964. /**
  16965. * If vertex color should be applied to the mesh
  16966. */
  16967. useVertexColor?: boolean | undefined;
  16968. /**
  16969. * If vertex alpha should be applied to the mesh
  16970. */
  16971. useVertexAlpha?: boolean | undefined;
  16972. /**
  16973. * Color of the line (Default: White)
  16974. */
  16975. color: Color3;
  16976. /**
  16977. * Alpha of the line (Default: 1)
  16978. */
  16979. alpha: number;
  16980. /**
  16981. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16982. * This margin is expressed in world space coordinates, so its value may vary.
  16983. * Default value is 0.1
  16984. */
  16985. intersectionThreshold: number;
  16986. private _colorShader;
  16987. /**
  16988. * Creates a new LinesMesh
  16989. * @param name defines the name
  16990. * @param scene defines the hosting scene
  16991. * @param parent defines the parent mesh if any
  16992. * @param source defines the optional source LinesMesh used to clone data from
  16993. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16994. * When false, achieved by calling a clone(), also passing False.
  16995. * This will make creation of children, recursive.
  16996. * @param useVertexColor defines if this LinesMesh supports vertex color
  16997. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16998. */
  16999. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17000. /**
  17001. * If vertex color should be applied to the mesh
  17002. */
  17003. useVertexColor?: boolean | undefined,
  17004. /**
  17005. * If vertex alpha should be applied to the mesh
  17006. */
  17007. useVertexAlpha?: boolean | undefined);
  17008. /**
  17009. * Returns the string "LineMesh"
  17010. */
  17011. getClassName(): string;
  17012. /**
  17013. * @hidden
  17014. */
  17015. /**
  17016. * @hidden
  17017. */
  17018. material: Material;
  17019. /**
  17020. * @hidden
  17021. */
  17022. readonly checkCollisions: boolean;
  17023. /** @hidden */
  17024. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17025. /** @hidden */
  17026. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17027. /**
  17028. * Disposes of the line mesh
  17029. * @param doNotRecurse If children should be disposed
  17030. */
  17031. dispose(doNotRecurse?: boolean): void;
  17032. /**
  17033. * Returns a new LineMesh object cloned from the current one.
  17034. */
  17035. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17036. /**
  17037. * Creates a new InstancedLinesMesh object from the mesh model.
  17038. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17039. * @param name defines the name of the new instance
  17040. * @returns a new InstancedLinesMesh
  17041. */
  17042. createInstance(name: string): InstancedLinesMesh;
  17043. }
  17044. /**
  17045. * Creates an instance based on a source LinesMesh
  17046. */
  17047. export class InstancedLinesMesh extends InstancedMesh {
  17048. /**
  17049. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17050. * This margin is expressed in world space coordinates, so its value may vary.
  17051. * Initilized with the intersectionThreshold value of the source LinesMesh
  17052. */
  17053. intersectionThreshold: number;
  17054. constructor(name: string, source: LinesMesh);
  17055. /**
  17056. * Returns the string "InstancedLinesMesh".
  17057. */
  17058. getClassName(): string;
  17059. }
  17060. }
  17061. declare module "babylonjs/Shaders/line.fragment" {
  17062. /** @hidden */
  17063. export var linePixelShader: {
  17064. name: string;
  17065. shader: string;
  17066. };
  17067. }
  17068. declare module "babylonjs/Shaders/line.vertex" {
  17069. /** @hidden */
  17070. export var lineVertexShader: {
  17071. name: string;
  17072. shader: string;
  17073. };
  17074. }
  17075. declare module "babylonjs/Rendering/edgesRenderer" {
  17076. import { Nullable } from "babylonjs/types";
  17077. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17078. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17079. import { Vector3 } from "babylonjs/Maths/math";
  17080. import { IDisposable } from "babylonjs/scene";
  17081. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17082. import "babylonjs/Shaders/line.fragment";
  17083. import "babylonjs/Shaders/line.vertex";
  17084. module "babylonjs/Meshes/abstractMesh" {
  17085. interface AbstractMesh {
  17086. /**
  17087. * Disables the mesh edge rendering mode
  17088. * @returns the currentAbstractMesh
  17089. */
  17090. disableEdgesRendering(): AbstractMesh;
  17091. /**
  17092. * Enables the edge rendering mode on the mesh.
  17093. * This mode makes the mesh edges visible
  17094. * @param epsilon defines the maximal distance between two angles to detect a face
  17095. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17096. * @returns the currentAbstractMesh
  17097. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17098. */
  17099. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17100. /**
  17101. * Gets the edgesRenderer associated with the mesh
  17102. */
  17103. edgesRenderer: Nullable<EdgesRenderer>;
  17104. }
  17105. }
  17106. module "babylonjs/Meshes/linesMesh" {
  17107. interface LinesMesh {
  17108. /**
  17109. * Enables the edge rendering mode on the mesh.
  17110. * This mode makes the mesh edges visible
  17111. * @param epsilon defines the maximal distance between two angles to detect a face
  17112. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17113. * @returns the currentAbstractMesh
  17114. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17115. */
  17116. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17117. }
  17118. }
  17119. module "babylonjs/Meshes/linesMesh" {
  17120. interface InstancedLinesMesh {
  17121. /**
  17122. * Enables the edge rendering mode on the mesh.
  17123. * This mode makes the mesh edges visible
  17124. * @param epsilon defines the maximal distance between two angles to detect a face
  17125. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17126. * @returns the current InstancedLinesMesh
  17127. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17128. */
  17129. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17130. }
  17131. }
  17132. /**
  17133. * Defines the minimum contract an Edges renderer should follow.
  17134. */
  17135. export interface IEdgesRenderer extends IDisposable {
  17136. /**
  17137. * Gets or sets a boolean indicating if the edgesRenderer is active
  17138. */
  17139. isEnabled: boolean;
  17140. /**
  17141. * Renders the edges of the attached mesh,
  17142. */
  17143. render(): void;
  17144. /**
  17145. * Checks wether or not the edges renderer is ready to render.
  17146. * @return true if ready, otherwise false.
  17147. */
  17148. isReady(): boolean;
  17149. }
  17150. /**
  17151. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17152. */
  17153. export class EdgesRenderer implements IEdgesRenderer {
  17154. /**
  17155. * Define the size of the edges with an orthographic camera
  17156. */
  17157. edgesWidthScalerForOrthographic: number;
  17158. /**
  17159. * Define the size of the edges with a perspective camera
  17160. */
  17161. edgesWidthScalerForPerspective: number;
  17162. protected _source: AbstractMesh;
  17163. protected _linesPositions: number[];
  17164. protected _linesNormals: number[];
  17165. protected _linesIndices: number[];
  17166. protected _epsilon: number;
  17167. protected _indicesCount: number;
  17168. protected _lineShader: ShaderMaterial;
  17169. protected _ib: WebGLBuffer;
  17170. protected _buffers: {
  17171. [key: string]: Nullable<VertexBuffer>;
  17172. };
  17173. protected _checkVerticesInsteadOfIndices: boolean;
  17174. private _meshRebuildObserver;
  17175. private _meshDisposeObserver;
  17176. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17177. isEnabled: boolean;
  17178. /**
  17179. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17180. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17181. * @param source Mesh used to create edges
  17182. * @param epsilon sum of angles in adjacency to check for edge
  17183. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17184. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17185. */
  17186. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17187. protected _prepareRessources(): void;
  17188. /** @hidden */
  17189. _rebuild(): void;
  17190. /**
  17191. * Releases the required resources for the edges renderer
  17192. */
  17193. dispose(): void;
  17194. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17195. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17196. /**
  17197. * Checks if the pair of p0 and p1 is en edge
  17198. * @param faceIndex
  17199. * @param edge
  17200. * @param faceNormals
  17201. * @param p0
  17202. * @param p1
  17203. * @private
  17204. */
  17205. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17206. /**
  17207. * push line into the position, normal and index buffer
  17208. * @protected
  17209. */
  17210. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17211. /**
  17212. * Generates lines edges from adjacencjes
  17213. * @private
  17214. */
  17215. _generateEdgesLines(): void;
  17216. /**
  17217. * Checks wether or not the edges renderer is ready to render.
  17218. * @return true if ready, otherwise false.
  17219. */
  17220. isReady(): boolean;
  17221. /**
  17222. * Renders the edges of the attached mesh,
  17223. */
  17224. render(): void;
  17225. }
  17226. /**
  17227. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17228. */
  17229. export class LineEdgesRenderer extends EdgesRenderer {
  17230. /**
  17231. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17232. * @param source LineMesh used to generate edges
  17233. * @param epsilon not important (specified angle for edge detection)
  17234. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17235. */
  17236. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17237. /**
  17238. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17239. */
  17240. _generateEdgesLines(): void;
  17241. }
  17242. }
  17243. declare module "babylonjs/Rendering/renderingGroup" {
  17244. import { SmartArray } from "babylonjs/Misc/smartArray";
  17245. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17246. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17247. import { Nullable } from "babylonjs/types";
  17248. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17249. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17250. import { Material } from "babylonjs/Materials/material";
  17251. import { Scene } from "babylonjs/scene";
  17252. /**
  17253. * This represents the object necessary to create a rendering group.
  17254. * This is exclusively used and created by the rendering manager.
  17255. * To modify the behavior, you use the available helpers in your scene or meshes.
  17256. * @hidden
  17257. */
  17258. export class RenderingGroup {
  17259. index: number;
  17260. private _scene;
  17261. private _opaqueSubMeshes;
  17262. private _transparentSubMeshes;
  17263. private _alphaTestSubMeshes;
  17264. private _depthOnlySubMeshes;
  17265. private _particleSystems;
  17266. private _spriteManagers;
  17267. private _opaqueSortCompareFn;
  17268. private _alphaTestSortCompareFn;
  17269. private _transparentSortCompareFn;
  17270. private _renderOpaque;
  17271. private _renderAlphaTest;
  17272. private _renderTransparent;
  17273. private _edgesRenderers;
  17274. onBeforeTransparentRendering: () => void;
  17275. /**
  17276. * Set the opaque sort comparison function.
  17277. * If null the sub meshes will be render in the order they were created
  17278. */
  17279. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17280. /**
  17281. * Set the alpha test sort comparison function.
  17282. * If null the sub meshes will be render in the order they were created
  17283. */
  17284. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17285. /**
  17286. * Set the transparent sort comparison function.
  17287. * If null the sub meshes will be render in the order they were created
  17288. */
  17289. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17290. /**
  17291. * Creates a new rendering group.
  17292. * @param index The rendering group index
  17293. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17294. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17295. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17296. */
  17297. 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>);
  17298. /**
  17299. * Render all the sub meshes contained in the group.
  17300. * @param customRenderFunction Used to override the default render behaviour of the group.
  17301. * @returns true if rendered some submeshes.
  17302. */
  17303. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17304. /**
  17305. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17306. * @param subMeshes The submeshes to render
  17307. */
  17308. private renderOpaqueSorted;
  17309. /**
  17310. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17311. * @param subMeshes The submeshes to render
  17312. */
  17313. private renderAlphaTestSorted;
  17314. /**
  17315. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17316. * @param subMeshes The submeshes to render
  17317. */
  17318. private renderTransparentSorted;
  17319. /**
  17320. * Renders the submeshes in a specified order.
  17321. * @param subMeshes The submeshes to sort before render
  17322. * @param sortCompareFn The comparison function use to sort
  17323. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17324. * @param transparent Specifies to activate blending if true
  17325. */
  17326. private static renderSorted;
  17327. /**
  17328. * Renders the submeshes in the order they were dispatched (no sort applied).
  17329. * @param subMeshes The submeshes to render
  17330. */
  17331. private static renderUnsorted;
  17332. /**
  17333. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17334. * are rendered back to front if in the same alpha index.
  17335. *
  17336. * @param a The first submesh
  17337. * @param b The second submesh
  17338. * @returns The result of the comparison
  17339. */
  17340. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17341. /**
  17342. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17343. * are rendered back to front.
  17344. *
  17345. * @param a The first submesh
  17346. * @param b The second submesh
  17347. * @returns The result of the comparison
  17348. */
  17349. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17350. /**
  17351. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17352. * are rendered front to back (prevent overdraw).
  17353. *
  17354. * @param a The first submesh
  17355. * @param b The second submesh
  17356. * @returns The result of the comparison
  17357. */
  17358. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17359. /**
  17360. * Resets the different lists of submeshes to prepare a new frame.
  17361. */
  17362. prepare(): void;
  17363. dispose(): void;
  17364. /**
  17365. * Inserts the submesh in its correct queue depending on its material.
  17366. * @param subMesh The submesh to dispatch
  17367. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17368. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17369. */
  17370. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17371. dispatchSprites(spriteManager: ISpriteManager): void;
  17372. dispatchParticles(particleSystem: IParticleSystem): void;
  17373. private _renderParticles;
  17374. private _renderSprites;
  17375. }
  17376. }
  17377. declare module "babylonjs/Rendering/renderingManager" {
  17378. import { Nullable } from "babylonjs/types";
  17379. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17380. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17381. import { SmartArray } from "babylonjs/Misc/smartArray";
  17382. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17383. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17384. import { Material } from "babylonjs/Materials/material";
  17385. import { Scene } from "babylonjs/scene";
  17386. import { Camera } from "babylonjs/Cameras/camera";
  17387. /**
  17388. * Interface describing the different options available in the rendering manager
  17389. * regarding Auto Clear between groups.
  17390. */
  17391. export interface IRenderingManagerAutoClearSetup {
  17392. /**
  17393. * Defines whether or not autoclear is enable.
  17394. */
  17395. autoClear: boolean;
  17396. /**
  17397. * Defines whether or not to autoclear the depth buffer.
  17398. */
  17399. depth: boolean;
  17400. /**
  17401. * Defines whether or not to autoclear the stencil buffer.
  17402. */
  17403. stencil: boolean;
  17404. }
  17405. /**
  17406. * This class is used by the onRenderingGroupObservable
  17407. */
  17408. export class RenderingGroupInfo {
  17409. /**
  17410. * The Scene that being rendered
  17411. */
  17412. scene: Scene;
  17413. /**
  17414. * The camera currently used for the rendering pass
  17415. */
  17416. camera: Nullable<Camera>;
  17417. /**
  17418. * The ID of the renderingGroup being processed
  17419. */
  17420. renderingGroupId: number;
  17421. }
  17422. /**
  17423. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17424. * It is enable to manage the different groups as well as the different necessary sort functions.
  17425. * This should not be used directly aside of the few static configurations
  17426. */
  17427. export class RenderingManager {
  17428. /**
  17429. * The max id used for rendering groups (not included)
  17430. */
  17431. static MAX_RENDERINGGROUPS: number;
  17432. /**
  17433. * The min id used for rendering groups (included)
  17434. */
  17435. static MIN_RENDERINGGROUPS: number;
  17436. /**
  17437. * Used to globally prevent autoclearing scenes.
  17438. */
  17439. static AUTOCLEAR: boolean;
  17440. /**
  17441. * @hidden
  17442. */
  17443. _useSceneAutoClearSetup: boolean;
  17444. private _scene;
  17445. private _renderingGroups;
  17446. private _depthStencilBufferAlreadyCleaned;
  17447. private _autoClearDepthStencil;
  17448. private _customOpaqueSortCompareFn;
  17449. private _customAlphaTestSortCompareFn;
  17450. private _customTransparentSortCompareFn;
  17451. private _renderingGroupInfo;
  17452. /**
  17453. * Instantiates a new rendering group for a particular scene
  17454. * @param scene Defines the scene the groups belongs to
  17455. */
  17456. constructor(scene: Scene);
  17457. private _clearDepthStencilBuffer;
  17458. /**
  17459. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17460. * @hidden
  17461. */
  17462. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17463. /**
  17464. * Resets the different information of the group to prepare a new frame
  17465. * @hidden
  17466. */
  17467. reset(): void;
  17468. /**
  17469. * Dispose and release the group and its associated resources.
  17470. * @hidden
  17471. */
  17472. dispose(): void;
  17473. /**
  17474. * Clear the info related to rendering groups preventing retention points during dispose.
  17475. */
  17476. freeRenderingGroups(): void;
  17477. private _prepareRenderingGroup;
  17478. /**
  17479. * Add a sprite manager to the rendering manager in order to render it this frame.
  17480. * @param spriteManager Define the sprite manager to render
  17481. */
  17482. dispatchSprites(spriteManager: ISpriteManager): void;
  17483. /**
  17484. * Add a particle system to the rendering manager in order to render it this frame.
  17485. * @param particleSystem Define the particle system to render
  17486. */
  17487. dispatchParticles(particleSystem: IParticleSystem): void;
  17488. /**
  17489. * Add a submesh to the manager in order to render it this frame
  17490. * @param subMesh The submesh to dispatch
  17491. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17492. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17493. */
  17494. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17495. /**
  17496. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17497. * This allowed control for front to back rendering or reversly depending of the special needs.
  17498. *
  17499. * @param renderingGroupId The rendering group id corresponding to its index
  17500. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17501. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17502. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17503. */
  17504. 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;
  17505. /**
  17506. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17507. *
  17508. * @param renderingGroupId The rendering group id corresponding to its index
  17509. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17510. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17511. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17512. */
  17513. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17514. /**
  17515. * Gets the current auto clear configuration for one rendering group of the rendering
  17516. * manager.
  17517. * @param index the rendering group index to get the information for
  17518. * @returns The auto clear setup for the requested rendering group
  17519. */
  17520. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17521. }
  17522. }
  17523. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  17524. import { Observable } from "babylonjs/Misc/observable";
  17525. import { SmartArray } from "babylonjs/Misc/smartArray";
  17526. import { Nullable } from "babylonjs/types";
  17527. import { Camera } from "babylonjs/Cameras/camera";
  17528. import { Scene } from "babylonjs/scene";
  17529. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  17530. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  17531. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17532. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17533. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17534. import { Texture } from "babylonjs/Materials/Textures/texture";
  17535. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17536. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  17537. import { Engine } from "babylonjs/Engines/engine";
  17538. /**
  17539. * This Helps creating a texture that will be created from a camera in your scene.
  17540. * It is basically a dynamic texture that could be used to create special effects for instance.
  17541. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17542. */
  17543. export class RenderTargetTexture extends Texture {
  17544. isCube: boolean;
  17545. /**
  17546. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17547. */
  17548. static readonly REFRESHRATE_RENDER_ONCE: number;
  17549. /**
  17550. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17551. */
  17552. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17553. /**
  17554. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17555. * the central point of your effect and can save a lot of performances.
  17556. */
  17557. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17558. /**
  17559. * Use this predicate to dynamically define the list of mesh you want to render.
  17560. * If set, the renderList property will be overwritten.
  17561. */
  17562. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17563. private _renderList;
  17564. /**
  17565. * Use this list to define the list of mesh you want to render.
  17566. */
  17567. renderList: Nullable<Array<AbstractMesh>>;
  17568. private _hookArray;
  17569. /**
  17570. * Define if particles should be rendered in your texture.
  17571. */
  17572. renderParticles: boolean;
  17573. /**
  17574. * Define if sprites should be rendered in your texture.
  17575. */
  17576. renderSprites: boolean;
  17577. /**
  17578. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17579. */
  17580. coordinatesMode: number;
  17581. /**
  17582. * Define the camera used to render the texture.
  17583. */
  17584. activeCamera: Nullable<Camera>;
  17585. /**
  17586. * Override the render function of the texture with your own one.
  17587. */
  17588. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17589. /**
  17590. * Define if camera post processes should be use while rendering the texture.
  17591. */
  17592. useCameraPostProcesses: boolean;
  17593. /**
  17594. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17595. */
  17596. ignoreCameraViewport: boolean;
  17597. private _postProcessManager;
  17598. private _postProcesses;
  17599. private _resizeObserver;
  17600. /**
  17601. * An event triggered when the texture is unbind.
  17602. */
  17603. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17604. /**
  17605. * An event triggered when the texture is unbind.
  17606. */
  17607. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17608. private _onAfterUnbindObserver;
  17609. /**
  17610. * Set a after unbind callback in the texture.
  17611. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17612. */
  17613. onAfterUnbind: () => void;
  17614. /**
  17615. * An event triggered before rendering the texture
  17616. */
  17617. onBeforeRenderObservable: Observable<number>;
  17618. private _onBeforeRenderObserver;
  17619. /**
  17620. * Set a before render callback in the texture.
  17621. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17622. */
  17623. onBeforeRender: (faceIndex: number) => void;
  17624. /**
  17625. * An event triggered after rendering the texture
  17626. */
  17627. onAfterRenderObservable: Observable<number>;
  17628. private _onAfterRenderObserver;
  17629. /**
  17630. * Set a after render callback in the texture.
  17631. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17632. */
  17633. onAfterRender: (faceIndex: number) => void;
  17634. /**
  17635. * An event triggered after the texture clear
  17636. */
  17637. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  17638. private _onClearObserver;
  17639. /**
  17640. * Set a clear callback in the texture.
  17641. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17642. */
  17643. onClear: (Engine: Engine) => void;
  17644. /**
  17645. * Define the clear color of the Render Target if it should be different from the scene.
  17646. */
  17647. clearColor: Color4;
  17648. protected _size: number | {
  17649. width: number;
  17650. height: number;
  17651. };
  17652. protected _initialSizeParameter: number | {
  17653. width: number;
  17654. height: number;
  17655. } | {
  17656. ratio: number;
  17657. };
  17658. protected _sizeRatio: Nullable<number>;
  17659. /** @hidden */
  17660. _generateMipMaps: boolean;
  17661. protected _renderingManager: RenderingManager;
  17662. /** @hidden */
  17663. _waitingRenderList: string[];
  17664. protected _doNotChangeAspectRatio: boolean;
  17665. protected _currentRefreshId: number;
  17666. protected _refreshRate: number;
  17667. protected _textureMatrix: Matrix;
  17668. protected _samples: number;
  17669. protected _renderTargetOptions: RenderTargetCreationOptions;
  17670. /**
  17671. * Gets render target creation options that were used.
  17672. */
  17673. readonly renderTargetOptions: RenderTargetCreationOptions;
  17674. protected _engine: Engine;
  17675. protected _onRatioRescale(): void;
  17676. /**
  17677. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17678. * It must define where the camera used to render the texture is set
  17679. */
  17680. boundingBoxPosition: Vector3;
  17681. private _boundingBoxSize;
  17682. /**
  17683. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17684. * When defined, the cubemap will switch to local mode
  17685. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17686. * @example https://www.babylonjs-playground.com/#RNASML
  17687. */
  17688. boundingBoxSize: Vector3;
  17689. /**
  17690. * In case the RTT has been created with a depth texture, get the associated
  17691. * depth texture.
  17692. * Otherwise, return null.
  17693. */
  17694. depthStencilTexture: Nullable<InternalTexture>;
  17695. /**
  17696. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17697. * or used a shadow, depth texture...
  17698. * @param name The friendly name of the texture
  17699. * @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)
  17700. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17701. * @param generateMipMaps True if mip maps need to be generated after render.
  17702. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17703. * @param type The type of the buffer in the RTT (int, half float, float...)
  17704. * @param isCube True if a cube texture needs to be created
  17705. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17706. * @param generateDepthBuffer True to generate a depth buffer
  17707. * @param generateStencilBuffer True to generate a stencil buffer
  17708. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17709. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17710. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17711. */
  17712. constructor(name: string, size: number | {
  17713. width: number;
  17714. height: number;
  17715. } | {
  17716. ratio: number;
  17717. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17718. /**
  17719. * Creates a depth stencil texture.
  17720. * This is only available in WebGL 2 or with the depth texture extension available.
  17721. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17722. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17723. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17724. */
  17725. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17726. private _processSizeParameter;
  17727. /**
  17728. * Define the number of samples to use in case of MSAA.
  17729. * It defaults to one meaning no MSAA has been enabled.
  17730. */
  17731. samples: number;
  17732. /**
  17733. * Resets the refresh counter of the texture and start bak from scratch.
  17734. * Could be useful to regenerate the texture if it is setup to render only once.
  17735. */
  17736. resetRefreshCounter(): void;
  17737. /**
  17738. * Define the refresh rate of the texture or the rendering frequency.
  17739. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17740. */
  17741. refreshRate: number;
  17742. /**
  17743. * Adds a post process to the render target rendering passes.
  17744. * @param postProcess define the post process to add
  17745. */
  17746. addPostProcess(postProcess: PostProcess): void;
  17747. /**
  17748. * Clear all the post processes attached to the render target
  17749. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17750. */
  17751. clearPostProcesses(dispose?: boolean): void;
  17752. /**
  17753. * Remove one of the post process from the list of attached post processes to the texture
  17754. * @param postProcess define the post process to remove from the list
  17755. */
  17756. removePostProcess(postProcess: PostProcess): void;
  17757. /** @hidden */
  17758. _shouldRender(): boolean;
  17759. /**
  17760. * Gets the actual render size of the texture.
  17761. * @returns the width of the render size
  17762. */
  17763. getRenderSize(): number;
  17764. /**
  17765. * Gets the actual render width of the texture.
  17766. * @returns the width of the render size
  17767. */
  17768. getRenderWidth(): number;
  17769. /**
  17770. * Gets the actual render height of the texture.
  17771. * @returns the height of the render size
  17772. */
  17773. getRenderHeight(): number;
  17774. /**
  17775. * Get if the texture can be rescaled or not.
  17776. */
  17777. readonly canRescale: boolean;
  17778. /**
  17779. * Resize the texture using a ratio.
  17780. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17781. */
  17782. scale(ratio: number): void;
  17783. /**
  17784. * Get the texture reflection matrix used to rotate/transform the reflection.
  17785. * @returns the reflection matrix
  17786. */
  17787. getReflectionTextureMatrix(): Matrix;
  17788. /**
  17789. * Resize the texture to a new desired size.
  17790. * Be carrefull as it will recreate all the data in the new texture.
  17791. * @param size Define the new size. It can be:
  17792. * - a number for squared texture,
  17793. * - an object containing { width: number, height: number }
  17794. * - or an object containing a ratio { ratio: number }
  17795. */
  17796. resize(size: number | {
  17797. width: number;
  17798. height: number;
  17799. } | {
  17800. ratio: number;
  17801. }): void;
  17802. /**
  17803. * Renders all the objects from the render list into the texture.
  17804. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17805. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17806. */
  17807. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17808. private _bestReflectionRenderTargetDimension;
  17809. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17810. private renderToTarget;
  17811. /**
  17812. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17813. * This allowed control for front to back rendering or reversly depending of the special needs.
  17814. *
  17815. * @param renderingGroupId The rendering group id corresponding to its index
  17816. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17817. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17818. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17819. */
  17820. 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;
  17821. /**
  17822. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17823. *
  17824. * @param renderingGroupId The rendering group id corresponding to its index
  17825. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17826. */
  17827. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17828. /**
  17829. * Clones the texture.
  17830. * @returns the cloned texture
  17831. */
  17832. clone(): RenderTargetTexture;
  17833. /**
  17834. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17835. * @returns The JSON representation of the texture
  17836. */
  17837. serialize(): any;
  17838. /**
  17839. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17840. */
  17841. disposeFramebufferObjects(): void;
  17842. /**
  17843. * Dispose the texture and release its associated resources.
  17844. */
  17845. dispose(): void;
  17846. /** @hidden */
  17847. _rebuild(): void;
  17848. /**
  17849. * Clear the info related to rendering groups preventing retention point in material dispose.
  17850. */
  17851. freeRenderingGroups(): void;
  17852. }
  17853. }
  17854. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  17855. import { Scene } from "babylonjs/scene";
  17856. import { Plane } from "babylonjs/Maths/math";
  17857. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17858. /**
  17859. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17860. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17861. * You can then easily use it as a reflectionTexture on a flat surface.
  17862. * In case the surface is not a plane, please consider relying on reflection probes.
  17863. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17864. */
  17865. export class MirrorTexture extends RenderTargetTexture {
  17866. private scene;
  17867. /**
  17868. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  17869. * 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.
  17870. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17871. */
  17872. mirrorPlane: Plane;
  17873. /**
  17874. * Define the blur ratio used to blur the reflection if needed.
  17875. */
  17876. blurRatio: number;
  17877. /**
  17878. * Define the adaptive blur kernel used to blur the reflection if needed.
  17879. * This will autocompute the closest best match for the `blurKernel`
  17880. */
  17881. adaptiveBlurKernel: number;
  17882. /**
  17883. * Define the blur kernel used to blur the reflection if needed.
  17884. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17885. */
  17886. blurKernel: number;
  17887. /**
  17888. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  17889. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17890. */
  17891. blurKernelX: number;
  17892. /**
  17893. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  17894. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17895. */
  17896. blurKernelY: number;
  17897. private _autoComputeBlurKernel;
  17898. protected _onRatioRescale(): void;
  17899. private _updateGammaSpace;
  17900. private _imageProcessingConfigChangeObserver;
  17901. private _transformMatrix;
  17902. private _mirrorMatrix;
  17903. private _savedViewMatrix;
  17904. private _blurX;
  17905. private _blurY;
  17906. private _adaptiveBlurKernel;
  17907. private _blurKernelX;
  17908. private _blurKernelY;
  17909. private _blurRatio;
  17910. /**
  17911. * Instantiates a Mirror Texture.
  17912. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17913. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17914. * You can then easily use it as a reflectionTexture on a flat surface.
  17915. * In case the surface is not a plane, please consider relying on reflection probes.
  17916. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17917. * @param name
  17918. * @param size
  17919. * @param scene
  17920. * @param generateMipMaps
  17921. * @param type
  17922. * @param samplingMode
  17923. * @param generateDepthBuffer
  17924. */
  17925. constructor(name: string, size: number | {
  17926. width: number;
  17927. height: number;
  17928. } | {
  17929. ratio: number;
  17930. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  17931. private _preparePostProcesses;
  17932. /**
  17933. * Clone the mirror texture.
  17934. * @returns the cloned texture
  17935. */
  17936. clone(): MirrorTexture;
  17937. /**
  17938. * Serialize the texture to a JSON representation you could use in Parse later on
  17939. * @returns the serialized JSON representation
  17940. */
  17941. serialize(): any;
  17942. /**
  17943. * Dispose the texture and release its associated resources.
  17944. */
  17945. dispose(): void;
  17946. }
  17947. }
  17948. declare module "babylonjs/Materials/Textures/texture" {
  17949. import { Observable } from "babylonjs/Misc/observable";
  17950. import { Nullable } from "babylonjs/types";
  17951. import { Scene } from "babylonjs/scene";
  17952. import { Matrix } from "babylonjs/Maths/math";
  17953. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17954. /**
  17955. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  17956. * @see http://doc.babylonjs.com/babylon101/materials#texture
  17957. */
  17958. export class Texture extends BaseTexture {
  17959. /** @hidden */
  17960. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  17961. /** @hidden */
  17962. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  17963. /** @hidden */
  17964. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  17965. /** nearest is mag = nearest and min = nearest and mip = linear */
  17966. static readonly NEAREST_SAMPLINGMODE: number;
  17967. /** nearest is mag = nearest and min = nearest and mip = linear */
  17968. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  17969. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17970. static readonly BILINEAR_SAMPLINGMODE: number;
  17971. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17972. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  17973. /** Trilinear is mag = linear and min = linear and mip = linear */
  17974. static readonly TRILINEAR_SAMPLINGMODE: number;
  17975. /** Trilinear is mag = linear and min = linear and mip = linear */
  17976. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  17977. /** mag = nearest and min = nearest and mip = nearest */
  17978. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  17979. /** mag = nearest and min = linear and mip = nearest */
  17980. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  17981. /** mag = nearest and min = linear and mip = linear */
  17982. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  17983. /** mag = nearest and min = linear and mip = none */
  17984. static readonly NEAREST_LINEAR: number;
  17985. /** mag = nearest and min = nearest and mip = none */
  17986. static readonly NEAREST_NEAREST: number;
  17987. /** mag = linear and min = nearest and mip = nearest */
  17988. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  17989. /** mag = linear and min = nearest and mip = linear */
  17990. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  17991. /** mag = linear and min = linear and mip = none */
  17992. static readonly LINEAR_LINEAR: number;
  17993. /** mag = linear and min = nearest and mip = none */
  17994. static readonly LINEAR_NEAREST: number;
  17995. /** Explicit coordinates mode */
  17996. static readonly EXPLICIT_MODE: number;
  17997. /** Spherical coordinates mode */
  17998. static readonly SPHERICAL_MODE: number;
  17999. /** Planar coordinates mode */
  18000. static readonly PLANAR_MODE: number;
  18001. /** Cubic coordinates mode */
  18002. static readonly CUBIC_MODE: number;
  18003. /** Projection coordinates mode */
  18004. static readonly PROJECTION_MODE: number;
  18005. /** Inverse Cubic coordinates mode */
  18006. static readonly SKYBOX_MODE: number;
  18007. /** Inverse Cubic coordinates mode */
  18008. static readonly INVCUBIC_MODE: number;
  18009. /** Equirectangular coordinates mode */
  18010. static readonly EQUIRECTANGULAR_MODE: number;
  18011. /** Equirectangular Fixed coordinates mode */
  18012. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18013. /** Equirectangular Fixed Mirrored coordinates mode */
  18014. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18015. /** Texture is not repeating outside of 0..1 UVs */
  18016. static readonly CLAMP_ADDRESSMODE: number;
  18017. /** Texture is repeating outside of 0..1 UVs */
  18018. static readonly WRAP_ADDRESSMODE: number;
  18019. /** Texture is repeating and mirrored */
  18020. static readonly MIRROR_ADDRESSMODE: number;
  18021. /**
  18022. * 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
  18023. */
  18024. static UseSerializedUrlIfAny: boolean;
  18025. /**
  18026. * Define the url of the texture.
  18027. */
  18028. url: Nullable<string>;
  18029. /**
  18030. * Define an offset on the texture to offset the u coordinates of the UVs
  18031. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18032. */
  18033. uOffset: number;
  18034. /**
  18035. * Define an offset on the texture to offset the v coordinates of the UVs
  18036. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18037. */
  18038. vOffset: number;
  18039. /**
  18040. * Define an offset on the texture to scale the u coordinates of the UVs
  18041. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18042. */
  18043. uScale: number;
  18044. /**
  18045. * Define an offset on the texture to scale the v coordinates of the UVs
  18046. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18047. */
  18048. vScale: number;
  18049. /**
  18050. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18051. * @see http://doc.babylonjs.com/how_to/more_materials
  18052. */
  18053. uAng: number;
  18054. /**
  18055. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18056. * @see http://doc.babylonjs.com/how_to/more_materials
  18057. */
  18058. vAng: number;
  18059. /**
  18060. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18061. * @see http://doc.babylonjs.com/how_to/more_materials
  18062. */
  18063. wAng: number;
  18064. /**
  18065. * Defines the center of rotation (U)
  18066. */
  18067. uRotationCenter: number;
  18068. /**
  18069. * Defines the center of rotation (V)
  18070. */
  18071. vRotationCenter: number;
  18072. /**
  18073. * Defines the center of rotation (W)
  18074. */
  18075. wRotationCenter: number;
  18076. /**
  18077. * Are mip maps generated for this texture or not.
  18078. */
  18079. readonly noMipmap: boolean;
  18080. private _noMipmap;
  18081. /** @hidden */
  18082. _invertY: boolean;
  18083. private _rowGenerationMatrix;
  18084. private _cachedTextureMatrix;
  18085. private _projectionModeMatrix;
  18086. private _t0;
  18087. private _t1;
  18088. private _t2;
  18089. private _cachedUOffset;
  18090. private _cachedVOffset;
  18091. private _cachedUScale;
  18092. private _cachedVScale;
  18093. private _cachedUAng;
  18094. private _cachedVAng;
  18095. private _cachedWAng;
  18096. private _cachedProjectionMatrixId;
  18097. private _cachedCoordinatesMode;
  18098. /** @hidden */
  18099. protected _initialSamplingMode: number;
  18100. /** @hidden */
  18101. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18102. private _deleteBuffer;
  18103. protected _format: Nullable<number>;
  18104. private _delayedOnLoad;
  18105. private _delayedOnError;
  18106. /**
  18107. * Observable triggered once the texture has been loaded.
  18108. */
  18109. onLoadObservable: Observable<Texture>;
  18110. protected _isBlocking: boolean;
  18111. /**
  18112. * Is the texture preventing material to render while loading.
  18113. * If false, a default texture will be used instead of the loading one during the preparation step.
  18114. */
  18115. isBlocking: boolean;
  18116. /**
  18117. * Get the current sampling mode associated with the texture.
  18118. */
  18119. readonly samplingMode: number;
  18120. /**
  18121. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18122. */
  18123. readonly invertY: boolean;
  18124. /**
  18125. * Instantiates a new texture.
  18126. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18127. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18128. * @param url define the url of the picture to load as a texture
  18129. * @param scene define the scene the texture will belong to
  18130. * @param noMipmap define if the texture will require mip maps or not
  18131. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18132. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18133. * @param onLoad define a callback triggered when the texture has been loaded
  18134. * @param onError define a callback triggered when an error occurred during the loading session
  18135. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18136. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18137. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18138. */
  18139. 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);
  18140. /**
  18141. * Update the url (and optional buffer) of this texture if url was null during construction.
  18142. * @param url the url of the texture
  18143. * @param buffer the buffer of the texture (defaults to null)
  18144. * @param onLoad callback called when the texture is loaded (defaults to null)
  18145. */
  18146. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18147. /**
  18148. * Finish the loading sequence of a texture flagged as delayed load.
  18149. * @hidden
  18150. */
  18151. delayLoad(): void;
  18152. private _prepareRowForTextureGeneration;
  18153. /**
  18154. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18155. * @returns the transform matrix of the texture.
  18156. */
  18157. getTextureMatrix(): Matrix;
  18158. /**
  18159. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18160. * @returns The reflection texture transform
  18161. */
  18162. getReflectionTextureMatrix(): Matrix;
  18163. /**
  18164. * Clones the texture.
  18165. * @returns the cloned texture
  18166. */
  18167. clone(): Texture;
  18168. /**
  18169. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18170. * @returns The JSON representation of the texture
  18171. */
  18172. serialize(): any;
  18173. /**
  18174. * Get the current class name of the texture useful for serialization or dynamic coding.
  18175. * @returns "Texture"
  18176. */
  18177. getClassName(): string;
  18178. /**
  18179. * Dispose the texture and release its associated resources.
  18180. */
  18181. dispose(): void;
  18182. /**
  18183. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18184. * @param parsedTexture Define the JSON representation of the texture
  18185. * @param scene Define the scene the parsed texture should be instantiated in
  18186. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18187. * @returns The parsed texture if successful
  18188. */
  18189. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18190. /**
  18191. * Creates a texture from its base 64 representation.
  18192. * @param data Define the base64 payload without the data: prefix
  18193. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18194. * @param scene Define the scene the texture should belong to
  18195. * @param noMipmap Forces the texture to not create mip map information if true
  18196. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18197. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18198. * @param onLoad define a callback triggered when the texture has been loaded
  18199. * @param onError define a callback triggered when an error occurred during the loading session
  18200. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18201. * @returns the created texture
  18202. */
  18203. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18204. /**
  18205. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18206. * @param data Define the base64 payload without the data: prefix
  18207. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18208. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18209. * @param scene Define the scene the texture should belong to
  18210. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18211. * @param noMipmap Forces the texture to not create mip map information if true
  18212. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18213. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18214. * @param onLoad define a callback triggered when the texture has been loaded
  18215. * @param onError define a callback triggered when an error occurred during the loading session
  18216. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18217. * @returns the created texture
  18218. */
  18219. 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;
  18220. }
  18221. }
  18222. declare module "babylonjs/Materials/Textures/rawTexture" {
  18223. import { Scene } from "babylonjs/scene";
  18224. import { Texture } from "babylonjs/Materials/Textures/texture";
  18225. /**
  18226. * Raw texture can help creating a texture directly from an array of data.
  18227. * This can be super useful if you either get the data from an uncompressed source or
  18228. * if you wish to create your texture pixel by pixel.
  18229. */
  18230. export class RawTexture extends Texture {
  18231. /**
  18232. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18233. */
  18234. format: number;
  18235. private _engine;
  18236. /**
  18237. * Instantiates a new RawTexture.
  18238. * Raw texture can help creating a texture directly from an array of data.
  18239. * This can be super useful if you either get the data from an uncompressed source or
  18240. * if you wish to create your texture pixel by pixel.
  18241. * @param data define the array of data to use to create the texture
  18242. * @param width define the width of the texture
  18243. * @param height define the height of the texture
  18244. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18245. * @param scene define the scene the texture belongs to
  18246. * @param generateMipMaps define whether mip maps should be generated or not
  18247. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18248. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18249. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18250. */
  18251. constructor(data: ArrayBufferView, width: number, height: number,
  18252. /**
  18253. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18254. */
  18255. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18256. /**
  18257. * Updates the texture underlying data.
  18258. * @param data Define the new data of the texture
  18259. */
  18260. update(data: ArrayBufferView): void;
  18261. /**
  18262. * Creates a luminance texture from some data.
  18263. * @param data Define the texture data
  18264. * @param width Define the width of the texture
  18265. * @param height Define the height of the texture
  18266. * @param scene Define the scene the texture belongs to
  18267. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18268. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18269. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18270. * @returns the luminance texture
  18271. */
  18272. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18273. /**
  18274. * Creates a luminance alpha texture from some data.
  18275. * @param data Define the texture data
  18276. * @param width Define the width of the texture
  18277. * @param height Define the height of the texture
  18278. * @param scene Define the scene the texture belongs to
  18279. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18280. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18281. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18282. * @returns the luminance alpha texture
  18283. */
  18284. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18285. /**
  18286. * Creates an alpha texture from some data.
  18287. * @param data Define the texture data
  18288. * @param width Define the width of the texture
  18289. * @param height Define the height of the texture
  18290. * @param scene Define the scene the texture belongs to
  18291. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18292. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18293. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18294. * @returns the alpha texture
  18295. */
  18296. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18297. /**
  18298. * Creates a RGB texture from some data.
  18299. * @param data Define the texture data
  18300. * @param width Define the width of the texture
  18301. * @param height Define the height of the texture
  18302. * @param scene Define the scene the texture belongs to
  18303. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18304. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18305. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18306. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18307. * @returns the RGB alpha texture
  18308. */
  18309. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18310. /**
  18311. * Creates a RGBA texture from some data.
  18312. * @param data Define the texture data
  18313. * @param width Define the width of the texture
  18314. * @param height Define the height of the texture
  18315. * @param scene Define the scene the texture belongs to
  18316. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18317. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18318. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18319. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18320. * @returns the RGBA texture
  18321. */
  18322. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18323. /**
  18324. * Creates a R texture from some data.
  18325. * @param data Define the texture data
  18326. * @param width Define the width of the texture
  18327. * @param height Define the height of the texture
  18328. * @param scene Define the scene the texture belongs to
  18329. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18330. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18331. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18332. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18333. * @returns the R texture
  18334. */
  18335. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18336. }
  18337. }
  18338. declare module "babylonjs/Animations/runtimeAnimation" {
  18339. import { Animation } from "babylonjs/Animations/animation";
  18340. import { Animatable } from "babylonjs/Animations/animatable";
  18341. import { Scene } from "babylonjs/scene";
  18342. /**
  18343. * Defines a runtime animation
  18344. */
  18345. export class RuntimeAnimation {
  18346. private _events;
  18347. /**
  18348. * The current frame of the runtime animation
  18349. */
  18350. private _currentFrame;
  18351. /**
  18352. * The animation used by the runtime animation
  18353. */
  18354. private _animation;
  18355. /**
  18356. * The target of the runtime animation
  18357. */
  18358. private _target;
  18359. /**
  18360. * The initiating animatable
  18361. */
  18362. private _host;
  18363. /**
  18364. * The original value of the runtime animation
  18365. */
  18366. private _originalValue;
  18367. /**
  18368. * The original blend value of the runtime animation
  18369. */
  18370. private _originalBlendValue;
  18371. /**
  18372. * The offsets cache of the runtime animation
  18373. */
  18374. private _offsetsCache;
  18375. /**
  18376. * The high limits cache of the runtime animation
  18377. */
  18378. private _highLimitsCache;
  18379. /**
  18380. * Specifies if the runtime animation has been stopped
  18381. */
  18382. private _stopped;
  18383. /**
  18384. * The blending factor of the runtime animation
  18385. */
  18386. private _blendingFactor;
  18387. /**
  18388. * The BabylonJS scene
  18389. */
  18390. private _scene;
  18391. /**
  18392. * The current value of the runtime animation
  18393. */
  18394. private _currentValue;
  18395. /** @hidden */
  18396. _workValue: any;
  18397. /**
  18398. * The active target of the runtime animation
  18399. */
  18400. private _activeTarget;
  18401. /**
  18402. * The target path of the runtime animation
  18403. */
  18404. private _targetPath;
  18405. /**
  18406. * The weight of the runtime animation
  18407. */
  18408. private _weight;
  18409. /**
  18410. * The ratio offset of the runtime animation
  18411. */
  18412. private _ratioOffset;
  18413. /**
  18414. * The previous delay of the runtime animation
  18415. */
  18416. private _previousDelay;
  18417. /**
  18418. * The previous ratio of the runtime animation
  18419. */
  18420. private _previousRatio;
  18421. /**
  18422. * Gets the current frame of the runtime animation
  18423. */
  18424. readonly currentFrame: number;
  18425. /**
  18426. * Gets the weight of the runtime animation
  18427. */
  18428. readonly weight: number;
  18429. /**
  18430. * Gets the current value of the runtime animation
  18431. */
  18432. readonly currentValue: any;
  18433. /**
  18434. * Gets the target path of the runtime animation
  18435. */
  18436. readonly targetPath: string;
  18437. /**
  18438. * Gets the actual target of the runtime animation
  18439. */
  18440. readonly target: any;
  18441. /**
  18442. * Create a new RuntimeAnimation object
  18443. * @param target defines the target of the animation
  18444. * @param animation defines the source animation object
  18445. * @param scene defines the hosting scene
  18446. * @param host defines the initiating Animatable
  18447. */
  18448. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18449. /**
  18450. * Gets the animation from the runtime animation
  18451. */
  18452. readonly animation: Animation;
  18453. /**
  18454. * Resets the runtime animation to the beginning
  18455. * @param restoreOriginal defines whether to restore the target property to the original value
  18456. */
  18457. reset(restoreOriginal?: boolean): void;
  18458. /**
  18459. * Specifies if the runtime animation is stopped
  18460. * @returns Boolean specifying if the runtime animation is stopped
  18461. */
  18462. isStopped(): boolean;
  18463. /**
  18464. * Disposes of the runtime animation
  18465. */
  18466. dispose(): void;
  18467. /**
  18468. * Interpolates the animation from the current frame
  18469. * @param currentFrame The frame to interpolate the animation to
  18470. * @param repeatCount The number of times that the animation should loop
  18471. * @param loopMode The type of looping mode to use
  18472. * @param offsetValue Animation offset value
  18473. * @param highLimitValue The high limit value
  18474. * @returns The interpolated value
  18475. */
  18476. private _interpolate;
  18477. /**
  18478. * Apply the interpolated value to the target
  18479. * @param currentValue defines the value computed by the animation
  18480. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18481. */
  18482. setValue(currentValue: any, weight?: number): void;
  18483. private _setValue;
  18484. /**
  18485. * Gets the loop pmode of the runtime animation
  18486. * @returns Loop Mode
  18487. */
  18488. private _getCorrectLoopMode;
  18489. /**
  18490. * Move the current animation to a given frame
  18491. * @param frame defines the frame to move to
  18492. */
  18493. goToFrame(frame: number): void;
  18494. /**
  18495. * @hidden Internal use only
  18496. */
  18497. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18498. /**
  18499. * Execute the current animation
  18500. * @param delay defines the delay to add to the current frame
  18501. * @param from defines the lower bound of the animation range
  18502. * @param to defines the upper bound of the animation range
  18503. * @param loop defines if the current animation must loop
  18504. * @param speedRatio defines the current speed ratio
  18505. * @param weight defines the weight of the animation (default is -1 so no weight)
  18506. * @param onLoop optional callback called when animation loops
  18507. * @returns a boolean indicating if the animation is running
  18508. */
  18509. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  18510. }
  18511. }
  18512. declare module "babylonjs/Animations/animatable" {
  18513. import { Animation } from "babylonjs/Animations/animation";
  18514. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  18515. import { Nullable } from "babylonjs/types";
  18516. import { Observable } from "babylonjs/Misc/observable";
  18517. import { Scene } from "babylonjs/scene";
  18518. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  18519. import { Node } from "babylonjs/node";
  18520. /**
  18521. * Class used to store an actual running animation
  18522. */
  18523. export class Animatable {
  18524. /** defines the target object */
  18525. target: any;
  18526. /** defines the starting frame number (default is 0) */
  18527. fromFrame: number;
  18528. /** defines the ending frame number (default is 100) */
  18529. toFrame: number;
  18530. /** defines if the animation must loop (default is false) */
  18531. loopAnimation: boolean;
  18532. /** defines a callback to call when animation ends if it is not looping */
  18533. onAnimationEnd?: (() => void) | null | undefined;
  18534. /** defines a callback to call when animation loops */
  18535. onAnimationLoop?: (() => void) | null | undefined;
  18536. private _localDelayOffset;
  18537. private _pausedDelay;
  18538. private _runtimeAnimations;
  18539. private _paused;
  18540. private _scene;
  18541. private _speedRatio;
  18542. private _weight;
  18543. private _syncRoot;
  18544. /**
  18545. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18546. * This will only apply for non looping animation (default is true)
  18547. */
  18548. disposeOnEnd: boolean;
  18549. /**
  18550. * Gets a boolean indicating if the animation has started
  18551. */
  18552. animationStarted: boolean;
  18553. /**
  18554. * Observer raised when the animation ends
  18555. */
  18556. onAnimationEndObservable: Observable<Animatable>;
  18557. /**
  18558. * Observer raised when the animation loops
  18559. */
  18560. onAnimationLoopObservable: Observable<Animatable>;
  18561. /**
  18562. * Gets the root Animatable used to synchronize and normalize animations
  18563. */
  18564. readonly syncRoot: Animatable;
  18565. /**
  18566. * Gets the current frame of the first RuntimeAnimation
  18567. * Used to synchronize Animatables
  18568. */
  18569. readonly masterFrame: number;
  18570. /**
  18571. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18572. */
  18573. weight: number;
  18574. /**
  18575. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18576. */
  18577. speedRatio: number;
  18578. /**
  18579. * Creates a new Animatable
  18580. * @param scene defines the hosting scene
  18581. * @param target defines the target object
  18582. * @param fromFrame defines the starting frame number (default is 0)
  18583. * @param toFrame defines the ending frame number (default is 100)
  18584. * @param loopAnimation defines if the animation must loop (default is false)
  18585. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18586. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18587. * @param animations defines a group of animation to add to the new Animatable
  18588. * @param onAnimationLoop defines a callback to call when animation loops
  18589. */
  18590. constructor(scene: Scene,
  18591. /** defines the target object */
  18592. target: any,
  18593. /** defines the starting frame number (default is 0) */
  18594. fromFrame?: number,
  18595. /** defines the ending frame number (default is 100) */
  18596. toFrame?: number,
  18597. /** defines if the animation must loop (default is false) */
  18598. loopAnimation?: boolean, speedRatio?: number,
  18599. /** defines a callback to call when animation ends if it is not looping */
  18600. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  18601. /** defines a callback to call when animation loops */
  18602. onAnimationLoop?: (() => void) | null | undefined);
  18603. /**
  18604. * Synchronize and normalize current Animatable with a source Animatable
  18605. * This is useful when using animation weights and when animations are not of the same length
  18606. * @param root defines the root Animatable to synchronize with
  18607. * @returns the current Animatable
  18608. */
  18609. syncWith(root: Animatable): Animatable;
  18610. /**
  18611. * Gets the list of runtime animations
  18612. * @returns an array of RuntimeAnimation
  18613. */
  18614. getAnimations(): RuntimeAnimation[];
  18615. /**
  18616. * Adds more animations to the current animatable
  18617. * @param target defines the target of the animations
  18618. * @param animations defines the new animations to add
  18619. */
  18620. appendAnimations(target: any, animations: Animation[]): void;
  18621. /**
  18622. * Gets the source animation for a specific property
  18623. * @param property defines the propertyu to look for
  18624. * @returns null or the source animation for the given property
  18625. */
  18626. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  18627. /**
  18628. * Gets the runtime animation for a specific property
  18629. * @param property defines the propertyu to look for
  18630. * @returns null or the runtime animation for the given property
  18631. */
  18632. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  18633. /**
  18634. * Resets the animatable to its original state
  18635. */
  18636. reset(): void;
  18637. /**
  18638. * Allows the animatable to blend with current running animations
  18639. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18640. * @param blendingSpeed defines the blending speed to use
  18641. */
  18642. enableBlending(blendingSpeed: number): void;
  18643. /**
  18644. * Disable animation blending
  18645. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18646. */
  18647. disableBlending(): void;
  18648. /**
  18649. * Jump directly to a given frame
  18650. * @param frame defines the frame to jump to
  18651. */
  18652. goToFrame(frame: number): void;
  18653. /**
  18654. * Pause the animation
  18655. */
  18656. pause(): void;
  18657. /**
  18658. * Restart the animation
  18659. */
  18660. restart(): void;
  18661. private _raiseOnAnimationEnd;
  18662. /**
  18663. * Stop and delete the current animation
  18664. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  18665. * @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)
  18666. */
  18667. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  18668. /**
  18669. * Wait asynchronously for the animation to end
  18670. * @returns a promise which will be fullfilled when the animation ends
  18671. */
  18672. waitAsync(): Promise<Animatable>;
  18673. /** @hidden */
  18674. _animate(delay: number): boolean;
  18675. }
  18676. module "babylonjs/scene" {
  18677. interface Scene {
  18678. /** @hidden */
  18679. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  18680. /** @hidden */
  18681. _processLateAnimationBindingsForMatrices(holder: {
  18682. totalWeight: number;
  18683. animations: RuntimeAnimation[];
  18684. originalValue: Matrix;
  18685. }): any;
  18686. /** @hidden */
  18687. _processLateAnimationBindingsForQuaternions(holder: {
  18688. totalWeight: number;
  18689. animations: RuntimeAnimation[];
  18690. originalValue: Quaternion;
  18691. }, refQuaternion: Quaternion): Quaternion;
  18692. /** @hidden */
  18693. _processLateAnimationBindings(): void;
  18694. /**
  18695. * Will start the animation sequence of a given target
  18696. * @param target defines the target
  18697. * @param from defines from which frame should animation start
  18698. * @param to defines until which frame should animation run.
  18699. * @param weight defines the weight to apply to the animation (1.0 by default)
  18700. * @param loop defines if the animation loops
  18701. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18702. * @param onAnimationEnd defines the function to be executed when the animation ends
  18703. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18704. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18705. * @param onAnimationLoop defines the callback to call when an animation loops
  18706. * @returns the animatable object created for this animation
  18707. */
  18708. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18709. /**
  18710. * Will start the animation sequence of a given target
  18711. * @param target defines the target
  18712. * @param from defines from which frame should animation start
  18713. * @param to defines until which frame should animation run.
  18714. * @param loop defines if the animation loops
  18715. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18716. * @param onAnimationEnd defines the function to be executed when the animation ends
  18717. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18718. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18719. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  18720. * @param onAnimationLoop defines the callback to call when an animation loops
  18721. * @returns the animatable object created for this animation
  18722. */
  18723. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18724. /**
  18725. * Will start the animation sequence of a given target and its hierarchy
  18726. * @param target defines the target
  18727. * @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.
  18728. * @param from defines from which frame should animation start
  18729. * @param to defines until which frame should animation run.
  18730. * @param loop defines if the animation loops
  18731. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18732. * @param onAnimationEnd defines the function to be executed when the animation ends
  18733. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18734. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18735. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18736. * @param onAnimationLoop defines the callback to call when an animation loops
  18737. * @returns the list of created animatables
  18738. */
  18739. 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[];
  18740. /**
  18741. * Begin a new animation on a given node
  18742. * @param target defines the target where the animation will take place
  18743. * @param animations defines the list of animations to start
  18744. * @param from defines the initial value
  18745. * @param to defines the final value
  18746. * @param loop defines if you want animation to loop (off by default)
  18747. * @param speedRatio defines the speed ratio to apply to all animations
  18748. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18749. * @param onAnimationLoop defines the callback to call when an animation loops
  18750. * @returns the list of created animatables
  18751. */
  18752. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  18753. /**
  18754. * Begin a new animation on a given node and its hierarchy
  18755. * @param target defines the root node where the animation will take place
  18756. * @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.
  18757. * @param animations defines the list of animations to start
  18758. * @param from defines the initial value
  18759. * @param to defines the final value
  18760. * @param loop defines if you want animation to loop (off by default)
  18761. * @param speedRatio defines the speed ratio to apply to all animations
  18762. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18763. * @param onAnimationLoop defines the callback to call when an animation loops
  18764. * @returns the list of animatables created for all nodes
  18765. */
  18766. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  18767. /**
  18768. * Gets the animatable associated with a specific target
  18769. * @param target defines the target of the animatable
  18770. * @returns the required animatable if found
  18771. */
  18772. getAnimatableByTarget(target: any): Nullable<Animatable>;
  18773. /**
  18774. * Gets all animatables associated with a given target
  18775. * @param target defines the target to look animatables for
  18776. * @returns an array of Animatables
  18777. */
  18778. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  18779. /**
  18780. * Will stop the animation of the given target
  18781. * @param target - the target
  18782. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  18783. * @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)
  18784. */
  18785. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  18786. /**
  18787. * Stops and removes all animations that have been applied to the scene
  18788. */
  18789. stopAllAnimations(): void;
  18790. }
  18791. }
  18792. module "babylonjs/Bones/bone" {
  18793. interface Bone {
  18794. /**
  18795. * Copy an animation range from another bone
  18796. * @param source defines the source bone
  18797. * @param rangeName defines the range name to copy
  18798. * @param frameOffset defines the frame offset
  18799. * @param rescaleAsRequired defines if rescaling must be applied if required
  18800. * @param skelDimensionsRatio defines the scaling ratio
  18801. * @returns true if operation was successful
  18802. */
  18803. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  18804. }
  18805. }
  18806. }
  18807. declare module "babylonjs/Bones/skeleton" {
  18808. import { Bone } from "babylonjs/Bones/bone";
  18809. import { IAnimatable } from "babylonjs/Misc/tools";
  18810. import { Observable } from "babylonjs/Misc/observable";
  18811. import { Vector3, Matrix } from "babylonjs/Maths/math";
  18812. import { Scene } from "babylonjs/scene";
  18813. import { Nullable } from "babylonjs/types";
  18814. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18815. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  18816. import { Animatable } from "babylonjs/Animations/animatable";
  18817. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  18818. import { Animation } from "babylonjs/Animations/animation";
  18819. import { AnimationRange } from "babylonjs/Animations/animationRange";
  18820. /**
  18821. * Class used to handle skinning animations
  18822. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  18823. */
  18824. export class Skeleton implements IAnimatable {
  18825. /** defines the skeleton name */
  18826. name: string;
  18827. /** defines the skeleton Id */
  18828. id: string;
  18829. /**
  18830. * Defines the list of child bones
  18831. */
  18832. bones: Bone[];
  18833. /**
  18834. * Defines an estimate of the dimension of the skeleton at rest
  18835. */
  18836. dimensionsAtRest: Vector3;
  18837. /**
  18838. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  18839. */
  18840. needInitialSkinMatrix: boolean;
  18841. /**
  18842. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  18843. */
  18844. overrideMesh: Nullable<AbstractMesh>;
  18845. /**
  18846. * Gets the list of animations attached to this skeleton
  18847. */
  18848. animations: Array<Animation>;
  18849. private _scene;
  18850. private _isDirty;
  18851. private _transformMatrices;
  18852. private _transformMatrixTexture;
  18853. private _meshesWithPoseMatrix;
  18854. private _animatables;
  18855. private _identity;
  18856. private _synchronizedWithMesh;
  18857. private _ranges;
  18858. private _lastAbsoluteTransformsUpdateId;
  18859. private _canUseTextureForBones;
  18860. /** @hidden */
  18861. _numBonesWithLinkedTransformNode: number;
  18862. /**
  18863. * Specifies if the skeleton should be serialized
  18864. */
  18865. doNotSerialize: boolean;
  18866. /**
  18867. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  18868. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  18869. */
  18870. useTextureToStoreBoneMatrices: boolean;
  18871. private _animationPropertiesOverride;
  18872. /**
  18873. * Gets or sets the animation properties override
  18874. */
  18875. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18876. /**
  18877. * An observable triggered before computing the skeleton's matrices
  18878. */
  18879. onBeforeComputeObservable: Observable<Skeleton>;
  18880. /**
  18881. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  18882. */
  18883. readonly isUsingTextureForMatrices: boolean;
  18884. /**
  18885. * Creates a new skeleton
  18886. * @param name defines the skeleton name
  18887. * @param id defines the skeleton Id
  18888. * @param scene defines the hosting scene
  18889. */
  18890. constructor(
  18891. /** defines the skeleton name */
  18892. name: string,
  18893. /** defines the skeleton Id */
  18894. id: string, scene: Scene);
  18895. /**
  18896. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  18897. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  18898. * @returns a Float32Array containing matrices data
  18899. */
  18900. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  18901. /**
  18902. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  18903. * @returns a raw texture containing the data
  18904. */
  18905. getTransformMatrixTexture(): Nullable<RawTexture>;
  18906. /**
  18907. * Gets the current hosting scene
  18908. * @returns a scene object
  18909. */
  18910. getScene(): Scene;
  18911. /**
  18912. * Gets a string representing the current skeleton data
  18913. * @param fullDetails defines a boolean indicating if we want a verbose version
  18914. * @returns a string representing the current skeleton data
  18915. */
  18916. toString(fullDetails?: boolean): string;
  18917. /**
  18918. * Get bone's index searching by name
  18919. * @param name defines bone's name to search for
  18920. * @return the indice of the bone. Returns -1 if not found
  18921. */
  18922. getBoneIndexByName(name: string): number;
  18923. /**
  18924. * Creater a new animation range
  18925. * @param name defines the name of the range
  18926. * @param from defines the start key
  18927. * @param to defines the end key
  18928. */
  18929. createAnimationRange(name: string, from: number, to: number): void;
  18930. /**
  18931. * Delete a specific animation range
  18932. * @param name defines the name of the range
  18933. * @param deleteFrames defines if frames must be removed as well
  18934. */
  18935. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  18936. /**
  18937. * Gets a specific animation range
  18938. * @param name defines the name of the range to look for
  18939. * @returns the requested animation range or null if not found
  18940. */
  18941. getAnimationRange(name: string): Nullable<AnimationRange>;
  18942. /**
  18943. * Gets the list of all animation ranges defined on this skeleton
  18944. * @returns an array
  18945. */
  18946. getAnimationRanges(): Nullable<AnimationRange>[];
  18947. /**
  18948. * Copy animation range from a source skeleton.
  18949. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  18950. * @param source defines the source skeleton
  18951. * @param name defines the name of the range to copy
  18952. * @param rescaleAsRequired defines if rescaling must be applied if required
  18953. * @returns true if operation was successful
  18954. */
  18955. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  18956. /**
  18957. * Forces the skeleton to go to rest pose
  18958. */
  18959. returnToRest(): void;
  18960. private _getHighestAnimationFrame;
  18961. /**
  18962. * Begin a specific animation range
  18963. * @param name defines the name of the range to start
  18964. * @param loop defines if looping must be turned on (false by default)
  18965. * @param speedRatio defines the speed ratio to apply (1 by default)
  18966. * @param onAnimationEnd defines a callback which will be called when animation will end
  18967. * @returns a new animatable
  18968. */
  18969. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  18970. /** @hidden */
  18971. _markAsDirty(): void;
  18972. /** @hidden */
  18973. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  18974. /** @hidden */
  18975. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  18976. private _computeTransformMatrices;
  18977. /**
  18978. * Build all resources required to render a skeleton
  18979. */
  18980. prepare(): void;
  18981. /**
  18982. * Gets the list of animatables currently running for this skeleton
  18983. * @returns an array of animatables
  18984. */
  18985. getAnimatables(): IAnimatable[];
  18986. /**
  18987. * Clone the current skeleton
  18988. * @param name defines the name of the new skeleton
  18989. * @param id defines the id of the enw skeleton
  18990. * @returns the new skeleton
  18991. */
  18992. clone(name: string, id: string): Skeleton;
  18993. /**
  18994. * Enable animation blending for this skeleton
  18995. * @param blendingSpeed defines the blending speed to apply
  18996. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18997. */
  18998. enableBlending(blendingSpeed?: number): void;
  18999. /**
  19000. * Releases all resources associated with the current skeleton
  19001. */
  19002. dispose(): void;
  19003. /**
  19004. * Serialize the skeleton in a JSON object
  19005. * @returns a JSON object
  19006. */
  19007. serialize(): any;
  19008. /**
  19009. * Creates a new skeleton from serialized data
  19010. * @param parsedSkeleton defines the serialized data
  19011. * @param scene defines the hosting scene
  19012. * @returns a new skeleton
  19013. */
  19014. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19015. /**
  19016. * Compute all node absolute transforms
  19017. * @param forceUpdate defines if computation must be done even if cache is up to date
  19018. */
  19019. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19020. /**
  19021. * Gets the root pose matrix
  19022. * @returns a matrix
  19023. */
  19024. getPoseMatrix(): Nullable<Matrix>;
  19025. /**
  19026. * Sorts bones per internal index
  19027. */
  19028. sortBones(): void;
  19029. private _sortBones;
  19030. }
  19031. }
  19032. declare module "babylonjs/Morph/morphTarget" {
  19033. import { IAnimatable } from "babylonjs/Misc/tools";
  19034. import { Observable } from "babylonjs/Misc/observable";
  19035. import { Nullable, FloatArray } from "babylonjs/types";
  19036. import { Scene } from "babylonjs/scene";
  19037. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19038. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19039. /**
  19040. * Defines a target to use with MorphTargetManager
  19041. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19042. */
  19043. export class MorphTarget implements IAnimatable {
  19044. /** defines the name of the target */
  19045. name: string;
  19046. /**
  19047. * Gets or sets the list of animations
  19048. */
  19049. animations: import("babylonjs/Animations/animation").Animation[];
  19050. private _scene;
  19051. private _positions;
  19052. private _normals;
  19053. private _tangents;
  19054. private _influence;
  19055. /**
  19056. * Observable raised when the influence changes
  19057. */
  19058. onInfluenceChanged: Observable<boolean>;
  19059. /** @hidden */
  19060. _onDataLayoutChanged: Observable<void>;
  19061. /**
  19062. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19063. */
  19064. influence: number;
  19065. /**
  19066. * Gets or sets the id of the morph Target
  19067. */
  19068. id: string;
  19069. private _animationPropertiesOverride;
  19070. /**
  19071. * Gets or sets the animation properties override
  19072. */
  19073. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19074. /**
  19075. * Creates a new MorphTarget
  19076. * @param name defines the name of the target
  19077. * @param influence defines the influence to use
  19078. * @param scene defines the scene the morphtarget belongs to
  19079. */
  19080. constructor(
  19081. /** defines the name of the target */
  19082. name: string, influence?: number, scene?: Nullable<Scene>);
  19083. /**
  19084. * Gets a boolean defining if the target contains position data
  19085. */
  19086. readonly hasPositions: boolean;
  19087. /**
  19088. * Gets a boolean defining if the target contains normal data
  19089. */
  19090. readonly hasNormals: boolean;
  19091. /**
  19092. * Gets a boolean defining if the target contains tangent data
  19093. */
  19094. readonly hasTangents: boolean;
  19095. /**
  19096. * Affects position data to this target
  19097. * @param data defines the position data to use
  19098. */
  19099. setPositions(data: Nullable<FloatArray>): void;
  19100. /**
  19101. * Gets the position data stored in this target
  19102. * @returns a FloatArray containing the position data (or null if not present)
  19103. */
  19104. getPositions(): Nullable<FloatArray>;
  19105. /**
  19106. * Affects normal data to this target
  19107. * @param data defines the normal data to use
  19108. */
  19109. setNormals(data: Nullable<FloatArray>): void;
  19110. /**
  19111. * Gets the normal data stored in this target
  19112. * @returns a FloatArray containing the normal data (or null if not present)
  19113. */
  19114. getNormals(): Nullable<FloatArray>;
  19115. /**
  19116. * Affects tangent data to this target
  19117. * @param data defines the tangent data to use
  19118. */
  19119. setTangents(data: Nullable<FloatArray>): void;
  19120. /**
  19121. * Gets the tangent data stored in this target
  19122. * @returns a FloatArray containing the tangent data (or null if not present)
  19123. */
  19124. getTangents(): Nullable<FloatArray>;
  19125. /**
  19126. * Serializes the current target into a Serialization object
  19127. * @returns the serialized object
  19128. */
  19129. serialize(): any;
  19130. /**
  19131. * Returns the string "MorphTarget"
  19132. * @returns "MorphTarget"
  19133. */
  19134. getClassName(): string;
  19135. /**
  19136. * Creates a new target from serialized data
  19137. * @param serializationObject defines the serialized data to use
  19138. * @returns a new MorphTarget
  19139. */
  19140. static Parse(serializationObject: any): MorphTarget;
  19141. /**
  19142. * Creates a MorphTarget from mesh data
  19143. * @param mesh defines the source mesh
  19144. * @param name defines the name to use for the new target
  19145. * @param influence defines the influence to attach to the target
  19146. * @returns a new MorphTarget
  19147. */
  19148. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19149. }
  19150. }
  19151. declare module "babylonjs/Morph/morphTargetManager" {
  19152. import { Nullable } from "babylonjs/types";
  19153. import { Scene } from "babylonjs/scene";
  19154. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  19155. /**
  19156. * This class is used to deform meshes using morphing between different targets
  19157. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19158. */
  19159. export class MorphTargetManager {
  19160. private _targets;
  19161. private _targetInfluenceChangedObservers;
  19162. private _targetDataLayoutChangedObservers;
  19163. private _activeTargets;
  19164. private _scene;
  19165. private _influences;
  19166. private _supportsNormals;
  19167. private _supportsTangents;
  19168. private _vertexCount;
  19169. private _uniqueId;
  19170. private _tempInfluences;
  19171. /**
  19172. * Creates a new MorphTargetManager
  19173. * @param scene defines the current scene
  19174. */
  19175. constructor(scene?: Nullable<Scene>);
  19176. /**
  19177. * Gets the unique ID of this manager
  19178. */
  19179. readonly uniqueId: number;
  19180. /**
  19181. * Gets the number of vertices handled by this manager
  19182. */
  19183. readonly vertexCount: number;
  19184. /**
  19185. * Gets a boolean indicating if this manager supports morphing of normals
  19186. */
  19187. readonly supportsNormals: boolean;
  19188. /**
  19189. * Gets a boolean indicating if this manager supports morphing of tangents
  19190. */
  19191. readonly supportsTangents: boolean;
  19192. /**
  19193. * Gets the number of targets stored in this manager
  19194. */
  19195. readonly numTargets: number;
  19196. /**
  19197. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19198. */
  19199. readonly numInfluencers: number;
  19200. /**
  19201. * Gets the list of influences (one per target)
  19202. */
  19203. readonly influences: Float32Array;
  19204. /**
  19205. * Gets the active target at specified index. An active target is a target with an influence > 0
  19206. * @param index defines the index to check
  19207. * @returns the requested target
  19208. */
  19209. getActiveTarget(index: number): MorphTarget;
  19210. /**
  19211. * Gets the target at specified index
  19212. * @param index defines the index to check
  19213. * @returns the requested target
  19214. */
  19215. getTarget(index: number): MorphTarget;
  19216. /**
  19217. * Add a new target to this manager
  19218. * @param target defines the target to add
  19219. */
  19220. addTarget(target: MorphTarget): void;
  19221. /**
  19222. * Removes a target from the manager
  19223. * @param target defines the target to remove
  19224. */
  19225. removeTarget(target: MorphTarget): void;
  19226. /**
  19227. * Serializes the current manager into a Serialization object
  19228. * @returns the serialized object
  19229. */
  19230. serialize(): any;
  19231. private _syncActiveTargets;
  19232. /**
  19233. * Syncrhonize the targets with all the meshes using this morph target manager
  19234. */
  19235. synchronize(): void;
  19236. /**
  19237. * Creates a new MorphTargetManager from serialized data
  19238. * @param serializationObject defines the serialized data
  19239. * @param scene defines the hosting scene
  19240. * @returns the new MorphTargetManager
  19241. */
  19242. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19243. }
  19244. }
  19245. declare module "babylonjs/Meshes/groundMesh" {
  19246. import { Scene } from "babylonjs/scene";
  19247. import { Vector3 } from "babylonjs/Maths/math";
  19248. import { Mesh } from "babylonjs/Meshes/mesh";
  19249. /**
  19250. * Mesh representing the gorund
  19251. */
  19252. export class GroundMesh extends Mesh {
  19253. /** If octree should be generated */
  19254. generateOctree: boolean;
  19255. private _heightQuads;
  19256. /** @hidden */
  19257. _subdivisionsX: number;
  19258. /** @hidden */
  19259. _subdivisionsY: number;
  19260. /** @hidden */
  19261. _width: number;
  19262. /** @hidden */
  19263. _height: number;
  19264. /** @hidden */
  19265. _minX: number;
  19266. /** @hidden */
  19267. _maxX: number;
  19268. /** @hidden */
  19269. _minZ: number;
  19270. /** @hidden */
  19271. _maxZ: number;
  19272. constructor(name: string, scene: Scene);
  19273. /**
  19274. * "GroundMesh"
  19275. * @returns "GroundMesh"
  19276. */
  19277. getClassName(): string;
  19278. /**
  19279. * The minimum of x and y subdivisions
  19280. */
  19281. readonly subdivisions: number;
  19282. /**
  19283. * X subdivisions
  19284. */
  19285. readonly subdivisionsX: number;
  19286. /**
  19287. * Y subdivisions
  19288. */
  19289. readonly subdivisionsY: number;
  19290. /**
  19291. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19292. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19293. * @param chunksCount the number of subdivisions for x and y
  19294. * @param octreeBlocksSize (Default: 32)
  19295. */
  19296. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19297. /**
  19298. * Returns a height (y) value in the Worl system :
  19299. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19300. * @param x x coordinate
  19301. * @param z z coordinate
  19302. * @returns the ground y position if (x, z) are outside the ground surface.
  19303. */
  19304. getHeightAtCoordinates(x: number, z: number): number;
  19305. /**
  19306. * Returns a normalized vector (Vector3) orthogonal to the ground
  19307. * at the ground coordinates (x, z) expressed in the World system.
  19308. * @param x x coordinate
  19309. * @param z z coordinate
  19310. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19311. */
  19312. getNormalAtCoordinates(x: number, z: number): Vector3;
  19313. /**
  19314. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19315. * at the ground coordinates (x, z) expressed in the World system.
  19316. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19317. * @param x x coordinate
  19318. * @param z z coordinate
  19319. * @param ref vector to store the result
  19320. * @returns the GroundMesh.
  19321. */
  19322. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19323. /**
  19324. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19325. * if the ground has been updated.
  19326. * This can be used in the render loop.
  19327. * @returns the GroundMesh.
  19328. */
  19329. updateCoordinateHeights(): GroundMesh;
  19330. private _getFacetAt;
  19331. private _initHeightQuads;
  19332. private _computeHeightQuads;
  19333. /**
  19334. * Serializes this ground mesh
  19335. * @param serializationObject object to write serialization to
  19336. */
  19337. serialize(serializationObject: any): void;
  19338. /**
  19339. * Parses a serialized ground mesh
  19340. * @param parsedMesh the serialized mesh
  19341. * @param scene the scene to create the ground mesh in
  19342. * @returns the created ground mesh
  19343. */
  19344. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19345. }
  19346. }
  19347. declare module "babylonjs/Physics/physicsJoint" {
  19348. import { Vector3 } from "babylonjs/Maths/math";
  19349. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  19350. /**
  19351. * Interface for Physics-Joint data
  19352. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19353. */
  19354. export interface PhysicsJointData {
  19355. /**
  19356. * The main pivot of the joint
  19357. */
  19358. mainPivot?: Vector3;
  19359. /**
  19360. * The connected pivot of the joint
  19361. */
  19362. connectedPivot?: Vector3;
  19363. /**
  19364. * The main axis of the joint
  19365. */
  19366. mainAxis?: Vector3;
  19367. /**
  19368. * The connected axis of the joint
  19369. */
  19370. connectedAxis?: Vector3;
  19371. /**
  19372. * The collision of the joint
  19373. */
  19374. collision?: boolean;
  19375. /**
  19376. * Native Oimo/Cannon/Energy data
  19377. */
  19378. nativeParams?: any;
  19379. }
  19380. /**
  19381. * This is a holder class for the physics joint created by the physics plugin
  19382. * It holds a set of functions to control the underlying joint
  19383. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19384. */
  19385. export class PhysicsJoint {
  19386. /**
  19387. * The type of the physics joint
  19388. */
  19389. type: number;
  19390. /**
  19391. * The data for the physics joint
  19392. */
  19393. jointData: PhysicsJointData;
  19394. private _physicsJoint;
  19395. protected _physicsPlugin: IPhysicsEnginePlugin;
  19396. /**
  19397. * Initializes the physics joint
  19398. * @param type The type of the physics joint
  19399. * @param jointData The data for the physics joint
  19400. */
  19401. constructor(
  19402. /**
  19403. * The type of the physics joint
  19404. */
  19405. type: number,
  19406. /**
  19407. * The data for the physics joint
  19408. */
  19409. jointData: PhysicsJointData);
  19410. /**
  19411. * Gets the physics joint
  19412. */
  19413. /**
  19414. * Sets the physics joint
  19415. */
  19416. physicsJoint: any;
  19417. /**
  19418. * Sets the physics plugin
  19419. */
  19420. physicsPlugin: IPhysicsEnginePlugin;
  19421. /**
  19422. * Execute a function that is physics-plugin specific.
  19423. * @param {Function} func the function that will be executed.
  19424. * It accepts two parameters: the physics world and the physics joint
  19425. */
  19426. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19427. /**
  19428. * Distance-Joint type
  19429. */
  19430. static DistanceJoint: number;
  19431. /**
  19432. * Hinge-Joint type
  19433. */
  19434. static HingeJoint: number;
  19435. /**
  19436. * Ball-and-Socket joint type
  19437. */
  19438. static BallAndSocketJoint: number;
  19439. /**
  19440. * Wheel-Joint type
  19441. */
  19442. static WheelJoint: number;
  19443. /**
  19444. * Slider-Joint type
  19445. */
  19446. static SliderJoint: number;
  19447. /**
  19448. * Prismatic-Joint type
  19449. */
  19450. static PrismaticJoint: number;
  19451. /**
  19452. * Universal-Joint type
  19453. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19454. */
  19455. static UniversalJoint: number;
  19456. /**
  19457. * Hinge-Joint 2 type
  19458. */
  19459. static Hinge2Joint: number;
  19460. /**
  19461. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19462. */
  19463. static PointToPointJoint: number;
  19464. /**
  19465. * Spring-Joint type
  19466. */
  19467. static SpringJoint: number;
  19468. /**
  19469. * Lock-Joint type
  19470. */
  19471. static LockJoint: number;
  19472. }
  19473. /**
  19474. * A class representing a physics distance joint
  19475. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19476. */
  19477. export class DistanceJoint extends PhysicsJoint {
  19478. /**
  19479. *
  19480. * @param jointData The data for the Distance-Joint
  19481. */
  19482. constructor(jointData: DistanceJointData);
  19483. /**
  19484. * Update the predefined distance.
  19485. * @param maxDistance The maximum preferred distance
  19486. * @param minDistance The minimum preferred distance
  19487. */
  19488. updateDistance(maxDistance: number, minDistance?: number): void;
  19489. }
  19490. /**
  19491. * Represents a Motor-Enabled Joint
  19492. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19493. */
  19494. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19495. /**
  19496. * Initializes the Motor-Enabled Joint
  19497. * @param type The type of the joint
  19498. * @param jointData The physica joint data for the joint
  19499. */
  19500. constructor(type: number, jointData: PhysicsJointData);
  19501. /**
  19502. * Set the motor values.
  19503. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19504. * @param force the force to apply
  19505. * @param maxForce max force for this motor.
  19506. */
  19507. setMotor(force?: number, maxForce?: number): void;
  19508. /**
  19509. * Set the motor's limits.
  19510. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19511. * @param upperLimit The upper limit of the motor
  19512. * @param lowerLimit The lower limit of the motor
  19513. */
  19514. setLimit(upperLimit: number, lowerLimit?: number): void;
  19515. }
  19516. /**
  19517. * This class represents a single physics Hinge-Joint
  19518. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19519. */
  19520. export class HingeJoint extends MotorEnabledJoint {
  19521. /**
  19522. * Initializes the Hinge-Joint
  19523. * @param jointData The joint data for the Hinge-Joint
  19524. */
  19525. constructor(jointData: PhysicsJointData);
  19526. /**
  19527. * Set the motor values.
  19528. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19529. * @param {number} force the force to apply
  19530. * @param {number} maxForce max force for this motor.
  19531. */
  19532. setMotor(force?: number, maxForce?: number): void;
  19533. /**
  19534. * Set the motor's limits.
  19535. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19536. * @param upperLimit The upper limit of the motor
  19537. * @param lowerLimit The lower limit of the motor
  19538. */
  19539. setLimit(upperLimit: number, lowerLimit?: number): void;
  19540. }
  19541. /**
  19542. * This class represents a dual hinge physics joint (same as wheel joint)
  19543. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19544. */
  19545. export class Hinge2Joint extends MotorEnabledJoint {
  19546. /**
  19547. * Initializes the Hinge2-Joint
  19548. * @param jointData The joint data for the Hinge2-Joint
  19549. */
  19550. constructor(jointData: PhysicsJointData);
  19551. /**
  19552. * Set the motor values.
  19553. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19554. * @param {number} targetSpeed the speed the motor is to reach
  19555. * @param {number} maxForce max force for this motor.
  19556. * @param {motorIndex} the motor's index, 0 or 1.
  19557. */
  19558. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19559. /**
  19560. * Set the motor limits.
  19561. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19562. * @param {number} upperLimit the upper limit
  19563. * @param {number} lowerLimit lower limit
  19564. * @param {motorIndex} the motor's index, 0 or 1.
  19565. */
  19566. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19567. }
  19568. /**
  19569. * Interface for a motor enabled joint
  19570. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19571. */
  19572. export interface IMotorEnabledJoint {
  19573. /**
  19574. * Physics joint
  19575. */
  19576. physicsJoint: any;
  19577. /**
  19578. * Sets the motor of the motor-enabled joint
  19579. * @param force The force of the motor
  19580. * @param maxForce The maximum force of the motor
  19581. * @param motorIndex The index of the motor
  19582. */
  19583. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19584. /**
  19585. * Sets the limit of the motor
  19586. * @param upperLimit The upper limit of the motor
  19587. * @param lowerLimit The lower limit of the motor
  19588. * @param motorIndex The index of the motor
  19589. */
  19590. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19591. }
  19592. /**
  19593. * Joint data for a Distance-Joint
  19594. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19595. */
  19596. export interface DistanceJointData extends PhysicsJointData {
  19597. /**
  19598. * Max distance the 2 joint objects can be apart
  19599. */
  19600. maxDistance: number;
  19601. }
  19602. /**
  19603. * Joint data from a spring joint
  19604. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19605. */
  19606. export interface SpringJointData extends PhysicsJointData {
  19607. /**
  19608. * Length of the spring
  19609. */
  19610. length: number;
  19611. /**
  19612. * Stiffness of the spring
  19613. */
  19614. stiffness: number;
  19615. /**
  19616. * Damping of the spring
  19617. */
  19618. damping: number;
  19619. /** this callback will be called when applying the force to the impostors. */
  19620. forceApplicationCallback: () => void;
  19621. }
  19622. }
  19623. declare module "babylonjs/Physics/IPhysicsEngine" {
  19624. import { Nullable } from "babylonjs/types";
  19625. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  19626. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19627. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  19628. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  19629. /**
  19630. * Interface used to describe a physics joint
  19631. */
  19632. export interface PhysicsImpostorJoint {
  19633. /** Defines the main impostor to which the joint is linked */
  19634. mainImpostor: PhysicsImpostor;
  19635. /** Defines the impostor that is connected to the main impostor using this joint */
  19636. connectedImpostor: PhysicsImpostor;
  19637. /** Defines the joint itself */
  19638. joint: PhysicsJoint;
  19639. }
  19640. /** @hidden */
  19641. export interface IPhysicsEnginePlugin {
  19642. world: any;
  19643. name: string;
  19644. setGravity(gravity: Vector3): void;
  19645. setTimeStep(timeStep: number): void;
  19646. getTimeStep(): number;
  19647. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  19648. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19649. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19650. generatePhysicsBody(impostor: PhysicsImpostor): void;
  19651. removePhysicsBody(impostor: PhysicsImpostor): void;
  19652. generateJoint(joint: PhysicsImpostorJoint): void;
  19653. removeJoint(joint: PhysicsImpostorJoint): void;
  19654. isSupported(): boolean;
  19655. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  19656. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  19657. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19658. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19659. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19660. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19661. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  19662. getBodyMass(impostor: PhysicsImpostor): number;
  19663. getBodyFriction(impostor: PhysicsImpostor): number;
  19664. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  19665. getBodyRestitution(impostor: PhysicsImpostor): number;
  19666. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  19667. sleepBody(impostor: PhysicsImpostor): void;
  19668. wakeUpBody(impostor: PhysicsImpostor): void;
  19669. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  19670. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  19671. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19672. getRadius(impostor: PhysicsImpostor): number;
  19673. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  19674. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  19675. dispose(): void;
  19676. }
  19677. /**
  19678. * Interface used to define a physics engine
  19679. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19680. */
  19681. export interface IPhysicsEngine {
  19682. /**
  19683. * Gets the gravity vector used by the simulation
  19684. */
  19685. gravity: Vector3;
  19686. /**
  19687. * Sets the gravity vector used by the simulation
  19688. * @param gravity defines the gravity vector to use
  19689. */
  19690. setGravity(gravity: Vector3): void;
  19691. /**
  19692. * Set the time step of the physics engine.
  19693. * Default is 1/60.
  19694. * To slow it down, enter 1/600 for example.
  19695. * To speed it up, 1/30
  19696. * @param newTimeStep the new timestep to apply to this world.
  19697. */
  19698. setTimeStep(newTimeStep: number): void;
  19699. /**
  19700. * Get the time step of the physics engine.
  19701. * @returns the current time step
  19702. */
  19703. getTimeStep(): number;
  19704. /**
  19705. * Release all resources
  19706. */
  19707. dispose(): void;
  19708. /**
  19709. * Gets the name of the current physics plugin
  19710. * @returns the name of the plugin
  19711. */
  19712. getPhysicsPluginName(): string;
  19713. /**
  19714. * Adding a new impostor for the impostor tracking.
  19715. * This will be done by the impostor itself.
  19716. * @param impostor the impostor to add
  19717. */
  19718. addImpostor(impostor: PhysicsImpostor): void;
  19719. /**
  19720. * Remove an impostor from the engine.
  19721. * This impostor and its mesh will not longer be updated by the physics engine.
  19722. * @param impostor the impostor to remove
  19723. */
  19724. removeImpostor(impostor: PhysicsImpostor): void;
  19725. /**
  19726. * Add a joint to the physics engine
  19727. * @param mainImpostor defines the main impostor to which the joint is added.
  19728. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  19729. * @param joint defines the joint that will connect both impostors.
  19730. */
  19731. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19732. /**
  19733. * Removes a joint from the simulation
  19734. * @param mainImpostor defines the impostor used with the joint
  19735. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  19736. * @param joint defines the joint to remove
  19737. */
  19738. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19739. /**
  19740. * Gets the current plugin used to run the simulation
  19741. * @returns current plugin
  19742. */
  19743. getPhysicsPlugin(): IPhysicsEnginePlugin;
  19744. /**
  19745. * Gets the list of physic impostors
  19746. * @returns an array of PhysicsImpostor
  19747. */
  19748. getImpostors(): Array<PhysicsImpostor>;
  19749. /**
  19750. * Gets the impostor for a physics enabled object
  19751. * @param object defines the object impersonated by the impostor
  19752. * @returns the PhysicsImpostor or null if not found
  19753. */
  19754. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19755. /**
  19756. * Gets the impostor for a physics body object
  19757. * @param body defines physics body used by the impostor
  19758. * @returns the PhysicsImpostor or null if not found
  19759. */
  19760. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  19761. /**
  19762. * Called by the scene. No need to call it.
  19763. * @param delta defines the timespam between frames
  19764. */
  19765. _step(delta: number): void;
  19766. }
  19767. }
  19768. declare module "babylonjs/Physics/physicsImpostor" {
  19769. import { Nullable, IndicesArray } from "babylonjs/types";
  19770. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  19771. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19772. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19773. import { Scene } from "babylonjs/scene";
  19774. import { Bone } from "babylonjs/Bones/bone";
  19775. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  19776. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  19777. /**
  19778. * The interface for the physics imposter parameters
  19779. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19780. */
  19781. export interface PhysicsImpostorParameters {
  19782. /**
  19783. * The mass of the physics imposter
  19784. */
  19785. mass: number;
  19786. /**
  19787. * The friction of the physics imposter
  19788. */
  19789. friction?: number;
  19790. /**
  19791. * The coefficient of restitution of the physics imposter
  19792. */
  19793. restitution?: number;
  19794. /**
  19795. * The native options of the physics imposter
  19796. */
  19797. nativeOptions?: any;
  19798. /**
  19799. * Specifies if the parent should be ignored
  19800. */
  19801. ignoreParent?: boolean;
  19802. /**
  19803. * Specifies if bi-directional transformations should be disabled
  19804. */
  19805. disableBidirectionalTransformation?: boolean;
  19806. }
  19807. /**
  19808. * Interface for a physics-enabled object
  19809. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19810. */
  19811. export interface IPhysicsEnabledObject {
  19812. /**
  19813. * The position of the physics-enabled object
  19814. */
  19815. position: Vector3;
  19816. /**
  19817. * The rotation of the physics-enabled object
  19818. */
  19819. rotationQuaternion: Nullable<Quaternion>;
  19820. /**
  19821. * The scale of the physics-enabled object
  19822. */
  19823. scaling: Vector3;
  19824. /**
  19825. * The rotation of the physics-enabled object
  19826. */
  19827. rotation?: Vector3;
  19828. /**
  19829. * The parent of the physics-enabled object
  19830. */
  19831. parent?: any;
  19832. /**
  19833. * The bounding info of the physics-enabled object
  19834. * @returns The bounding info of the physics-enabled object
  19835. */
  19836. getBoundingInfo(): BoundingInfo;
  19837. /**
  19838. * Computes the world matrix
  19839. * @param force Specifies if the world matrix should be computed by force
  19840. * @returns A world matrix
  19841. */
  19842. computeWorldMatrix(force: boolean): Matrix;
  19843. /**
  19844. * Gets the world matrix
  19845. * @returns A world matrix
  19846. */
  19847. getWorldMatrix?(): Matrix;
  19848. /**
  19849. * Gets the child meshes
  19850. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  19851. * @returns An array of abstract meshes
  19852. */
  19853. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  19854. /**
  19855. * Gets the vertex data
  19856. * @param kind The type of vertex data
  19857. * @returns A nullable array of numbers, or a float32 array
  19858. */
  19859. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  19860. /**
  19861. * Gets the indices from the mesh
  19862. * @returns A nullable array of index arrays
  19863. */
  19864. getIndices?(): Nullable<IndicesArray>;
  19865. /**
  19866. * Gets the scene from the mesh
  19867. * @returns the indices array or null
  19868. */
  19869. getScene?(): Scene;
  19870. /**
  19871. * Gets the absolute position from the mesh
  19872. * @returns the absolute position
  19873. */
  19874. getAbsolutePosition(): Vector3;
  19875. /**
  19876. * Gets the absolute pivot point from the mesh
  19877. * @returns the absolute pivot point
  19878. */
  19879. getAbsolutePivotPoint(): Vector3;
  19880. /**
  19881. * Rotates the mesh
  19882. * @param axis The axis of rotation
  19883. * @param amount The amount of rotation
  19884. * @param space The space of the rotation
  19885. * @returns The rotation transform node
  19886. */
  19887. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  19888. /**
  19889. * Translates the mesh
  19890. * @param axis The axis of translation
  19891. * @param distance The distance of translation
  19892. * @param space The space of the translation
  19893. * @returns The transform node
  19894. */
  19895. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  19896. /**
  19897. * Sets the absolute position of the mesh
  19898. * @param absolutePosition The absolute position of the mesh
  19899. * @returns The transform node
  19900. */
  19901. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  19902. /**
  19903. * Gets the class name of the mesh
  19904. * @returns The class name
  19905. */
  19906. getClassName(): string;
  19907. }
  19908. /**
  19909. * Represents a physics imposter
  19910. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19911. */
  19912. export class PhysicsImpostor {
  19913. /**
  19914. * The physics-enabled object used as the physics imposter
  19915. */
  19916. object: IPhysicsEnabledObject;
  19917. /**
  19918. * The type of the physics imposter
  19919. */
  19920. type: number;
  19921. private _options;
  19922. private _scene?;
  19923. /**
  19924. * The default object size of the imposter
  19925. */
  19926. static DEFAULT_OBJECT_SIZE: Vector3;
  19927. /**
  19928. * The identity quaternion of the imposter
  19929. */
  19930. static IDENTITY_QUATERNION: Quaternion;
  19931. /** @hidden */
  19932. _pluginData: any;
  19933. private _physicsEngine;
  19934. private _physicsBody;
  19935. private _bodyUpdateRequired;
  19936. private _onBeforePhysicsStepCallbacks;
  19937. private _onAfterPhysicsStepCallbacks;
  19938. /** @hidden */
  19939. _onPhysicsCollideCallbacks: Array<{
  19940. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  19941. otherImpostors: Array<PhysicsImpostor>;
  19942. }>;
  19943. private _deltaPosition;
  19944. private _deltaRotation;
  19945. private _deltaRotationConjugated;
  19946. private _parent;
  19947. private _isDisposed;
  19948. private static _tmpVecs;
  19949. private static _tmpQuat;
  19950. /**
  19951. * Specifies if the physics imposter is disposed
  19952. */
  19953. readonly isDisposed: boolean;
  19954. /**
  19955. * Gets the mass of the physics imposter
  19956. */
  19957. mass: number;
  19958. /**
  19959. * Gets the coefficient of friction
  19960. */
  19961. /**
  19962. * Sets the coefficient of friction
  19963. */
  19964. friction: number;
  19965. /**
  19966. * Gets the coefficient of restitution
  19967. */
  19968. /**
  19969. * Sets the coefficient of restitution
  19970. */
  19971. restitution: number;
  19972. /**
  19973. * The unique id of the physics imposter
  19974. * set by the physics engine when adding this impostor to the array
  19975. */
  19976. uniqueId: number;
  19977. private _joints;
  19978. /**
  19979. * Initializes the physics imposter
  19980. * @param object The physics-enabled object used as the physics imposter
  19981. * @param type The type of the physics imposter
  19982. * @param _options The options for the physics imposter
  19983. * @param _scene The Babylon scene
  19984. */
  19985. constructor(
  19986. /**
  19987. * The physics-enabled object used as the physics imposter
  19988. */
  19989. object: IPhysicsEnabledObject,
  19990. /**
  19991. * The type of the physics imposter
  19992. */
  19993. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  19994. /**
  19995. * This function will completly initialize this impostor.
  19996. * It will create a new body - but only if this mesh has no parent.
  19997. * If it has, this impostor will not be used other than to define the impostor
  19998. * of the child mesh.
  19999. * @hidden
  20000. */
  20001. _init(): void;
  20002. private _getPhysicsParent;
  20003. /**
  20004. * Should a new body be generated.
  20005. * @returns boolean specifying if body initialization is required
  20006. */
  20007. isBodyInitRequired(): boolean;
  20008. /**
  20009. * Sets the updated scaling
  20010. * @param updated Specifies if the scaling is updated
  20011. */
  20012. setScalingUpdated(): void;
  20013. /**
  20014. * Force a regeneration of this or the parent's impostor's body.
  20015. * Use under cautious - This will remove all joints already implemented.
  20016. */
  20017. forceUpdate(): void;
  20018. /**
  20019. * Gets the body that holds this impostor. Either its own, or its parent.
  20020. */
  20021. /**
  20022. * Set the physics body. Used mainly by the physics engine/plugin
  20023. */
  20024. physicsBody: any;
  20025. /**
  20026. * Get the parent of the physics imposter
  20027. * @returns Physics imposter or null
  20028. */
  20029. /**
  20030. * Sets the parent of the physics imposter
  20031. */
  20032. parent: Nullable<PhysicsImpostor>;
  20033. /**
  20034. * Resets the update flags
  20035. */
  20036. resetUpdateFlags(): void;
  20037. /**
  20038. * Gets the object extend size
  20039. * @returns the object extend size
  20040. */
  20041. getObjectExtendSize(): Vector3;
  20042. /**
  20043. * Gets the object center
  20044. * @returns The object center
  20045. */
  20046. getObjectCenter(): Vector3;
  20047. /**
  20048. * Get a specific parametes from the options parameter
  20049. * @param paramName The object parameter name
  20050. * @returns The object parameter
  20051. */
  20052. getParam(paramName: string): any;
  20053. /**
  20054. * Sets a specific parameter in the options given to the physics plugin
  20055. * @param paramName The parameter name
  20056. * @param value The value of the parameter
  20057. */
  20058. setParam(paramName: string, value: number): void;
  20059. /**
  20060. * Specifically change the body's mass option. Won't recreate the physics body object
  20061. * @param mass The mass of the physics imposter
  20062. */
  20063. setMass(mass: number): void;
  20064. /**
  20065. * Gets the linear velocity
  20066. * @returns linear velocity or null
  20067. */
  20068. getLinearVelocity(): Nullable<Vector3>;
  20069. /**
  20070. * Sets the linear velocity
  20071. * @param velocity linear velocity or null
  20072. */
  20073. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20074. /**
  20075. * Gets the angular velocity
  20076. * @returns angular velocity or null
  20077. */
  20078. getAngularVelocity(): Nullable<Vector3>;
  20079. /**
  20080. * Sets the angular velocity
  20081. * @param velocity The velocity or null
  20082. */
  20083. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20084. /**
  20085. * Execute a function with the physics plugin native code
  20086. * Provide a function the will have two variables - the world object and the physics body object
  20087. * @param func The function to execute with the physics plugin native code
  20088. */
  20089. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20090. /**
  20091. * Register a function that will be executed before the physics world is stepping forward
  20092. * @param func The function to execute before the physics world is stepped forward
  20093. */
  20094. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20095. /**
  20096. * Unregister a function that will be executed before the physics world is stepping forward
  20097. * @param func The function to execute before the physics world is stepped forward
  20098. */
  20099. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20100. /**
  20101. * Register a function that will be executed after the physics step
  20102. * @param func The function to execute after physics step
  20103. */
  20104. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20105. /**
  20106. * Unregisters a function that will be executed after the physics step
  20107. * @param func The function to execute after physics step
  20108. */
  20109. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20110. /**
  20111. * register a function that will be executed when this impostor collides against a different body
  20112. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20113. * @param func Callback that is executed on collision
  20114. */
  20115. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20116. /**
  20117. * Unregisters the physics imposter on contact
  20118. * @param collideAgainst The physics object to collide against
  20119. * @param func Callback to execute on collision
  20120. */
  20121. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20122. private _tmpQuat;
  20123. private _tmpQuat2;
  20124. /**
  20125. * Get the parent rotation
  20126. * @returns The parent rotation
  20127. */
  20128. getParentsRotation(): Quaternion;
  20129. /**
  20130. * this function is executed by the physics engine.
  20131. */
  20132. beforeStep: () => void;
  20133. /**
  20134. * this function is executed by the physics engine
  20135. */
  20136. afterStep: () => void;
  20137. /**
  20138. * Legacy collision detection event support
  20139. */
  20140. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20141. /**
  20142. * event and body object due to cannon's event-based architecture.
  20143. */
  20144. onCollide: (e: {
  20145. body: any;
  20146. }) => void;
  20147. /**
  20148. * Apply a force
  20149. * @param force The force to apply
  20150. * @param contactPoint The contact point for the force
  20151. * @returns The physics imposter
  20152. */
  20153. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20154. /**
  20155. * Apply an impulse
  20156. * @param force The impulse force
  20157. * @param contactPoint The contact point for the impulse force
  20158. * @returns The physics imposter
  20159. */
  20160. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20161. /**
  20162. * A help function to create a joint
  20163. * @param otherImpostor A physics imposter used to create a joint
  20164. * @param jointType The type of joint
  20165. * @param jointData The data for the joint
  20166. * @returns The physics imposter
  20167. */
  20168. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20169. /**
  20170. * Add a joint to this impostor with a different impostor
  20171. * @param otherImpostor A physics imposter used to add a joint
  20172. * @param joint The joint to add
  20173. * @returns The physics imposter
  20174. */
  20175. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20176. /**
  20177. * Will keep this body still, in a sleep mode.
  20178. * @returns the physics imposter
  20179. */
  20180. sleep(): PhysicsImpostor;
  20181. /**
  20182. * Wake the body up.
  20183. * @returns The physics imposter
  20184. */
  20185. wakeUp(): PhysicsImpostor;
  20186. /**
  20187. * Clones the physics imposter
  20188. * @param newObject The physics imposter clones to this physics-enabled object
  20189. * @returns A nullable physics imposter
  20190. */
  20191. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20192. /**
  20193. * Disposes the physics imposter
  20194. */
  20195. dispose(): void;
  20196. /**
  20197. * Sets the delta position
  20198. * @param position The delta position amount
  20199. */
  20200. setDeltaPosition(position: Vector3): void;
  20201. /**
  20202. * Sets the delta rotation
  20203. * @param rotation The delta rotation amount
  20204. */
  20205. setDeltaRotation(rotation: Quaternion): void;
  20206. /**
  20207. * Gets the box size of the physics imposter and stores the result in the input parameter
  20208. * @param result Stores the box size
  20209. * @returns The physics imposter
  20210. */
  20211. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20212. /**
  20213. * Gets the radius of the physics imposter
  20214. * @returns Radius of the physics imposter
  20215. */
  20216. getRadius(): number;
  20217. /**
  20218. * Sync a bone with this impostor
  20219. * @param bone The bone to sync to the impostor.
  20220. * @param boneMesh The mesh that the bone is influencing.
  20221. * @param jointPivot The pivot of the joint / bone in local space.
  20222. * @param distToJoint Optional distance from the impostor to the joint.
  20223. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20224. */
  20225. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20226. /**
  20227. * Sync impostor to a bone
  20228. * @param bone The bone that the impostor will be synced to.
  20229. * @param boneMesh The mesh that the bone is influencing.
  20230. * @param jointPivot The pivot of the joint / bone in local space.
  20231. * @param distToJoint Optional distance from the impostor to the joint.
  20232. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20233. * @param boneAxis Optional vector3 axis the bone is aligned with
  20234. */
  20235. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20236. /**
  20237. * No-Imposter type
  20238. */
  20239. static NoImpostor: number;
  20240. /**
  20241. * Sphere-Imposter type
  20242. */
  20243. static SphereImpostor: number;
  20244. /**
  20245. * Box-Imposter type
  20246. */
  20247. static BoxImpostor: number;
  20248. /**
  20249. * Plane-Imposter type
  20250. */
  20251. static PlaneImpostor: number;
  20252. /**
  20253. * Mesh-imposter type
  20254. */
  20255. static MeshImpostor: number;
  20256. /**
  20257. * Cylinder-Imposter type
  20258. */
  20259. static CylinderImpostor: number;
  20260. /**
  20261. * Particle-Imposter type
  20262. */
  20263. static ParticleImpostor: number;
  20264. /**
  20265. * Heightmap-Imposter type
  20266. */
  20267. static HeightmapImpostor: number;
  20268. }
  20269. }
  20270. declare module "babylonjs/Meshes/mesh" {
  20271. import { Observable } from "babylonjs/Misc/observable";
  20272. import { IAnimatable } from "babylonjs/Misc/tools";
  20273. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  20274. import { Camera } from "babylonjs/Cameras/camera";
  20275. import { Scene } from "babylonjs/scene";
  20276. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  20277. import { Engine } from "babylonjs/Engines/engine";
  20278. import { Node } from "babylonjs/node";
  20279. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20280. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  20281. import { Buffer } from "babylonjs/Meshes/buffer";
  20282. import { Geometry } from "babylonjs/Meshes/geometry";
  20283. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20284. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20285. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  20286. import { Effect } from "babylonjs/Materials/effect";
  20287. import { Material } from "babylonjs/Materials/material";
  20288. import { Skeleton } from "babylonjs/Bones/skeleton";
  20289. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  20290. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  20291. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20292. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  20293. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20294. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  20295. /**
  20296. * Class used to represent a specific level of detail of a mesh
  20297. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20298. */
  20299. export class MeshLODLevel {
  20300. /** Defines the distance where this level should star being displayed */
  20301. distance: number;
  20302. /** Defines the mesh to use to render this level */
  20303. mesh: Nullable<Mesh>;
  20304. /**
  20305. * Creates a new LOD level
  20306. * @param distance defines the distance where this level should star being displayed
  20307. * @param mesh defines the mesh to use to render this level
  20308. */
  20309. constructor(
  20310. /** Defines the distance where this level should star being displayed */
  20311. distance: number,
  20312. /** Defines the mesh to use to render this level */
  20313. mesh: Nullable<Mesh>);
  20314. }
  20315. /**
  20316. * @hidden
  20317. **/
  20318. export class _CreationDataStorage {
  20319. closePath?: boolean;
  20320. closeArray?: boolean;
  20321. idx: number[];
  20322. dashSize: number;
  20323. gapSize: number;
  20324. path3D: Path3D;
  20325. pathArray: Vector3[][];
  20326. arc: number;
  20327. radius: number;
  20328. cap: number;
  20329. tessellation: number;
  20330. }
  20331. /**
  20332. * @hidden
  20333. **/
  20334. class _InstanceDataStorage {
  20335. visibleInstances: any;
  20336. renderIdForInstances: number[];
  20337. batchCache: _InstancesBatch;
  20338. instancesBufferSize: number;
  20339. instancesBuffer: Nullable<Buffer>;
  20340. instancesData: Float32Array;
  20341. overridenInstanceCount: number;
  20342. }
  20343. /**
  20344. * @hidden
  20345. **/
  20346. export class _InstancesBatch {
  20347. mustReturn: boolean;
  20348. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  20349. renderSelf: boolean[];
  20350. }
  20351. /**
  20352. * Class used to represent renderable models
  20353. */
  20354. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20355. /**
  20356. * Mesh side orientation : usually the external or front surface
  20357. */
  20358. static readonly FRONTSIDE: number;
  20359. /**
  20360. * Mesh side orientation : usually the internal or back surface
  20361. */
  20362. static readonly BACKSIDE: number;
  20363. /**
  20364. * Mesh side orientation : both internal and external or front and back surfaces
  20365. */
  20366. static readonly DOUBLESIDE: number;
  20367. /**
  20368. * Mesh side orientation : by default, `FRONTSIDE`
  20369. */
  20370. static readonly DEFAULTSIDE: number;
  20371. /**
  20372. * Mesh cap setting : no cap
  20373. */
  20374. static readonly NO_CAP: number;
  20375. /**
  20376. * Mesh cap setting : one cap at the beginning of the mesh
  20377. */
  20378. static readonly CAP_START: number;
  20379. /**
  20380. * Mesh cap setting : one cap at the end of the mesh
  20381. */
  20382. static readonly CAP_END: number;
  20383. /**
  20384. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20385. */
  20386. static readonly CAP_ALL: number;
  20387. /**
  20388. * Gets the default side orientation.
  20389. * @param orientation the orientation to value to attempt to get
  20390. * @returns the default orientation
  20391. * @hidden
  20392. */
  20393. static _GetDefaultSideOrientation(orientation?: number): number;
  20394. private _onBeforeRenderObservable;
  20395. private _onBeforeBindObservable;
  20396. private _onAfterRenderObservable;
  20397. private _onBeforeDrawObservable;
  20398. /**
  20399. * An event triggered before rendering the mesh
  20400. */
  20401. readonly onBeforeRenderObservable: Observable<Mesh>;
  20402. /**
  20403. * An event triggered before binding the mesh
  20404. */
  20405. readonly onBeforeBindObservable: Observable<Mesh>;
  20406. /**
  20407. * An event triggered after rendering the mesh
  20408. */
  20409. readonly onAfterRenderObservable: Observable<Mesh>;
  20410. /**
  20411. * An event triggered before drawing the mesh
  20412. */
  20413. readonly onBeforeDrawObservable: Observable<Mesh>;
  20414. private _onBeforeDrawObserver;
  20415. /**
  20416. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  20417. */
  20418. onBeforeDraw: () => void;
  20419. /**
  20420. * Gets the delay loading state of the mesh (when delay loading is turned on)
  20421. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  20422. */
  20423. delayLoadState: number;
  20424. /**
  20425. * Gets the list of instances created from this mesh
  20426. * it is not supposed to be modified manually.
  20427. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  20428. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20429. */
  20430. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  20431. /**
  20432. * Gets the file containing delay loading data for this mesh
  20433. */
  20434. delayLoadingFile: string;
  20435. /** @hidden */
  20436. _binaryInfo: any;
  20437. private _LODLevels;
  20438. /**
  20439. * User defined function used to change how LOD level selection is done
  20440. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20441. */
  20442. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20443. private _morphTargetManager;
  20444. /**
  20445. * Gets or sets the morph target manager
  20446. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20447. */
  20448. morphTargetManager: Nullable<MorphTargetManager>;
  20449. /** @hidden */
  20450. _creationDataStorage: Nullable<_CreationDataStorage>;
  20451. /** @hidden */
  20452. _geometry: Nullable<Geometry>;
  20453. /** @hidden */
  20454. _delayInfo: Array<string>;
  20455. /** @hidden */
  20456. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20457. /** @hidden */
  20458. _instanceDataStorage: _InstanceDataStorage;
  20459. private _effectiveMaterial;
  20460. /** @hidden */
  20461. _shouldGenerateFlatShading: boolean;
  20462. private _preActivateId;
  20463. /** @hidden */
  20464. _originalBuilderSideOrientation: number;
  20465. /**
  20466. * Use this property to change the original side orientation defined at construction time
  20467. */
  20468. overrideMaterialSideOrientation: Nullable<number>;
  20469. private _areNormalsFrozen;
  20470. private _sourcePositions;
  20471. private _sourceNormals;
  20472. private _source;
  20473. private meshMap;
  20474. /**
  20475. * Gets the source mesh (the one used to clone this one from)
  20476. */
  20477. readonly source: Nullable<Mesh>;
  20478. /**
  20479. * Gets or sets a boolean indicating that this mesh does not use index buffer
  20480. */
  20481. isUnIndexed: boolean;
  20482. /**
  20483. * @constructor
  20484. * @param name The value used by scene.getMeshByName() to do a lookup.
  20485. * @param scene The scene to add this mesh to.
  20486. * @param parent The parent of this mesh, if it has one
  20487. * @param source An optional Mesh from which geometry is shared, cloned.
  20488. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20489. * When false, achieved by calling a clone(), also passing False.
  20490. * This will make creation of children, recursive.
  20491. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20492. */
  20493. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20494. /**
  20495. * Gets the class name
  20496. * @returns the string "Mesh".
  20497. */
  20498. getClassName(): string;
  20499. /** @hidden */
  20500. readonly _isMesh: boolean;
  20501. /**
  20502. * Returns a description of this mesh
  20503. * @param fullDetails define if full details about this mesh must be used
  20504. * @returns a descriptive string representing this mesh
  20505. */
  20506. toString(fullDetails?: boolean): string;
  20507. /** @hidden */
  20508. _unBindEffect(): void;
  20509. /**
  20510. * Gets a boolean indicating if this mesh has LOD
  20511. */
  20512. readonly hasLODLevels: boolean;
  20513. /**
  20514. * Gets the list of MeshLODLevel associated with the current mesh
  20515. * @returns an array of MeshLODLevel
  20516. */
  20517. getLODLevels(): MeshLODLevel[];
  20518. private _sortLODLevels;
  20519. /**
  20520. * Add a mesh as LOD level triggered at the given distance.
  20521. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20522. * @param distance The distance from the center of the object to show this level
  20523. * @param mesh The mesh to be added as LOD level (can be null)
  20524. * @return This mesh (for chaining)
  20525. */
  20526. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  20527. /**
  20528. * Returns the LOD level mesh at the passed distance or null if not found.
  20529. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20530. * @param distance The distance from the center of the object to show this level
  20531. * @returns a Mesh or `null`
  20532. */
  20533. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20534. /**
  20535. * Remove a mesh from the LOD array
  20536. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20537. * @param mesh defines the mesh to be removed
  20538. * @return This mesh (for chaining)
  20539. */
  20540. removeLODLevel(mesh: Mesh): Mesh;
  20541. /**
  20542. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  20543. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20544. * @param camera defines the camera to use to compute distance
  20545. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  20546. * @return This mesh (for chaining)
  20547. */
  20548. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  20549. /**
  20550. * Gets the mesh internal Geometry object
  20551. */
  20552. readonly geometry: Nullable<Geometry>;
  20553. /**
  20554. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20555. * @returns the total number of vertices
  20556. */
  20557. getTotalVertices(): number;
  20558. /**
  20559. * Returns the content of an associated vertex buffer
  20560. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20561. * - VertexBuffer.PositionKind
  20562. * - VertexBuffer.UVKind
  20563. * - VertexBuffer.UV2Kind
  20564. * - VertexBuffer.UV3Kind
  20565. * - VertexBuffer.UV4Kind
  20566. * - VertexBuffer.UV5Kind
  20567. * - VertexBuffer.UV6Kind
  20568. * - VertexBuffer.ColorKind
  20569. * - VertexBuffer.MatricesIndicesKind
  20570. * - VertexBuffer.MatricesIndicesExtraKind
  20571. * - VertexBuffer.MatricesWeightsKind
  20572. * - VertexBuffer.MatricesWeightsExtraKind
  20573. * @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
  20574. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  20575. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  20576. */
  20577. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20578. /**
  20579. * Returns the mesh VertexBuffer object from the requested `kind`
  20580. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20581. * - VertexBuffer.PositionKind
  20582. * - VertexBuffer.UVKind
  20583. * - VertexBuffer.UV2Kind
  20584. * - VertexBuffer.UV3Kind
  20585. * - VertexBuffer.UV4Kind
  20586. * - VertexBuffer.UV5Kind
  20587. * - VertexBuffer.UV6Kind
  20588. * - VertexBuffer.ColorKind
  20589. * - VertexBuffer.MatricesIndicesKind
  20590. * - VertexBuffer.MatricesIndicesExtraKind
  20591. * - VertexBuffer.MatricesWeightsKind
  20592. * - VertexBuffer.MatricesWeightsExtraKind
  20593. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  20594. */
  20595. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20596. /**
  20597. * Tests if a specific vertex buffer is associated with this mesh
  20598. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20599. * - VertexBuffer.PositionKind
  20600. * - VertexBuffer.UVKind
  20601. * - VertexBuffer.UV2Kind
  20602. * - VertexBuffer.UV3Kind
  20603. * - VertexBuffer.UV4Kind
  20604. * - VertexBuffer.UV5Kind
  20605. * - VertexBuffer.UV6Kind
  20606. * - VertexBuffer.ColorKind
  20607. * - VertexBuffer.MatricesIndicesKind
  20608. * - VertexBuffer.MatricesIndicesExtraKind
  20609. * - VertexBuffer.MatricesWeightsKind
  20610. * - VertexBuffer.MatricesWeightsExtraKind
  20611. * @returns a boolean
  20612. */
  20613. isVerticesDataPresent(kind: string): boolean;
  20614. /**
  20615. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  20616. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20617. * - VertexBuffer.PositionKind
  20618. * - VertexBuffer.UVKind
  20619. * - VertexBuffer.UV2Kind
  20620. * - VertexBuffer.UV3Kind
  20621. * - VertexBuffer.UV4Kind
  20622. * - VertexBuffer.UV5Kind
  20623. * - VertexBuffer.UV6Kind
  20624. * - VertexBuffer.ColorKind
  20625. * - VertexBuffer.MatricesIndicesKind
  20626. * - VertexBuffer.MatricesIndicesExtraKind
  20627. * - VertexBuffer.MatricesWeightsKind
  20628. * - VertexBuffer.MatricesWeightsExtraKind
  20629. * @returns a boolean
  20630. */
  20631. isVertexBufferUpdatable(kind: string): boolean;
  20632. /**
  20633. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  20634. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20635. * - VertexBuffer.PositionKind
  20636. * - VertexBuffer.UVKind
  20637. * - VertexBuffer.UV2Kind
  20638. * - VertexBuffer.UV3Kind
  20639. * - VertexBuffer.UV4Kind
  20640. * - VertexBuffer.UV5Kind
  20641. * - VertexBuffer.UV6Kind
  20642. * - VertexBuffer.ColorKind
  20643. * - VertexBuffer.MatricesIndicesKind
  20644. * - VertexBuffer.MatricesIndicesExtraKind
  20645. * - VertexBuffer.MatricesWeightsKind
  20646. * - VertexBuffer.MatricesWeightsExtraKind
  20647. * @returns an array of strings
  20648. */
  20649. getVerticesDataKinds(): string[];
  20650. /**
  20651. * Returns a positive integer : the total number of indices in this mesh geometry.
  20652. * @returns the numner of indices or zero if the mesh has no geometry.
  20653. */
  20654. getTotalIndices(): number;
  20655. /**
  20656. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20657. * @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.
  20658. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20659. * @returns the indices array or an empty array if the mesh has no geometry
  20660. */
  20661. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20662. readonly isBlocked: boolean;
  20663. /**
  20664. * Determine if the current mesh is ready to be rendered
  20665. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20666. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  20667. * @returns true if all associated assets are ready (material, textures, shaders)
  20668. */
  20669. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  20670. /**
  20671. * 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.
  20672. */
  20673. readonly areNormalsFrozen: boolean;
  20674. /**
  20675. * 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.
  20676. * @returns the current mesh
  20677. */
  20678. freezeNormals(): Mesh;
  20679. /**
  20680. * 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
  20681. * @returns the current mesh
  20682. */
  20683. unfreezeNormals(): Mesh;
  20684. /**
  20685. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  20686. */
  20687. overridenInstanceCount: number;
  20688. /** @hidden */
  20689. _preActivate(): Mesh;
  20690. /** @hidden */
  20691. _preActivateForIntermediateRendering(renderId: number): Mesh;
  20692. /** @hidden */
  20693. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  20694. /**
  20695. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  20696. * This means the mesh underlying bounding box and sphere are recomputed.
  20697. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  20698. * @returns the current mesh
  20699. */
  20700. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  20701. /** @hidden */
  20702. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  20703. /**
  20704. * This function will subdivide the mesh into multiple submeshes
  20705. * @param count defines the expected number of submeshes
  20706. */
  20707. subdivide(count: number): void;
  20708. /**
  20709. * Copy a FloatArray into a specific associated vertex buffer
  20710. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20711. * - VertexBuffer.PositionKind
  20712. * - VertexBuffer.UVKind
  20713. * - VertexBuffer.UV2Kind
  20714. * - VertexBuffer.UV3Kind
  20715. * - VertexBuffer.UV4Kind
  20716. * - VertexBuffer.UV5Kind
  20717. * - VertexBuffer.UV6Kind
  20718. * - VertexBuffer.ColorKind
  20719. * - VertexBuffer.MatricesIndicesKind
  20720. * - VertexBuffer.MatricesIndicesExtraKind
  20721. * - VertexBuffer.MatricesWeightsKind
  20722. * - VertexBuffer.MatricesWeightsExtraKind
  20723. * @param data defines the data source
  20724. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20725. * @param stride defines the data stride size (can be null)
  20726. * @returns the current mesh
  20727. */
  20728. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20729. /**
  20730. * Flags an associated vertex buffer as updatable
  20731. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  20732. * - VertexBuffer.PositionKind
  20733. * - VertexBuffer.UVKind
  20734. * - VertexBuffer.UV2Kind
  20735. * - VertexBuffer.UV3Kind
  20736. * - VertexBuffer.UV4Kind
  20737. * - VertexBuffer.UV5Kind
  20738. * - VertexBuffer.UV6Kind
  20739. * - VertexBuffer.ColorKind
  20740. * - VertexBuffer.MatricesIndicesKind
  20741. * - VertexBuffer.MatricesIndicesExtraKind
  20742. * - VertexBuffer.MatricesWeightsKind
  20743. * - VertexBuffer.MatricesWeightsExtraKind
  20744. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20745. */
  20746. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  20747. /**
  20748. * Sets the mesh global Vertex Buffer
  20749. * @param buffer defines the buffer to use
  20750. * @returns the current mesh
  20751. */
  20752. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  20753. /**
  20754. * Update a specific associated vertex buffer
  20755. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20756. * - VertexBuffer.PositionKind
  20757. * - VertexBuffer.UVKind
  20758. * - VertexBuffer.UV2Kind
  20759. * - VertexBuffer.UV3Kind
  20760. * - VertexBuffer.UV4Kind
  20761. * - VertexBuffer.UV5Kind
  20762. * - VertexBuffer.UV6Kind
  20763. * - VertexBuffer.ColorKind
  20764. * - VertexBuffer.MatricesIndicesKind
  20765. * - VertexBuffer.MatricesIndicesExtraKind
  20766. * - VertexBuffer.MatricesWeightsKind
  20767. * - VertexBuffer.MatricesWeightsExtraKind
  20768. * @param data defines the data source
  20769. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  20770. * @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)
  20771. * @returns the current mesh
  20772. */
  20773. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20774. /**
  20775. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  20776. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  20777. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  20778. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  20779. * @returns the current mesh
  20780. */
  20781. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  20782. /**
  20783. * Creates a un-shared specific occurence of the geometry for the mesh.
  20784. * @returns the current mesh
  20785. */
  20786. makeGeometryUnique(): Mesh;
  20787. /**
  20788. * Set the index buffer of this mesh
  20789. * @param indices defines the source data
  20790. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  20791. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  20792. * @returns the current mesh
  20793. */
  20794. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  20795. /**
  20796. * Update the current index buffer
  20797. * @param indices defines the source data
  20798. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  20799. * @returns the current mesh
  20800. */
  20801. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  20802. /**
  20803. * Invert the geometry to move from a right handed system to a left handed one.
  20804. * @returns the current mesh
  20805. */
  20806. toLeftHanded(): Mesh;
  20807. /** @hidden */
  20808. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20809. /** @hidden */
  20810. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  20811. /**
  20812. * Registers for this mesh a javascript function called just before the rendering process
  20813. * @param func defines the function to call before rendering this mesh
  20814. * @returns the current mesh
  20815. */
  20816. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20817. /**
  20818. * Disposes a previously registered javascript function called before the rendering
  20819. * @param func defines the function to remove
  20820. * @returns the current mesh
  20821. */
  20822. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20823. /**
  20824. * Registers for this mesh a javascript function called just after the rendering is complete
  20825. * @param func defines the function to call after rendering this mesh
  20826. * @returns the current mesh
  20827. */
  20828. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20829. /**
  20830. * Disposes a previously registered javascript function called after the rendering.
  20831. * @param func defines the function to remove
  20832. * @returns the current mesh
  20833. */
  20834. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20835. /** @hidden */
  20836. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  20837. /** @hidden */
  20838. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  20839. /** @hidden */
  20840. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  20841. /**
  20842. * 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
  20843. * @param subMesh defines the subMesh to render
  20844. * @param enableAlphaMode defines if alpha mode can be changed
  20845. * @returns the current mesh
  20846. */
  20847. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  20848. private _onBeforeDraw;
  20849. /**
  20850. * Renormalize the mesh and patch it up if there are no weights
  20851. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  20852. * However in the case of zero weights then we set just a single influence to 1.
  20853. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  20854. */
  20855. cleanMatrixWeights(): void;
  20856. private normalizeSkinFourWeights;
  20857. private normalizeSkinWeightsAndExtra;
  20858. /**
  20859. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  20860. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  20861. * the user know there was an issue with importing the mesh
  20862. * @returns a validation object with skinned, valid and report string
  20863. */
  20864. validateSkinning(): {
  20865. skinned: boolean;
  20866. valid: boolean;
  20867. report: string;
  20868. };
  20869. /** @hidden */
  20870. _checkDelayState(): Mesh;
  20871. private _queueLoad;
  20872. /**
  20873. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  20874. * A mesh is in the frustum if its bounding box intersects the frustum
  20875. * @param frustumPlanes defines the frustum to test
  20876. * @returns true if the mesh is in the frustum planes
  20877. */
  20878. isInFrustum(frustumPlanes: Plane[]): boolean;
  20879. /**
  20880. * Sets the mesh material by the material or multiMaterial `id` property
  20881. * @param id is a string identifying the material or the multiMaterial
  20882. * @returns the current mesh
  20883. */
  20884. setMaterialByID(id: string): Mesh;
  20885. /**
  20886. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  20887. * @returns an array of IAnimatable
  20888. */
  20889. getAnimatables(): IAnimatable[];
  20890. /**
  20891. * Modifies the mesh geometry according to the passed transformation matrix.
  20892. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  20893. * The mesh normals are modified using the same transformation.
  20894. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20895. * @param transform defines the transform matrix to use
  20896. * @see http://doc.babylonjs.com/resources/baking_transformations
  20897. * @returns the current mesh
  20898. */
  20899. bakeTransformIntoVertices(transform: Matrix): Mesh;
  20900. /**
  20901. * Modifies the mesh geometry according to its own current World Matrix.
  20902. * The mesh World Matrix is then reset.
  20903. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  20904. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20905. * @see http://doc.babylonjs.com/resources/baking_transformations
  20906. * @returns the current mesh
  20907. */
  20908. bakeCurrentTransformIntoVertices(): Mesh;
  20909. /** @hidden */
  20910. readonly _positions: Nullable<Vector3[]>;
  20911. /** @hidden */
  20912. _resetPointsArrayCache(): Mesh;
  20913. /** @hidden */
  20914. _generatePointsArray(): boolean;
  20915. /**
  20916. * Returns a new Mesh object generated from the current mesh properties.
  20917. * This method must not get confused with createInstance()
  20918. * @param name is a string, the name given to the new mesh
  20919. * @param newParent can be any Node object (default `null`)
  20920. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  20921. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  20922. * @returns a new mesh
  20923. */
  20924. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  20925. /**
  20926. * Releases resources associated with this mesh.
  20927. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  20928. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  20929. */
  20930. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  20931. /**
  20932. * Modifies the mesh geometry according to a displacement map.
  20933. * 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.
  20934. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20935. * @param url is a string, the URL from the image file is to be downloaded.
  20936. * @param minHeight is the lower limit of the displacement.
  20937. * @param maxHeight is the upper limit of the displacement.
  20938. * @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.
  20939. * @param uvOffset is an optional vector2 used to offset UV.
  20940. * @param uvScale is an optional vector2 used to scale UV.
  20941. * @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.
  20942. * @returns the Mesh.
  20943. */
  20944. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  20945. /**
  20946. * Modifies the mesh geometry according to a displacementMap buffer.
  20947. * 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.
  20948. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20949. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  20950. * @param heightMapWidth is the width of the buffer image.
  20951. * @param heightMapHeight is the height of the buffer image.
  20952. * @param minHeight is the lower limit of the displacement.
  20953. * @param maxHeight is the upper limit of the displacement.
  20954. * @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.
  20955. * @param uvOffset is an optional vector2 used to offset UV.
  20956. * @param uvScale is an optional vector2 used to scale UV.
  20957. * @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.
  20958. * @returns the Mesh.
  20959. */
  20960. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  20961. /**
  20962. * Modify the mesh to get a flat shading rendering.
  20963. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  20964. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  20965. * @returns current mesh
  20966. */
  20967. convertToFlatShadedMesh(): Mesh;
  20968. /**
  20969. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  20970. * In other words, more vertices, no more indices and a single bigger VBO.
  20971. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  20972. * @returns current mesh
  20973. */
  20974. convertToUnIndexedMesh(): Mesh;
  20975. /**
  20976. * Inverses facet orientations.
  20977. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  20978. * @param flipNormals will also inverts the normals
  20979. * @returns current mesh
  20980. */
  20981. flipFaces(flipNormals?: boolean): Mesh;
  20982. /** @hidden */
  20983. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  20984. /** @hidden */
  20985. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  20986. /**
  20987. * Creates a new InstancedMesh object from the mesh model.
  20988. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20989. * @param name defines the name of the new instance
  20990. * @returns a new InstancedMesh
  20991. */
  20992. createInstance(name: string): InstancedMesh;
  20993. /**
  20994. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  20995. * After this call, all the mesh instances have the same submeshes than the current mesh.
  20996. * @returns the current mesh
  20997. */
  20998. synchronizeInstances(): Mesh;
  20999. /**
  21000. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21001. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21002. * This should be used together with the simplification to avoid disappearing triangles.
  21003. * @param successCallback an optional success callback to be called after the optimization finished.
  21004. * @returns the current mesh
  21005. */
  21006. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21007. /**
  21008. * Serialize current mesh
  21009. * @param serializationObject defines the object which will receive the serialization data
  21010. */
  21011. serialize(serializationObject: any): void;
  21012. /** @hidden */
  21013. _syncGeometryWithMorphTargetManager(): void;
  21014. /** @hidden */
  21015. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21016. /**
  21017. * Returns a new Mesh object parsed from the source provided.
  21018. * @param parsedMesh is the source
  21019. * @param scene defines the hosting scene
  21020. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21021. * @returns a new Mesh
  21022. */
  21023. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21024. /**
  21025. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21026. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21027. * @param name defines the name of the mesh to create
  21028. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21029. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21030. * @param closePath creates a seam between the first and the last points of each path of the path array
  21031. * @param offset is taken in account only if the `pathArray` is containing a single path
  21032. * @param scene defines the hosting scene
  21033. * @param updatable defines if the mesh must be flagged as updatable
  21034. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21035. * @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)
  21036. * @returns a new Mesh
  21037. */
  21038. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21039. /**
  21040. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21041. * @param name defines the name of the mesh to create
  21042. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21043. * @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
  21044. * @param scene defines the hosting scene
  21045. * @param updatable defines if the mesh must be flagged as updatable
  21046. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21047. * @returns a new Mesh
  21048. */
  21049. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21050. /**
  21051. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21052. * @param name defines the name of the mesh to create
  21053. * @param size sets the size (float) of each box side (default 1)
  21054. * @param scene defines the hosting scene
  21055. * @param updatable defines if the mesh must be flagged as updatable
  21056. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21057. * @returns a new Mesh
  21058. */
  21059. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21060. /**
  21061. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21062. * @param name defines the name of the mesh to create
  21063. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21064. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21065. * @param scene defines the hosting scene
  21066. * @param updatable defines if the mesh must be flagged as updatable
  21067. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21068. * @returns a new Mesh
  21069. */
  21070. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21071. /**
  21072. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21073. * @param name defines the name of the mesh to create
  21074. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21075. * @param diameterTop set the top cap diameter (floats, default 1)
  21076. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21077. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21078. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21079. * @param scene defines the hosting scene
  21080. * @param updatable defines if the mesh must be flagged as updatable
  21081. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21082. * @returns a new Mesh
  21083. */
  21084. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21085. /**
  21086. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21087. * @param name defines the name of the mesh to create
  21088. * @param diameter sets the diameter size (float) of the torus (default 1)
  21089. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21090. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21091. * @param scene defines the hosting scene
  21092. * @param updatable defines if the mesh must be flagged as updatable
  21093. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21094. * @returns a new Mesh
  21095. */
  21096. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21097. /**
  21098. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21099. * @param name defines the name of the mesh to create
  21100. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21101. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21102. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21103. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21104. * @param p the number of windings on X axis (positive integers, default 2)
  21105. * @param q the number of windings on Y axis (positive integers, default 3)
  21106. * @param scene defines the hosting scene
  21107. * @param updatable defines if the mesh must be flagged as updatable
  21108. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21109. * @returns a new Mesh
  21110. */
  21111. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21112. /**
  21113. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21114. * @param name defines the name of the mesh to create
  21115. * @param points is an array successive Vector3
  21116. * @param scene defines the hosting scene
  21117. * @param updatable defines if the mesh must be flagged as updatable
  21118. * @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).
  21119. * @returns a new Mesh
  21120. */
  21121. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21122. /**
  21123. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21124. * @param name defines the name of the mesh to create
  21125. * @param points is an array successive Vector3
  21126. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21127. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21128. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21129. * @param scene defines the hosting scene
  21130. * @param updatable defines if the mesh must be flagged as updatable
  21131. * @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)
  21132. * @returns a new Mesh
  21133. */
  21134. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21135. /**
  21136. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21137. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21138. * 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.
  21139. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21140. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21141. * Remember you can only change the shape positions, not their number when updating a polygon.
  21142. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21143. * @param name defines the name of the mesh to create
  21144. * @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
  21145. * @param scene defines the hosting scene
  21146. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21147. * @param updatable defines if the mesh must be flagged as updatable
  21148. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21149. * @param earcutInjection can be used to inject your own earcut reference
  21150. * @returns a new Mesh
  21151. */
  21152. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21153. /**
  21154. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21155. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21156. * @param name defines the name of the mesh to create
  21157. * @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
  21158. * @param depth defines the height of extrusion
  21159. * @param scene defines the hosting scene
  21160. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21161. * @param updatable defines if the mesh must be flagged as updatable
  21162. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21163. * @param earcutInjection can be used to inject your own earcut reference
  21164. * @returns a new Mesh
  21165. */
  21166. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21167. /**
  21168. * Creates an extruded shape mesh.
  21169. * 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
  21170. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21171. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21172. * @param name defines the name of the mesh to create
  21173. * @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
  21174. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21175. * @param scale is the value to scale the shape
  21176. * @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
  21177. * @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
  21178. * @param scene defines the hosting scene
  21179. * @param updatable defines if the mesh must be flagged as updatable
  21180. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21181. * @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)
  21182. * @returns a new Mesh
  21183. */
  21184. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21185. /**
  21186. * Creates an custom extruded shape mesh.
  21187. * The custom extrusion is a parametric shape.
  21188. * It has no predefined shape. Its final shape will depend on the input parameters.
  21189. * Please consider using the same method from the MeshBuilder class instead
  21190. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21191. * @param name defines the name of the mesh to create
  21192. * @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
  21193. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21194. * @param scaleFunction is a custom Javascript function called on each path point
  21195. * @param rotationFunction is a custom Javascript function called on each path point
  21196. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21197. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21198. * @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
  21199. * @param scene defines the hosting scene
  21200. * @param updatable defines if the mesh must be flagged as updatable
  21201. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21202. * @param 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)
  21203. * @returns a new Mesh
  21204. */
  21205. 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;
  21206. /**
  21207. * Creates lathe mesh.
  21208. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21209. * Please consider using the same method from the MeshBuilder class instead
  21210. * @param name defines the name of the mesh to create
  21211. * @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
  21212. * @param radius is the radius value of the lathe
  21213. * @param tessellation is the side number of the lathe.
  21214. * @param scene defines the hosting scene
  21215. * @param updatable defines if the mesh must be flagged as updatable
  21216. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21217. * @returns a new Mesh
  21218. */
  21219. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21220. /**
  21221. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21222. * @param name defines the name of the mesh to create
  21223. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21224. * @param scene defines the hosting scene
  21225. * @param updatable defines if the mesh must be flagged as updatable
  21226. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21227. * @returns a new Mesh
  21228. */
  21229. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21230. /**
  21231. * Creates a ground mesh.
  21232. * Please consider using the same method from the MeshBuilder class instead
  21233. * @param name defines the name of the mesh to create
  21234. * @param width set the width of the ground
  21235. * @param height set the height of the ground
  21236. * @param subdivisions sets the number of subdivisions per side
  21237. * @param scene defines the hosting scene
  21238. * @param updatable defines if the mesh must be flagged as updatable
  21239. * @returns a new Mesh
  21240. */
  21241. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21242. /**
  21243. * Creates a tiled ground mesh.
  21244. * Please consider using the same method from the MeshBuilder class instead
  21245. * @param name defines the name of the mesh to create
  21246. * @param xmin set the ground minimum X coordinate
  21247. * @param zmin set the ground minimum Y coordinate
  21248. * @param xmax set the ground maximum X coordinate
  21249. * @param zmax set the ground maximum Z coordinate
  21250. * @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
  21251. * @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
  21252. * @param scene defines the hosting scene
  21253. * @param updatable defines if the mesh must be flagged as updatable
  21254. * @returns a new Mesh
  21255. */
  21256. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21257. w: number;
  21258. h: number;
  21259. }, precision: {
  21260. w: number;
  21261. h: number;
  21262. }, scene: Scene, updatable?: boolean): Mesh;
  21263. /**
  21264. * Creates a ground mesh from a height map.
  21265. * Please consider using the same method from the MeshBuilder class instead
  21266. * @see http://doc.babylonjs.com/babylon101/height_map
  21267. * @param name defines the name of the mesh to create
  21268. * @param url sets the URL of the height map image resource
  21269. * @param width set the ground width size
  21270. * @param height set the ground height size
  21271. * @param subdivisions sets the number of subdivision per side
  21272. * @param minHeight is the minimum altitude on the ground
  21273. * @param maxHeight is the maximum altitude on the ground
  21274. * @param scene defines the hosting scene
  21275. * @param updatable defines if the mesh must be flagged as updatable
  21276. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21277. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21278. * @returns a new Mesh
  21279. */
  21280. 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;
  21281. /**
  21282. * Creates a tube mesh.
  21283. * The tube is a parametric shape.
  21284. * It has no predefined shape. Its final shape will depend on the input parameters.
  21285. * Please consider using the same method from the MeshBuilder class instead
  21286. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21287. * @param name defines the name of the mesh to create
  21288. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21289. * @param radius sets the tube radius size
  21290. * @param tessellation is the number of sides on the tubular surface
  21291. * @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
  21292. * @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
  21293. * @param scene defines the hosting scene
  21294. * @param updatable defines if the mesh must be flagged as updatable
  21295. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21296. * @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)
  21297. * @returns a new Mesh
  21298. */
  21299. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21300. (i: number, distance: number): number;
  21301. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21302. /**
  21303. * Creates a polyhedron mesh.
  21304. * Please consider using the same method from the MeshBuilder class instead.
  21305. * * 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
  21306. * * The parameter `size` (positive float, default 1) sets the polygon size
  21307. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21308. * * 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`
  21309. * * 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
  21310. * * 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)`)
  21311. * * 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
  21312. * * 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
  21313. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21314. * * If you create a double-sided mesh, you can choose what parts of 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
  21315. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21316. * @param name defines the name of the mesh to create
  21317. * @param options defines the options used to create the mesh
  21318. * @param scene defines the hosting scene
  21319. * @returns a new Mesh
  21320. */
  21321. static CreatePolyhedron(name: string, options: {
  21322. type?: number;
  21323. size?: number;
  21324. sizeX?: number;
  21325. sizeY?: number;
  21326. sizeZ?: number;
  21327. custom?: any;
  21328. faceUV?: Vector4[];
  21329. faceColors?: Color4[];
  21330. updatable?: boolean;
  21331. sideOrientation?: number;
  21332. }, scene: Scene): Mesh;
  21333. /**
  21334. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21335. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21336. * * 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`)
  21337. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21338. * * 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
  21339. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21340. * * If you create a double-sided mesh, you can choose what parts of 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
  21341. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21342. * @param name defines the name of the mesh
  21343. * @param options defines the options used to create the mesh
  21344. * @param scene defines the hosting scene
  21345. * @returns a new Mesh
  21346. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21347. */
  21348. static CreateIcoSphere(name: string, options: {
  21349. radius?: number;
  21350. flat?: boolean;
  21351. subdivisions?: number;
  21352. sideOrientation?: number;
  21353. updatable?: boolean;
  21354. }, scene: Scene): Mesh;
  21355. /**
  21356. * Creates a decal mesh.
  21357. * Please consider using the same method from the MeshBuilder class instead.
  21358. * A decal is a mesh usually applied as a model onto the surface of another mesh
  21359. * @param name defines the name of the mesh
  21360. * @param sourceMesh defines the mesh receiving the decal
  21361. * @param position sets the position of the decal in world coordinates
  21362. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  21363. * @param size sets the decal scaling
  21364. * @param angle sets the angle to rotate the decal
  21365. * @returns a new Mesh
  21366. */
  21367. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21368. /**
  21369. * Prepare internal position array for software CPU skinning
  21370. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  21371. */
  21372. setPositionsForCPUSkinning(): Float32Array;
  21373. /**
  21374. * Prepare internal normal array for software CPU skinning
  21375. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21376. */
  21377. setNormalsForCPUSkinning(): Float32Array;
  21378. /**
  21379. * Updates the vertex buffer by applying transformation from the bones
  21380. * @param skeleton defines the skeleton to apply to current mesh
  21381. * @returns the current mesh
  21382. */
  21383. applySkeleton(skeleton: Skeleton): Mesh;
  21384. /**
  21385. * 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
  21386. * @param meshes defines the list of meshes to scan
  21387. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  21388. */
  21389. static MinMax(meshes: AbstractMesh[]): {
  21390. min: Vector3;
  21391. max: Vector3;
  21392. };
  21393. /**
  21394. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  21395. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  21396. * @returns a vector3
  21397. */
  21398. static Center(meshesOrMinMaxVector: {
  21399. min: Vector3;
  21400. max: Vector3;
  21401. } | AbstractMesh[]): Vector3;
  21402. /**
  21403. * Merge the array of meshes into a single mesh for performance reasons.
  21404. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  21405. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  21406. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  21407. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21408. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  21409. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  21410. * @returns a new mesh
  21411. */
  21412. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  21413. /** @hidden */
  21414. addInstance(instance: InstancedMesh): void;
  21415. /** @hidden */
  21416. removeInstance(instance: InstancedMesh): void;
  21417. }
  21418. }
  21419. declare module "babylonjs/Materials/material" {
  21420. import { IAnimatable } from "babylonjs/Misc/tools";
  21421. import { SmartArray } from "babylonjs/Misc/smartArray";
  21422. import { Observable } from "babylonjs/Misc/observable";
  21423. import { Nullable } from "babylonjs/types";
  21424. import { Scene } from "babylonjs/scene";
  21425. import { Matrix } from "babylonjs/Maths/math";
  21426. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21427. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21428. import { Mesh } from "babylonjs/Meshes/mesh";
  21429. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21430. import { Effect } from "babylonjs/Materials/effect";
  21431. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21432. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21433. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21434. import { Animation } from "babylonjs/Animations/animation";
  21435. /**
  21436. * Base class for the main features of a material in Babylon.js
  21437. */
  21438. export class Material implements IAnimatable {
  21439. /**
  21440. * Returns the triangle fill mode
  21441. */
  21442. static readonly TriangleFillMode: number;
  21443. /**
  21444. * Returns the wireframe mode
  21445. */
  21446. static readonly WireFrameFillMode: number;
  21447. /**
  21448. * Returns the point fill mode
  21449. */
  21450. static readonly PointFillMode: number;
  21451. /**
  21452. * Returns the point list draw mode
  21453. */
  21454. static readonly PointListDrawMode: number;
  21455. /**
  21456. * Returns the line list draw mode
  21457. */
  21458. static readonly LineListDrawMode: number;
  21459. /**
  21460. * Returns the line loop draw mode
  21461. */
  21462. static readonly LineLoopDrawMode: number;
  21463. /**
  21464. * Returns the line strip draw mode
  21465. */
  21466. static readonly LineStripDrawMode: number;
  21467. /**
  21468. * Returns the triangle strip draw mode
  21469. */
  21470. static readonly TriangleStripDrawMode: number;
  21471. /**
  21472. * Returns the triangle fan draw mode
  21473. */
  21474. static readonly TriangleFanDrawMode: number;
  21475. /**
  21476. * Stores the clock-wise side orientation
  21477. */
  21478. static readonly ClockWiseSideOrientation: number;
  21479. /**
  21480. * Stores the counter clock-wise side orientation
  21481. */
  21482. static readonly CounterClockWiseSideOrientation: number;
  21483. /**
  21484. * The dirty texture flag value
  21485. */
  21486. static readonly TextureDirtyFlag: number;
  21487. /**
  21488. * The dirty light flag value
  21489. */
  21490. static readonly LightDirtyFlag: number;
  21491. /**
  21492. * The dirty fresnel flag value
  21493. */
  21494. static readonly FresnelDirtyFlag: number;
  21495. /**
  21496. * The dirty attribute flag value
  21497. */
  21498. static readonly AttributesDirtyFlag: number;
  21499. /**
  21500. * The dirty misc flag value
  21501. */
  21502. static readonly MiscDirtyFlag: number;
  21503. /**
  21504. * The all dirty flag value
  21505. */
  21506. static readonly AllDirtyFlag: number;
  21507. /**
  21508. * The ID of the material
  21509. */
  21510. id: string;
  21511. /**
  21512. * Gets or sets the unique id of the material
  21513. */
  21514. uniqueId: number;
  21515. /**
  21516. * The name of the material
  21517. */
  21518. name: string;
  21519. /**
  21520. * Gets or sets user defined metadata
  21521. */
  21522. metadata: any;
  21523. /**
  21524. * For internal use only. Please do not use.
  21525. */
  21526. reservedDataStore: any;
  21527. /**
  21528. * Specifies if the ready state should be checked on each call
  21529. */
  21530. checkReadyOnEveryCall: boolean;
  21531. /**
  21532. * Specifies if the ready state should be checked once
  21533. */
  21534. checkReadyOnlyOnce: boolean;
  21535. /**
  21536. * The state of the material
  21537. */
  21538. state: string;
  21539. /**
  21540. * The alpha value of the material
  21541. */
  21542. protected _alpha: number;
  21543. /**
  21544. * Sets the alpha value of the material
  21545. */
  21546. /**
  21547. * Gets the alpha value of the material
  21548. */
  21549. alpha: number;
  21550. /**
  21551. * Specifies if back face culling is enabled
  21552. */
  21553. protected _backFaceCulling: boolean;
  21554. /**
  21555. * Sets the back-face culling state
  21556. */
  21557. /**
  21558. * Gets the back-face culling state
  21559. */
  21560. backFaceCulling: boolean;
  21561. /**
  21562. * Stores the value for side orientation
  21563. */
  21564. sideOrientation: number;
  21565. /**
  21566. * Callback triggered when the material is compiled
  21567. */
  21568. onCompiled: (effect: Effect) => void;
  21569. /**
  21570. * Callback triggered when an error occurs
  21571. */
  21572. onError: (effect: Effect, errors: string) => void;
  21573. /**
  21574. * Callback triggered to get the render target textures
  21575. */
  21576. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  21577. /**
  21578. * Gets a boolean indicating that current material needs to register RTT
  21579. */
  21580. readonly hasRenderTargetTextures: boolean;
  21581. /**
  21582. * Specifies if the material should be serialized
  21583. */
  21584. doNotSerialize: boolean;
  21585. /**
  21586. * @hidden
  21587. */
  21588. _storeEffectOnSubMeshes: boolean;
  21589. /**
  21590. * Stores the animations for the material
  21591. */
  21592. animations: Array<Animation>;
  21593. /**
  21594. * An event triggered when the material is disposed
  21595. */
  21596. onDisposeObservable: Observable<Material>;
  21597. /**
  21598. * An observer which watches for dispose events
  21599. */
  21600. private _onDisposeObserver;
  21601. private _onUnBindObservable;
  21602. /**
  21603. * Called during a dispose event
  21604. */
  21605. onDispose: () => void;
  21606. private _onBindObservable;
  21607. /**
  21608. * An event triggered when the material is bound
  21609. */
  21610. readonly onBindObservable: Observable<AbstractMesh>;
  21611. /**
  21612. * An observer which watches for bind events
  21613. */
  21614. private _onBindObserver;
  21615. /**
  21616. * Called during a bind event
  21617. */
  21618. onBind: (Mesh: AbstractMesh) => void;
  21619. /**
  21620. * An event triggered when the material is unbound
  21621. */
  21622. readonly onUnBindObservable: Observable<Material>;
  21623. /**
  21624. * Stores the value of the alpha mode
  21625. */
  21626. private _alphaMode;
  21627. /**
  21628. * Sets the value of the alpha mode.
  21629. *
  21630. * | Value | Type | Description |
  21631. * | --- | --- | --- |
  21632. * | 0 | ALPHA_DISABLE | |
  21633. * | 1 | ALPHA_ADD | |
  21634. * | 2 | ALPHA_COMBINE | |
  21635. * | 3 | ALPHA_SUBTRACT | |
  21636. * | 4 | ALPHA_MULTIPLY | |
  21637. * | 5 | ALPHA_MAXIMIZED | |
  21638. * | 6 | ALPHA_ONEONE | |
  21639. * | 7 | ALPHA_PREMULTIPLIED | |
  21640. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21641. * | 9 | ALPHA_INTERPOLATE | |
  21642. * | 10 | ALPHA_SCREENMODE | |
  21643. *
  21644. */
  21645. /**
  21646. * Gets the value of the alpha mode
  21647. */
  21648. alphaMode: number;
  21649. /**
  21650. * Stores the state of the need depth pre-pass value
  21651. */
  21652. private _needDepthPrePass;
  21653. /**
  21654. * Sets the need depth pre-pass value
  21655. */
  21656. /**
  21657. * Gets the depth pre-pass value
  21658. */
  21659. needDepthPrePass: boolean;
  21660. /**
  21661. * Specifies if depth writing should be disabled
  21662. */
  21663. disableDepthWrite: boolean;
  21664. /**
  21665. * Specifies if depth writing should be forced
  21666. */
  21667. forceDepthWrite: boolean;
  21668. /**
  21669. * Specifies if there should be a separate pass for culling
  21670. */
  21671. separateCullingPass: boolean;
  21672. /**
  21673. * Stores the state specifing if fog should be enabled
  21674. */
  21675. private _fogEnabled;
  21676. /**
  21677. * Sets the state for enabling fog
  21678. */
  21679. /**
  21680. * Gets the value of the fog enabled state
  21681. */
  21682. fogEnabled: boolean;
  21683. /**
  21684. * Stores the size of points
  21685. */
  21686. pointSize: number;
  21687. /**
  21688. * Stores the z offset value
  21689. */
  21690. zOffset: number;
  21691. /**
  21692. * Gets a value specifying if wireframe mode is enabled
  21693. */
  21694. /**
  21695. * Sets the state of wireframe mode
  21696. */
  21697. wireframe: boolean;
  21698. /**
  21699. * Gets the value specifying if point clouds are enabled
  21700. */
  21701. /**
  21702. * Sets the state of point cloud mode
  21703. */
  21704. pointsCloud: boolean;
  21705. /**
  21706. * Gets the material fill mode
  21707. */
  21708. /**
  21709. * Sets the material fill mode
  21710. */
  21711. fillMode: number;
  21712. /**
  21713. * @hidden
  21714. * Stores the effects for the material
  21715. */
  21716. _effect: Nullable<Effect>;
  21717. /**
  21718. * @hidden
  21719. * Specifies if the material was previously ready
  21720. */
  21721. _wasPreviouslyReady: boolean;
  21722. /**
  21723. * Specifies if uniform buffers should be used
  21724. */
  21725. private _useUBO;
  21726. /**
  21727. * Stores a reference to the scene
  21728. */
  21729. private _scene;
  21730. /**
  21731. * Stores the fill mode state
  21732. */
  21733. private _fillMode;
  21734. /**
  21735. * Specifies if the depth write state should be cached
  21736. */
  21737. private _cachedDepthWriteState;
  21738. /**
  21739. * Stores the uniform buffer
  21740. */
  21741. protected _uniformBuffer: UniformBuffer;
  21742. /** @hidden */
  21743. _indexInSceneMaterialArray: number;
  21744. /** @hidden */
  21745. meshMap: Nullable<{
  21746. [id: string]: AbstractMesh | undefined;
  21747. }>;
  21748. /**
  21749. * Creates a material instance
  21750. * @param name defines the name of the material
  21751. * @param scene defines the scene to reference
  21752. * @param doNotAdd specifies if the material should be added to the scene
  21753. */
  21754. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21755. /**
  21756. * Returns a string representation of the current material
  21757. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21758. * @returns a string with material information
  21759. */
  21760. toString(fullDetails?: boolean): string;
  21761. /**
  21762. * Gets the class name of the material
  21763. * @returns a string with the class name of the material
  21764. */
  21765. getClassName(): string;
  21766. /**
  21767. * Specifies if updates for the material been locked
  21768. */
  21769. readonly isFrozen: boolean;
  21770. /**
  21771. * Locks updates for the material
  21772. */
  21773. freeze(): void;
  21774. /**
  21775. * Unlocks updates for the material
  21776. */
  21777. unfreeze(): void;
  21778. /**
  21779. * Specifies if the material is ready to be used
  21780. * @param mesh defines the mesh to check
  21781. * @param useInstances specifies if instances should be used
  21782. * @returns a boolean indicating if the material is ready to be used
  21783. */
  21784. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21785. /**
  21786. * Specifies that the submesh is ready to be used
  21787. * @param mesh defines the mesh to check
  21788. * @param subMesh defines which submesh to check
  21789. * @param useInstances specifies that instances should be used
  21790. * @returns a boolean indicating that the submesh is ready or not
  21791. */
  21792. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21793. /**
  21794. * Returns the material effect
  21795. * @returns the effect associated with the material
  21796. */
  21797. getEffect(): Nullable<Effect>;
  21798. /**
  21799. * Returns the current scene
  21800. * @returns a Scene
  21801. */
  21802. getScene(): Scene;
  21803. /**
  21804. * Specifies if the material will require alpha blending
  21805. * @returns a boolean specifying if alpha blending is needed
  21806. */
  21807. needAlphaBlending(): boolean;
  21808. /**
  21809. * Specifies if the mesh will require alpha blending
  21810. * @param mesh defines the mesh to check
  21811. * @returns a boolean specifying if alpha blending is needed for the mesh
  21812. */
  21813. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21814. /**
  21815. * Specifies if this material should be rendered in alpha test mode
  21816. * @returns a boolean specifying if an alpha test is needed.
  21817. */
  21818. needAlphaTesting(): boolean;
  21819. /**
  21820. * Gets the texture used for the alpha test
  21821. * @returns the texture to use for alpha testing
  21822. */
  21823. getAlphaTestTexture(): Nullable<BaseTexture>;
  21824. /**
  21825. * Marks the material to indicate that it needs to be re-calculated
  21826. */
  21827. markDirty(): void;
  21828. /** @hidden */
  21829. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21830. /**
  21831. * Binds the material to the mesh
  21832. * @param world defines the world transformation matrix
  21833. * @param mesh defines the mesh to bind the material to
  21834. */
  21835. bind(world: Matrix, mesh?: Mesh): void;
  21836. /**
  21837. * Binds the submesh to the material
  21838. * @param world defines the world transformation matrix
  21839. * @param mesh defines the mesh containing the submesh
  21840. * @param subMesh defines the submesh to bind the material to
  21841. */
  21842. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21843. /**
  21844. * Binds the world matrix to the material
  21845. * @param world defines the world transformation matrix
  21846. */
  21847. bindOnlyWorldMatrix(world: Matrix): void;
  21848. /**
  21849. * Binds the scene's uniform buffer to the effect.
  21850. * @param effect defines the effect to bind to the scene uniform buffer
  21851. * @param sceneUbo defines the uniform buffer storing scene data
  21852. */
  21853. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21854. /**
  21855. * Binds the view matrix to the effect
  21856. * @param effect defines the effect to bind the view matrix to
  21857. */
  21858. bindView(effect: Effect): void;
  21859. /**
  21860. * Binds the view projection matrix to the effect
  21861. * @param effect defines the effect to bind the view projection matrix to
  21862. */
  21863. bindViewProjection(effect: Effect): void;
  21864. /**
  21865. * Specifies if material alpha testing should be turned on for the mesh
  21866. * @param mesh defines the mesh to check
  21867. */
  21868. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21869. /**
  21870. * Processes to execute after binding the material to a mesh
  21871. * @param mesh defines the rendered mesh
  21872. */
  21873. protected _afterBind(mesh?: Mesh): void;
  21874. /**
  21875. * Unbinds the material from the mesh
  21876. */
  21877. unbind(): void;
  21878. /**
  21879. * Gets the active textures from the material
  21880. * @returns an array of textures
  21881. */
  21882. getActiveTextures(): BaseTexture[];
  21883. /**
  21884. * Specifies if the material uses a texture
  21885. * @param texture defines the texture to check against the material
  21886. * @returns a boolean specifying if the material uses the texture
  21887. */
  21888. hasTexture(texture: BaseTexture): boolean;
  21889. /**
  21890. * Makes a duplicate of the material, and gives it a new name
  21891. * @param name defines the new name for the duplicated material
  21892. * @returns the cloned material
  21893. */
  21894. clone(name: string): Nullable<Material>;
  21895. /**
  21896. * Gets the meshes bound to the material
  21897. * @returns an array of meshes bound to the material
  21898. */
  21899. getBindedMeshes(): AbstractMesh[];
  21900. /**
  21901. * Force shader compilation
  21902. * @param mesh defines the mesh associated with this material
  21903. * @param onCompiled defines a function to execute once the material is compiled
  21904. * @param options defines the options to configure the compilation
  21905. */
  21906. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  21907. clipPlane: boolean;
  21908. }>): void;
  21909. /**
  21910. * Force shader compilation
  21911. * @param mesh defines the mesh that will use this material
  21912. * @param options defines additional options for compiling the shaders
  21913. * @returns a promise that resolves when the compilation completes
  21914. */
  21915. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21916. clipPlane: boolean;
  21917. }>): Promise<void>;
  21918. private static readonly _ImageProcessingDirtyCallBack;
  21919. private static readonly _TextureDirtyCallBack;
  21920. private static readonly _FresnelDirtyCallBack;
  21921. private static readonly _MiscDirtyCallBack;
  21922. private static readonly _LightsDirtyCallBack;
  21923. private static readonly _AttributeDirtyCallBack;
  21924. private static _FresnelAndMiscDirtyCallBack;
  21925. private static _TextureAndMiscDirtyCallBack;
  21926. private static readonly _DirtyCallbackArray;
  21927. private static readonly _RunDirtyCallBacks;
  21928. /**
  21929. * Marks a define in the material to indicate that it needs to be re-computed
  21930. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21931. */
  21932. markAsDirty(flag: number): void;
  21933. /**
  21934. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21935. * @param func defines a function which checks material defines against the submeshes
  21936. */
  21937. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21938. /**
  21939. * Indicates that image processing needs to be re-calculated for all submeshes
  21940. */
  21941. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21942. /**
  21943. * Indicates that textures need to be re-calculated for all submeshes
  21944. */
  21945. protected _markAllSubMeshesAsTexturesDirty(): void;
  21946. /**
  21947. * Indicates that fresnel needs to be re-calculated for all submeshes
  21948. */
  21949. protected _markAllSubMeshesAsFresnelDirty(): void;
  21950. /**
  21951. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21952. */
  21953. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21954. /**
  21955. * Indicates that lights need to be re-calculated for all submeshes
  21956. */
  21957. protected _markAllSubMeshesAsLightsDirty(): void;
  21958. /**
  21959. * Indicates that attributes need to be re-calculated for all submeshes
  21960. */
  21961. protected _markAllSubMeshesAsAttributesDirty(): void;
  21962. /**
  21963. * Indicates that misc needs to be re-calculated for all submeshes
  21964. */
  21965. protected _markAllSubMeshesAsMiscDirty(): void;
  21966. /**
  21967. * Indicates that textures and misc need to be re-calculated for all submeshes
  21968. */
  21969. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21970. /**
  21971. * Disposes the material
  21972. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21973. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21974. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21975. */
  21976. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21977. /** @hidden */
  21978. private releaseVertexArrayObject;
  21979. /**
  21980. * Serializes this material
  21981. * @returns the serialized material object
  21982. */
  21983. serialize(): any;
  21984. /**
  21985. * Creates a material from parsed material data
  21986. * @param parsedMaterial defines parsed material data
  21987. * @param scene defines the hosting scene
  21988. * @param rootUrl defines the root URL to use to load textures
  21989. * @returns a new material
  21990. */
  21991. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  21992. }
  21993. }
  21994. declare module "babylonjs/Meshes/subMesh" {
  21995. import { Nullable, IndicesArray, DeepImmutable } from "babylonjs/types";
  21996. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  21997. import { Engine } from "babylonjs/Engines/engine";
  21998. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21999. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22000. import { Effect } from "babylonjs/Materials/effect";
  22001. import { Collider } from "babylonjs/Collisions/collider";
  22002. import { Material } from "babylonjs/Materials/material";
  22003. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22004. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22005. import { Mesh } from "babylonjs/Meshes/mesh";
  22006. import { Ray } from "babylonjs/Culling/ray";
  22007. /**
  22008. * Base class for submeshes
  22009. */
  22010. export class BaseSubMesh {
  22011. /** @hidden */
  22012. _materialDefines: Nullable<MaterialDefines>;
  22013. /** @hidden */
  22014. _materialEffect: Nullable<Effect>;
  22015. /**
  22016. * Gets associated effect
  22017. */
  22018. readonly effect: Nullable<Effect>;
  22019. /**
  22020. * Sets associated effect (effect used to render this submesh)
  22021. * @param effect defines the effect to associate with
  22022. * @param defines defines the set of defines used to compile this effect
  22023. */
  22024. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22025. }
  22026. /**
  22027. * Defines a subdivision inside a mesh
  22028. */
  22029. export class SubMesh extends BaseSubMesh implements ICullable {
  22030. /** the material index to use */
  22031. materialIndex: number;
  22032. /** vertex index start */
  22033. verticesStart: number;
  22034. /** vertices count */
  22035. verticesCount: number;
  22036. /** index start */
  22037. indexStart: number;
  22038. /** indices count */
  22039. indexCount: number;
  22040. /** @hidden */
  22041. _linesIndexCount: number;
  22042. private _mesh;
  22043. private _renderingMesh;
  22044. private _boundingInfo;
  22045. private _linesIndexBuffer;
  22046. /** @hidden */
  22047. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22048. /** @hidden */
  22049. _trianglePlanes: Plane[];
  22050. /** @hidden */
  22051. _lastColliderTransformMatrix: Matrix;
  22052. /** @hidden */
  22053. _renderId: number;
  22054. /** @hidden */
  22055. _alphaIndex: number;
  22056. /** @hidden */
  22057. _distanceToCamera: number;
  22058. /** @hidden */
  22059. _id: number;
  22060. private _currentMaterial;
  22061. /**
  22062. * Add a new submesh to a mesh
  22063. * @param materialIndex defines the material index to use
  22064. * @param verticesStart defines vertex index start
  22065. * @param verticesCount defines vertices count
  22066. * @param indexStart defines index start
  22067. * @param indexCount defines indices count
  22068. * @param mesh defines the parent mesh
  22069. * @param renderingMesh defines an optional rendering mesh
  22070. * @param createBoundingBox defines if bounding box should be created for this submesh
  22071. * @returns the new submesh
  22072. */
  22073. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22074. /**
  22075. * Creates a new submesh
  22076. * @param materialIndex defines the material index to use
  22077. * @param verticesStart defines vertex index start
  22078. * @param verticesCount defines vertices count
  22079. * @param indexStart defines index start
  22080. * @param indexCount defines indices count
  22081. * @param mesh defines the parent mesh
  22082. * @param renderingMesh defines an optional rendering mesh
  22083. * @param createBoundingBox defines if bounding box should be created for this submesh
  22084. */
  22085. constructor(
  22086. /** the material index to use */
  22087. materialIndex: number,
  22088. /** vertex index start */
  22089. verticesStart: number,
  22090. /** vertices count */
  22091. verticesCount: number,
  22092. /** index start */
  22093. indexStart: number,
  22094. /** indices count */
  22095. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22096. /**
  22097. * Returns true if this submesh covers the entire parent mesh
  22098. * @ignorenaming
  22099. */
  22100. readonly IsGlobal: boolean;
  22101. /**
  22102. * Returns the submesh BoudingInfo object
  22103. * @returns current bounding info (or mesh's one if the submesh is global)
  22104. */
  22105. getBoundingInfo(): BoundingInfo;
  22106. /**
  22107. * Sets the submesh BoundingInfo
  22108. * @param boundingInfo defines the new bounding info to use
  22109. * @returns the SubMesh
  22110. */
  22111. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22112. /**
  22113. * Returns the mesh of the current submesh
  22114. * @return the parent mesh
  22115. */
  22116. getMesh(): AbstractMesh;
  22117. /**
  22118. * Returns the rendering mesh of the submesh
  22119. * @returns the rendering mesh (could be different from parent mesh)
  22120. */
  22121. getRenderingMesh(): Mesh;
  22122. /**
  22123. * Returns the submesh material
  22124. * @returns null or the current material
  22125. */
  22126. getMaterial(): Nullable<Material>;
  22127. /**
  22128. * Sets a new updated BoundingInfo object to the submesh
  22129. * @returns the SubMesh
  22130. */
  22131. refreshBoundingInfo(): SubMesh;
  22132. /** @hidden */
  22133. _checkCollision(collider: Collider): boolean;
  22134. /**
  22135. * Updates the submesh BoundingInfo
  22136. * @param world defines the world matrix to use to update the bounding info
  22137. * @returns the submesh
  22138. */
  22139. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22140. /**
  22141. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22142. * @param frustumPlanes defines the frustum planes
  22143. * @returns true if the submesh is intersecting with the frustum
  22144. */
  22145. isInFrustum(frustumPlanes: Plane[]): boolean;
  22146. /**
  22147. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22148. * @param frustumPlanes defines the frustum planes
  22149. * @returns true if the submesh is inside the frustum
  22150. */
  22151. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22152. /**
  22153. * Renders the submesh
  22154. * @param enableAlphaMode defines if alpha needs to be used
  22155. * @returns the submesh
  22156. */
  22157. render(enableAlphaMode: boolean): SubMesh;
  22158. /**
  22159. * @hidden
  22160. */
  22161. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  22162. /**
  22163. * Checks if the submesh intersects with a ray
  22164. * @param ray defines the ray to test
  22165. * @returns true is the passed ray intersects the submesh bounding box
  22166. */
  22167. canIntersects(ray: Ray): boolean;
  22168. /**
  22169. * Intersects current submesh with a ray
  22170. * @param ray defines the ray to test
  22171. * @param positions defines mesh's positions array
  22172. * @param indices defines mesh's indices array
  22173. * @param fastCheck defines if only bounding info should be used
  22174. * @returns intersection info or null if no intersection
  22175. */
  22176. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  22177. /** @hidden */
  22178. private _intersectLines;
  22179. /** @hidden */
  22180. private _intersectTriangles;
  22181. /** @hidden */
  22182. _rebuild(): void;
  22183. /**
  22184. * Creates a new submesh from the passed mesh
  22185. * @param newMesh defines the new hosting mesh
  22186. * @param newRenderingMesh defines an optional rendering mesh
  22187. * @returns the new submesh
  22188. */
  22189. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22190. /**
  22191. * Release associated resources
  22192. */
  22193. dispose(): void;
  22194. /**
  22195. * Gets the class name
  22196. * @returns the string "SubMesh".
  22197. */
  22198. getClassName(): string;
  22199. /**
  22200. * Creates a new submesh from indices data
  22201. * @param materialIndex the index of the main mesh material
  22202. * @param startIndex the index where to start the copy in the mesh indices array
  22203. * @param indexCount the number of indices to copy then from the startIndex
  22204. * @param mesh the main mesh to create the submesh from
  22205. * @param renderingMesh the optional rendering mesh
  22206. * @returns a new submesh
  22207. */
  22208. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22209. }
  22210. }
  22211. declare module "babylonjs/Meshes/geometry" {
  22212. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22213. import { Scene } from "babylonjs/scene";
  22214. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  22215. import { Engine } from "babylonjs/Engines/engine";
  22216. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22217. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22218. import { Effect } from "babylonjs/Materials/effect";
  22219. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22220. import { Mesh } from "babylonjs/Meshes/mesh";
  22221. /**
  22222. * Class used to store geometry data (vertex buffers + index buffer)
  22223. */
  22224. export class Geometry implements IGetSetVerticesData {
  22225. /**
  22226. * Gets or sets the ID of the geometry
  22227. */
  22228. id: string;
  22229. /**
  22230. * Gets or sets the unique ID of the geometry
  22231. */
  22232. uniqueId: number;
  22233. /**
  22234. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22235. */
  22236. delayLoadState: number;
  22237. /**
  22238. * Gets the file containing the data to load when running in delay load state
  22239. */
  22240. delayLoadingFile: Nullable<string>;
  22241. /**
  22242. * Callback called when the geometry is updated
  22243. */
  22244. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22245. private _scene;
  22246. private _engine;
  22247. private _meshes;
  22248. private _totalVertices;
  22249. /** @hidden */
  22250. _indices: IndicesArray;
  22251. /** @hidden */
  22252. _vertexBuffers: {
  22253. [key: string]: VertexBuffer;
  22254. };
  22255. private _isDisposed;
  22256. private _extend;
  22257. private _boundingBias;
  22258. /** @hidden */
  22259. _delayInfo: Array<string>;
  22260. private _indexBuffer;
  22261. private _indexBufferIsUpdatable;
  22262. /** @hidden */
  22263. _boundingInfo: Nullable<BoundingInfo>;
  22264. /** @hidden */
  22265. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22266. /** @hidden */
  22267. _softwareSkinningFrameId: number;
  22268. private _vertexArrayObjects;
  22269. private _updatable;
  22270. /** @hidden */
  22271. _positions: Nullable<Vector3[]>;
  22272. /**
  22273. * 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
  22274. */
  22275. /**
  22276. * 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
  22277. */
  22278. boundingBias: Vector2;
  22279. /**
  22280. * Static function used to attach a new empty geometry to a mesh
  22281. * @param mesh defines the mesh to attach the geometry to
  22282. * @returns the new Geometry
  22283. */
  22284. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22285. /**
  22286. * Creates a new geometry
  22287. * @param id defines the unique ID
  22288. * @param scene defines the hosting scene
  22289. * @param vertexData defines the VertexData used to get geometry data
  22290. * @param updatable defines if geometry must be updatable (false by default)
  22291. * @param mesh defines the mesh that will be associated with the geometry
  22292. */
  22293. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22294. /**
  22295. * Gets the current extend of the geometry
  22296. */
  22297. readonly extend: {
  22298. minimum: Vector3;
  22299. maximum: Vector3;
  22300. };
  22301. /**
  22302. * Gets the hosting scene
  22303. * @returns the hosting Scene
  22304. */
  22305. getScene(): Scene;
  22306. /**
  22307. * Gets the hosting engine
  22308. * @returns the hosting Engine
  22309. */
  22310. getEngine(): Engine;
  22311. /**
  22312. * Defines if the geometry is ready to use
  22313. * @returns true if the geometry is ready to be used
  22314. */
  22315. isReady(): boolean;
  22316. /**
  22317. * Gets a value indicating that the geometry should not be serialized
  22318. */
  22319. readonly doNotSerialize: boolean;
  22320. /** @hidden */
  22321. _rebuild(): void;
  22322. /**
  22323. * Affects all geometry data in one call
  22324. * @param vertexData defines the geometry data
  22325. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22326. */
  22327. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22328. /**
  22329. * Set specific vertex data
  22330. * @param kind defines the data kind (Position, normal, etc...)
  22331. * @param data defines the vertex data to use
  22332. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22333. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22334. */
  22335. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22336. /**
  22337. * Removes a specific vertex data
  22338. * @param kind defines the data kind (Position, normal, etc...)
  22339. */
  22340. removeVerticesData(kind: string): void;
  22341. /**
  22342. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22343. * @param buffer defines the vertex buffer to use
  22344. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22345. */
  22346. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22347. /**
  22348. * Update a specific vertex buffer
  22349. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  22350. * It will do nothing if the buffer is not updatable
  22351. * @param kind defines the data kind (Position, normal, etc...)
  22352. * @param data defines the data to use
  22353. * @param offset defines the offset in the target buffer where to store the data
  22354. * @param useBytes set to true if the offset is in bytes
  22355. */
  22356. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22357. /**
  22358. * Update a specific vertex buffer
  22359. * This function will create a new buffer if the current one is not updatable
  22360. * @param kind defines the data kind (Position, normal, etc...)
  22361. * @param data defines the data to use
  22362. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22363. */
  22364. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22365. private _updateBoundingInfo;
  22366. /** @hidden */
  22367. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  22368. /**
  22369. * Gets total number of vertices
  22370. * @returns the total number of vertices
  22371. */
  22372. getTotalVertices(): number;
  22373. /**
  22374. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22375. * @param kind defines the data kind (Position, normal, etc...)
  22376. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22377. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22378. * @returns a float array containing vertex data
  22379. */
  22380. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22381. /**
  22382. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22383. * @param kind defines the data kind (Position, normal, etc...)
  22384. * @returns true if the vertex buffer with the specified kind is updatable
  22385. */
  22386. isVertexBufferUpdatable(kind: string): boolean;
  22387. /**
  22388. * Gets a specific vertex buffer
  22389. * @param kind defines the data kind (Position, normal, etc...)
  22390. * @returns a VertexBuffer
  22391. */
  22392. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22393. /**
  22394. * Returns all vertex buffers
  22395. * @return an object holding all vertex buffers indexed by kind
  22396. */
  22397. getVertexBuffers(): Nullable<{
  22398. [key: string]: VertexBuffer;
  22399. }>;
  22400. /**
  22401. * Gets a boolean indicating if specific vertex buffer is present
  22402. * @param kind defines the data kind (Position, normal, etc...)
  22403. * @returns true if data is present
  22404. */
  22405. isVerticesDataPresent(kind: string): boolean;
  22406. /**
  22407. * Gets a list of all attached data kinds (Position, normal, etc...)
  22408. * @returns a list of string containing all kinds
  22409. */
  22410. getVerticesDataKinds(): string[];
  22411. /**
  22412. * Update index buffer
  22413. * @param indices defines the indices to store in the index buffer
  22414. * @param offset defines the offset in the target buffer where to store the data
  22415. */
  22416. updateIndices(indices: IndicesArray, offset?: number): void;
  22417. /**
  22418. * Creates a new index buffer
  22419. * @param indices defines the indices to store in the index buffer
  22420. * @param totalVertices defines the total number of vertices (could be null)
  22421. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22422. */
  22423. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22424. /**
  22425. * Return the total number of indices
  22426. * @returns the total number of indices
  22427. */
  22428. getTotalIndices(): number;
  22429. /**
  22430. * Gets the index buffer array
  22431. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22432. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22433. * @returns the index buffer array
  22434. */
  22435. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22436. /**
  22437. * Gets the index buffer
  22438. * @return the index buffer
  22439. */
  22440. getIndexBuffer(): Nullable<WebGLBuffer>;
  22441. /** @hidden */
  22442. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22443. /**
  22444. * Release the associated resources for a specific mesh
  22445. * @param mesh defines the source mesh
  22446. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22447. */
  22448. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22449. /**
  22450. * Apply current geometry to a given mesh
  22451. * @param mesh defines the mesh to apply geometry to
  22452. */
  22453. applyToMesh(mesh: Mesh): void;
  22454. private _updateExtend;
  22455. private _applyToMesh;
  22456. private notifyUpdate;
  22457. /**
  22458. * Load the geometry if it was flagged as delay loaded
  22459. * @param scene defines the hosting scene
  22460. * @param onLoaded defines a callback called when the geometry is loaded
  22461. */
  22462. load(scene: Scene, onLoaded?: () => void): void;
  22463. private _queueLoad;
  22464. /**
  22465. * Invert the geometry to move from a right handed system to a left handed one.
  22466. */
  22467. toLeftHanded(): void;
  22468. /** @hidden */
  22469. _resetPointsArrayCache(): void;
  22470. /** @hidden */
  22471. _generatePointsArray(): boolean;
  22472. /**
  22473. * Gets a value indicating if the geometry is disposed
  22474. * @returns true if the geometry was disposed
  22475. */
  22476. isDisposed(): boolean;
  22477. private _disposeVertexArrayObjects;
  22478. /**
  22479. * Free all associated resources
  22480. */
  22481. dispose(): void;
  22482. /**
  22483. * Clone the current geometry into a new geometry
  22484. * @param id defines the unique ID of the new geometry
  22485. * @returns a new geometry object
  22486. */
  22487. copy(id: string): Geometry;
  22488. /**
  22489. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22490. * @return a JSON representation of the current geometry data (without the vertices data)
  22491. */
  22492. serialize(): any;
  22493. private toNumberArray;
  22494. /**
  22495. * Serialize all vertices data into a JSON oject
  22496. * @returns a JSON representation of the current geometry data
  22497. */
  22498. serializeVerticeData(): any;
  22499. /**
  22500. * Extracts a clone of a mesh geometry
  22501. * @param mesh defines the source mesh
  22502. * @param id defines the unique ID of the new geometry object
  22503. * @returns the new geometry object
  22504. */
  22505. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22506. /**
  22507. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22508. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22509. * Be aware Math.random() could cause collisions, but:
  22510. * "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"
  22511. * @returns a string containing a new GUID
  22512. */
  22513. static RandomId(): string;
  22514. /** @hidden */
  22515. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22516. private static _CleanMatricesWeights;
  22517. /**
  22518. * Create a new geometry from persisted data (Using .babylon file format)
  22519. * @param parsedVertexData defines the persisted data
  22520. * @param scene defines the hosting scene
  22521. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22522. * @returns the new geometry object
  22523. */
  22524. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22525. }
  22526. }
  22527. declare module "babylonjs/Meshes/mesh.vertexData" {
  22528. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22529. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  22530. import { Geometry } from "babylonjs/Meshes/geometry";
  22531. import { Mesh } from "babylonjs/Meshes/mesh";
  22532. /**
  22533. * Define an interface for all classes that will get and set the data on vertices
  22534. */
  22535. export interface IGetSetVerticesData {
  22536. /**
  22537. * Gets a boolean indicating if specific vertex data is present
  22538. * @param kind defines the vertex data kind to use
  22539. * @returns true is data kind is present
  22540. */
  22541. isVerticesDataPresent(kind: string): boolean;
  22542. /**
  22543. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22544. * @param kind defines the data kind (Position, normal, etc...)
  22545. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22546. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22547. * @returns a float array containing vertex data
  22548. */
  22549. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22550. /**
  22551. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22552. * @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.
  22553. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22554. * @returns the indices array or an empty array if the mesh has no geometry
  22555. */
  22556. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22557. /**
  22558. * Set specific vertex data
  22559. * @param kind defines the data kind (Position, normal, etc...)
  22560. * @param data defines the vertex data to use
  22561. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22562. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22563. */
  22564. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22565. /**
  22566. * Update a specific associated vertex buffer
  22567. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22568. * - VertexBuffer.PositionKind
  22569. * - VertexBuffer.UVKind
  22570. * - VertexBuffer.UV2Kind
  22571. * - VertexBuffer.UV3Kind
  22572. * - VertexBuffer.UV4Kind
  22573. * - VertexBuffer.UV5Kind
  22574. * - VertexBuffer.UV6Kind
  22575. * - VertexBuffer.ColorKind
  22576. * - VertexBuffer.MatricesIndicesKind
  22577. * - VertexBuffer.MatricesIndicesExtraKind
  22578. * - VertexBuffer.MatricesWeightsKind
  22579. * - VertexBuffer.MatricesWeightsExtraKind
  22580. * @param data defines the data source
  22581. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22582. * @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)
  22583. */
  22584. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22585. /**
  22586. * Creates a new index buffer
  22587. * @param indices defines the indices to store in the index buffer
  22588. * @param totalVertices defines the total number of vertices (could be null)
  22589. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22590. */
  22591. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22592. }
  22593. /**
  22594. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22595. */
  22596. export class VertexData {
  22597. /**
  22598. * Mesh side orientation : usually the external or front surface
  22599. */
  22600. static readonly FRONTSIDE: number;
  22601. /**
  22602. * Mesh side orientation : usually the internal or back surface
  22603. */
  22604. static readonly BACKSIDE: number;
  22605. /**
  22606. * Mesh side orientation : both internal and external or front and back surfaces
  22607. */
  22608. static readonly DOUBLESIDE: number;
  22609. /**
  22610. * Mesh side orientation : by default, `FRONTSIDE`
  22611. */
  22612. static readonly DEFAULTSIDE: number;
  22613. /**
  22614. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22615. */
  22616. positions: Nullable<FloatArray>;
  22617. /**
  22618. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22619. */
  22620. normals: Nullable<FloatArray>;
  22621. /**
  22622. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22623. */
  22624. tangents: Nullable<FloatArray>;
  22625. /**
  22626. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22627. */
  22628. uvs: Nullable<FloatArray>;
  22629. /**
  22630. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22631. */
  22632. uvs2: Nullable<FloatArray>;
  22633. /**
  22634. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22635. */
  22636. uvs3: Nullable<FloatArray>;
  22637. /**
  22638. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22639. */
  22640. uvs4: Nullable<FloatArray>;
  22641. /**
  22642. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22643. */
  22644. uvs5: Nullable<FloatArray>;
  22645. /**
  22646. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22647. */
  22648. uvs6: Nullable<FloatArray>;
  22649. /**
  22650. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22651. */
  22652. colors: Nullable<FloatArray>;
  22653. /**
  22654. * 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).
  22655. */
  22656. matricesIndices: Nullable<FloatArray>;
  22657. /**
  22658. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22659. */
  22660. matricesWeights: Nullable<FloatArray>;
  22661. /**
  22662. * An array extending the number of possible indices
  22663. */
  22664. matricesIndicesExtra: Nullable<FloatArray>;
  22665. /**
  22666. * An array extending the number of possible weights when the number of indices is extended
  22667. */
  22668. matricesWeightsExtra: Nullable<FloatArray>;
  22669. /**
  22670. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22671. */
  22672. indices: Nullable<IndicesArray>;
  22673. /**
  22674. * Uses the passed data array to set the set the values for the specified kind of data
  22675. * @param data a linear array of floating numbers
  22676. * @param kind the type of data that is being set, eg positions, colors etc
  22677. */
  22678. set(data: FloatArray, kind: string): void;
  22679. /**
  22680. * Associates the vertexData to the passed Mesh.
  22681. * Sets it as updatable or not (default `false`)
  22682. * @param mesh the mesh the vertexData is applied to
  22683. * @param updatable when used and having the value true allows new data to update the vertexData
  22684. * @returns the VertexData
  22685. */
  22686. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22687. /**
  22688. * Associates the vertexData to the passed Geometry.
  22689. * Sets it as updatable or not (default `false`)
  22690. * @param geometry the geometry the vertexData is applied to
  22691. * @param updatable when used and having the value true allows new data to update the vertexData
  22692. * @returns VertexData
  22693. */
  22694. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22695. /**
  22696. * Updates the associated mesh
  22697. * @param mesh the mesh to be updated
  22698. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22699. * @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
  22700. * @returns VertexData
  22701. */
  22702. updateMesh(mesh: Mesh): VertexData;
  22703. /**
  22704. * Updates the associated geometry
  22705. * @param geometry the geometry to be updated
  22706. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22707. * @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
  22708. * @returns VertexData.
  22709. */
  22710. updateGeometry(geometry: Geometry): VertexData;
  22711. private _applyTo;
  22712. private _update;
  22713. /**
  22714. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22715. * @param matrix the transforming matrix
  22716. * @returns the VertexData
  22717. */
  22718. transform(matrix: Matrix): VertexData;
  22719. /**
  22720. * Merges the passed VertexData into the current one
  22721. * @param other the VertexData to be merged into the current one
  22722. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22723. * @returns the modified VertexData
  22724. */
  22725. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22726. private _mergeElement;
  22727. private _validate;
  22728. /**
  22729. * Serializes the VertexData
  22730. * @returns a serialized object
  22731. */
  22732. serialize(): any;
  22733. /**
  22734. * Extracts the vertexData from a mesh
  22735. * @param mesh the mesh from which to extract the VertexData
  22736. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22737. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22738. * @returns the object VertexData associated to the passed mesh
  22739. */
  22740. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22741. /**
  22742. * Extracts the vertexData from the geometry
  22743. * @param geometry the geometry from which to extract the VertexData
  22744. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22745. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22746. * @returns the object VertexData associated to the passed mesh
  22747. */
  22748. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22749. private static _ExtractFrom;
  22750. /**
  22751. * Creates the VertexData for a Ribbon
  22752. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22753. * * pathArray array of paths, each of which an array of successive Vector3
  22754. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22755. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22756. * * 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
  22757. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22758. * * 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)
  22759. * * 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)
  22760. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22761. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22762. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22763. * @returns the VertexData of the ribbon
  22764. */
  22765. static CreateRibbon(options: {
  22766. pathArray: Vector3[][];
  22767. closeArray?: boolean;
  22768. closePath?: boolean;
  22769. offset?: number;
  22770. sideOrientation?: number;
  22771. frontUVs?: Vector4;
  22772. backUVs?: Vector4;
  22773. invertUV?: boolean;
  22774. uvs?: Vector2[];
  22775. colors?: Color4[];
  22776. }): VertexData;
  22777. /**
  22778. * Creates the VertexData for a box
  22779. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22780. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22781. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22782. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22783. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22784. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22785. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22786. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22787. * * 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)
  22788. * * 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)
  22789. * @returns the VertexData of the box
  22790. */
  22791. static CreateBox(options: {
  22792. size?: number;
  22793. width?: number;
  22794. height?: number;
  22795. depth?: number;
  22796. faceUV?: Vector4[];
  22797. faceColors?: Color4[];
  22798. sideOrientation?: number;
  22799. frontUVs?: Vector4;
  22800. backUVs?: Vector4;
  22801. }): VertexData;
  22802. /**
  22803. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22804. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22805. * * segments sets the number of horizontal strips optional, default 32
  22806. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22807. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22808. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22809. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22810. * * 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
  22811. * * 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
  22812. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22813. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22814. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22815. * @returns the VertexData of the ellipsoid
  22816. */
  22817. static CreateSphere(options: {
  22818. segments?: number;
  22819. diameter?: number;
  22820. diameterX?: number;
  22821. diameterY?: number;
  22822. diameterZ?: number;
  22823. arc?: number;
  22824. slice?: number;
  22825. sideOrientation?: number;
  22826. frontUVs?: Vector4;
  22827. backUVs?: Vector4;
  22828. }): VertexData;
  22829. /**
  22830. * Creates the VertexData for a cylinder, cone or prism
  22831. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22832. * * height sets the height (y direction) of the cylinder, optional, default 2
  22833. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22834. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22835. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22836. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22837. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22838. * * 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
  22839. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22840. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22841. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22842. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22843. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22844. * * 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)
  22845. * * 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)
  22846. * @returns the VertexData of the cylinder, cone or prism
  22847. */
  22848. static CreateCylinder(options: {
  22849. height?: number;
  22850. diameterTop?: number;
  22851. diameterBottom?: number;
  22852. diameter?: number;
  22853. tessellation?: number;
  22854. subdivisions?: number;
  22855. arc?: number;
  22856. faceColors?: Color4[];
  22857. faceUV?: Vector4[];
  22858. hasRings?: boolean;
  22859. enclose?: boolean;
  22860. sideOrientation?: number;
  22861. frontUVs?: Vector4;
  22862. backUVs?: Vector4;
  22863. }): VertexData;
  22864. /**
  22865. * Creates the VertexData for a torus
  22866. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22867. * * diameter the diameter of the torus, optional default 1
  22868. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22869. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22870. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22871. * * 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)
  22872. * * 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)
  22873. * @returns the VertexData of the torus
  22874. */
  22875. static CreateTorus(options: {
  22876. diameter?: number;
  22877. thickness?: number;
  22878. tessellation?: number;
  22879. sideOrientation?: number;
  22880. frontUVs?: Vector4;
  22881. backUVs?: Vector4;
  22882. }): VertexData;
  22883. /**
  22884. * Creates the VertexData of the LineSystem
  22885. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22886. * - lines an array of lines, each line being an array of successive Vector3
  22887. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22888. * @returns the VertexData of the LineSystem
  22889. */
  22890. static CreateLineSystem(options: {
  22891. lines: Vector3[][];
  22892. colors?: Nullable<Color4[][]>;
  22893. }): VertexData;
  22894. /**
  22895. * Create the VertexData for a DashedLines
  22896. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22897. * - points an array successive Vector3
  22898. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22899. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22900. * - dashNb the intended total number of dashes, optional, default 200
  22901. * @returns the VertexData for the DashedLines
  22902. */
  22903. static CreateDashedLines(options: {
  22904. points: Vector3[];
  22905. dashSize?: number;
  22906. gapSize?: number;
  22907. dashNb?: number;
  22908. }): VertexData;
  22909. /**
  22910. * Creates the VertexData for a Ground
  22911. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22912. * - width the width (x direction) of the ground, optional, default 1
  22913. * - height the height (z direction) of the ground, optional, default 1
  22914. * - subdivisions the number of subdivisions per side, optional, default 1
  22915. * @returns the VertexData of the Ground
  22916. */
  22917. static CreateGround(options: {
  22918. width?: number;
  22919. height?: number;
  22920. subdivisions?: number;
  22921. subdivisionsX?: number;
  22922. subdivisionsY?: number;
  22923. }): VertexData;
  22924. /**
  22925. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22926. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22927. * * xmin the ground minimum X coordinate, optional, default -1
  22928. * * zmin the ground minimum Z coordinate, optional, default -1
  22929. * * xmax the ground maximum X coordinate, optional, default 1
  22930. * * zmax the ground maximum Z coordinate, optional, default 1
  22931. * * 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}
  22932. * * 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}
  22933. * @returns the VertexData of the TiledGround
  22934. */
  22935. static CreateTiledGround(options: {
  22936. xmin: number;
  22937. zmin: number;
  22938. xmax: number;
  22939. zmax: number;
  22940. subdivisions?: {
  22941. w: number;
  22942. h: number;
  22943. };
  22944. precision?: {
  22945. w: number;
  22946. h: number;
  22947. };
  22948. }): VertexData;
  22949. /**
  22950. * Creates the VertexData of the Ground designed from a heightmap
  22951. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22952. * * width the width (x direction) of the ground
  22953. * * height the height (z direction) of the ground
  22954. * * subdivisions the number of subdivisions per side
  22955. * * minHeight the minimum altitude on the ground, optional, default 0
  22956. * * maxHeight the maximum altitude on the ground, optional default 1
  22957. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22958. * * buffer the array holding the image color data
  22959. * * bufferWidth the width of image
  22960. * * bufferHeight the height of image
  22961. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22962. * @returns the VertexData of the Ground designed from a heightmap
  22963. */
  22964. static CreateGroundFromHeightMap(options: {
  22965. width: number;
  22966. height: number;
  22967. subdivisions: number;
  22968. minHeight: number;
  22969. maxHeight: number;
  22970. colorFilter: Color3;
  22971. buffer: Uint8Array;
  22972. bufferWidth: number;
  22973. bufferHeight: number;
  22974. alphaFilter: number;
  22975. }): VertexData;
  22976. /**
  22977. * Creates the VertexData for a Plane
  22978. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22979. * * size sets the width and height of the plane to the value of size, optional default 1
  22980. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22981. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22982. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22983. * * 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)
  22984. * * 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)
  22985. * @returns the VertexData of the box
  22986. */
  22987. static CreatePlane(options: {
  22988. size?: number;
  22989. width?: number;
  22990. height?: number;
  22991. sideOrientation?: number;
  22992. frontUVs?: Vector4;
  22993. backUVs?: Vector4;
  22994. }): VertexData;
  22995. /**
  22996. * Creates the VertexData of the Disc or regular Polygon
  22997. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22998. * * radius the radius of the disc, optional default 0.5
  22999. * * tessellation the number of polygon sides, optional, default 64
  23000. * * 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
  23001. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23002. * * 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)
  23003. * * 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)
  23004. * @returns the VertexData of the box
  23005. */
  23006. static CreateDisc(options: {
  23007. radius?: number;
  23008. tessellation?: number;
  23009. arc?: number;
  23010. sideOrientation?: number;
  23011. frontUVs?: Vector4;
  23012. backUVs?: Vector4;
  23013. }): VertexData;
  23014. /**
  23015. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23016. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23017. * @param polygon a mesh built from polygonTriangulation.build()
  23018. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23019. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23020. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23021. * @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)
  23022. * @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)
  23023. * @returns the VertexData of the Polygon
  23024. */
  23025. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23026. /**
  23027. * Creates the VertexData of the IcoSphere
  23028. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23029. * * radius the radius of the IcoSphere, optional default 1
  23030. * * radiusX allows stretching in the x direction, optional, default radius
  23031. * * radiusY allows stretching in the y direction, optional, default radius
  23032. * * radiusZ allows stretching in the z direction, optional, default radius
  23033. * * flat when true creates a flat shaded mesh, optional, default true
  23034. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  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 IcoSphere
  23039. */
  23040. static CreateIcoSphere(options: {
  23041. radius?: number;
  23042. radiusX?: number;
  23043. radiusY?: number;
  23044. radiusZ?: number;
  23045. flat?: boolean;
  23046. subdivisions?: number;
  23047. sideOrientation?: number;
  23048. frontUVs?: Vector4;
  23049. backUVs?: Vector4;
  23050. }): VertexData;
  23051. /**
  23052. * Creates the VertexData for a Polyhedron
  23053. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23054. * * type provided types are:
  23055. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23056. * * 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)
  23057. * * size the size of the IcoSphere, optional default 1
  23058. * * sizeX allows stretching in the x direction, optional, default size
  23059. * * sizeY allows stretching in the y direction, optional, default size
  23060. * * sizeZ allows stretching in the z direction, optional, default size
  23061. * * 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
  23062. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23063. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23064. * * flat when true creates a flat shaded mesh, optional, default true
  23065. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23066. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23067. * * 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)
  23068. * * 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)
  23069. * @returns the VertexData of the Polyhedron
  23070. */
  23071. static CreatePolyhedron(options: {
  23072. type?: number;
  23073. size?: number;
  23074. sizeX?: number;
  23075. sizeY?: number;
  23076. sizeZ?: number;
  23077. custom?: any;
  23078. faceUV?: Vector4[];
  23079. faceColors?: Color4[];
  23080. flat?: boolean;
  23081. sideOrientation?: number;
  23082. frontUVs?: Vector4;
  23083. backUVs?: Vector4;
  23084. }): VertexData;
  23085. /**
  23086. * Creates the VertexData for a TorusKnot
  23087. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23088. * * radius the radius of the torus knot, optional, default 2
  23089. * * tube the thickness of the tube, optional, default 0.5
  23090. * * radialSegments the number of sides on each tube segments, optional, default 32
  23091. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23092. * * p the number of windings around the z axis, optional, default 2
  23093. * * q the number of windings around the x axis, optional, default 3
  23094. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23095. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23096. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23097. * @returns the VertexData of the Torus Knot
  23098. */
  23099. static CreateTorusKnot(options: {
  23100. radius?: number;
  23101. tube?: number;
  23102. radialSegments?: number;
  23103. tubularSegments?: number;
  23104. p?: number;
  23105. q?: number;
  23106. sideOrientation?: number;
  23107. frontUVs?: Vector4;
  23108. backUVs?: Vector4;
  23109. }): VertexData;
  23110. /**
  23111. * Compute normals for given positions and indices
  23112. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23113. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23114. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23115. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23116. * * facetNormals : optional array of facet normals (vector3)
  23117. * * facetPositions : optional array of facet positions (vector3)
  23118. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23119. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23120. * * bInfo : optional bounding info, required for facetPartitioning computation
  23121. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23122. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23123. * * useRightHandedSystem: optional boolean to for right handed system computation
  23124. * * depthSort : optional boolean to enable the facet depth sort computation
  23125. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23126. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23127. */
  23128. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23129. facetNormals?: any;
  23130. facetPositions?: any;
  23131. facetPartitioning?: any;
  23132. ratio?: number;
  23133. bInfo?: any;
  23134. bbSize?: Vector3;
  23135. subDiv?: any;
  23136. useRightHandedSystem?: boolean;
  23137. depthSort?: boolean;
  23138. distanceTo?: Vector3;
  23139. depthSortedFacets?: any;
  23140. }): void;
  23141. /** @hidden */
  23142. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23143. /**
  23144. * Applies VertexData created from the imported parameters to the geometry
  23145. * @param parsedVertexData the parsed data from an imported file
  23146. * @param geometry the geometry to apply the VertexData to
  23147. */
  23148. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23149. }
  23150. }
  23151. declare module "babylonjs/Meshes/Builders/discBuilder" {
  23152. import { Nullable } from "babylonjs/types";
  23153. import { Scene } from "babylonjs/scene";
  23154. import { Vector4 } from "babylonjs/Maths/math";
  23155. import { Mesh } from "babylonjs/Meshes/mesh";
  23156. /**
  23157. * Class containing static functions to help procedurally build meshes
  23158. */
  23159. export class DiscBuilder {
  23160. /**
  23161. * Creates a plane polygonal mesh. By default, this is a disc
  23162. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23163. * * 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
  23164. * * 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
  23165. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23166. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23167. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23168. * @param name defines the name of the mesh
  23169. * @param options defines the options used to create the mesh
  23170. * @param scene defines the hosting scene
  23171. * @returns the plane polygonal mesh
  23172. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23173. */
  23174. static CreateDisc(name: string, options: {
  23175. radius?: number;
  23176. tessellation?: number;
  23177. arc?: number;
  23178. updatable?: boolean;
  23179. sideOrientation?: number;
  23180. frontUVs?: Vector4;
  23181. backUVs?: Vector4;
  23182. }, scene?: Nullable<Scene>): Mesh;
  23183. }
  23184. }
  23185. declare module "babylonjs/Particles/solidParticleSystem" {
  23186. import { Vector3 } from "babylonjs/Maths/math";
  23187. import { Mesh } from "babylonjs/Meshes/mesh";
  23188. import { Scene, IDisposable } from "babylonjs/scene";
  23189. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  23190. /**
  23191. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23192. *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.
  23193. * The SPS is also a particle system. It provides some methods to manage the particles.
  23194. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23195. *
  23196. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23197. */
  23198. export class SolidParticleSystem implements IDisposable {
  23199. /**
  23200. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23201. * Example : var p = SPS.particles[i];
  23202. */
  23203. particles: SolidParticle[];
  23204. /**
  23205. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23206. */
  23207. nbParticles: number;
  23208. /**
  23209. * If the particles must ever face the camera (default false). Useful for planar particles.
  23210. */
  23211. billboard: boolean;
  23212. /**
  23213. * Recompute normals when adding a shape
  23214. */
  23215. recomputeNormals: boolean;
  23216. /**
  23217. * This a counter ofr your own usage. It's not set by any SPS functions.
  23218. */
  23219. counter: number;
  23220. /**
  23221. * The SPS name. This name is also given to the underlying mesh.
  23222. */
  23223. name: string;
  23224. /**
  23225. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23226. */
  23227. mesh: Mesh;
  23228. /**
  23229. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23230. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23231. */
  23232. vars: any;
  23233. /**
  23234. * This array is populated when the SPS is set as 'pickable'.
  23235. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23236. * Each element of this array is an object `{idx: int, faceId: int}`.
  23237. * `idx` is the picked particle index in the `SPS.particles` array
  23238. * `faceId` is the picked face index counted within this particle.
  23239. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23240. */
  23241. pickedParticles: {
  23242. idx: number;
  23243. faceId: number;
  23244. }[];
  23245. /**
  23246. * This array is populated when `enableDepthSort` is set to true.
  23247. * Each element of this array is an instance of the class DepthSortedParticle.
  23248. */
  23249. depthSortedParticles: DepthSortedParticle[];
  23250. /**
  23251. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23252. * @hidden
  23253. */
  23254. _bSphereOnly: boolean;
  23255. /**
  23256. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23257. * @hidden
  23258. */
  23259. _bSphereRadiusFactor: number;
  23260. private _scene;
  23261. private _positions;
  23262. private _indices;
  23263. private _normals;
  23264. private _colors;
  23265. private _uvs;
  23266. private _indices32;
  23267. private _positions32;
  23268. private _normals32;
  23269. private _fixedNormal32;
  23270. private _colors32;
  23271. private _uvs32;
  23272. private _index;
  23273. private _updatable;
  23274. private _pickable;
  23275. private _isVisibilityBoxLocked;
  23276. private _alwaysVisible;
  23277. private _depthSort;
  23278. private _shapeCounter;
  23279. private _copy;
  23280. private _color;
  23281. private _computeParticleColor;
  23282. private _computeParticleTexture;
  23283. private _computeParticleRotation;
  23284. private _computeParticleVertex;
  23285. private _computeBoundingBox;
  23286. private _depthSortParticles;
  23287. private _camera;
  23288. private _mustUnrotateFixedNormals;
  23289. private _particlesIntersect;
  23290. private _needs32Bits;
  23291. /**
  23292. * Creates a SPS (Solid Particle System) object.
  23293. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23294. * @param scene (Scene) is the scene in which the SPS is added.
  23295. * @param options defines the options of the sps e.g.
  23296. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23297. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23298. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23299. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23300. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23301. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23302. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23303. */
  23304. constructor(name: string, scene: Scene, options?: {
  23305. updatable?: boolean;
  23306. isPickable?: boolean;
  23307. enableDepthSort?: boolean;
  23308. particleIntersection?: boolean;
  23309. boundingSphereOnly?: boolean;
  23310. bSphereRadiusFactor?: number;
  23311. });
  23312. /**
  23313. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23314. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23315. * @returns the created mesh
  23316. */
  23317. buildMesh(): Mesh;
  23318. /**
  23319. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23320. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23321. * Thus the particles generated from `digest()` have their property `position` set yet.
  23322. * @param mesh ( Mesh ) is the mesh to be digested
  23323. * @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
  23324. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23325. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23326. * @returns the current SPS
  23327. */
  23328. digest(mesh: Mesh, options?: {
  23329. facetNb?: number;
  23330. number?: number;
  23331. delta?: number;
  23332. }): SolidParticleSystem;
  23333. private _unrotateFixedNormals;
  23334. private _resetCopy;
  23335. private _meshBuilder;
  23336. private _posToShape;
  23337. private _uvsToShapeUV;
  23338. private _addParticle;
  23339. /**
  23340. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23341. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23342. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23343. * @param nb (positive integer) the number of particles to be created from this model
  23344. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23345. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23346. * @returns the number of shapes in the system
  23347. */
  23348. addShape(mesh: Mesh, nb: number, options?: {
  23349. positionFunction?: any;
  23350. vertexFunction?: any;
  23351. }): number;
  23352. private _rebuildParticle;
  23353. /**
  23354. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23355. * @returns the SPS.
  23356. */
  23357. rebuildMesh(): SolidParticleSystem;
  23358. /**
  23359. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23360. * This method calls `updateParticle()` for each particle of the SPS.
  23361. * For an animated SPS, it is usually called within the render loop.
  23362. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23363. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23364. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23365. * @returns the SPS.
  23366. */
  23367. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23368. /**
  23369. * Disposes the SPS.
  23370. */
  23371. dispose(): void;
  23372. /**
  23373. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23374. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23375. * @returns the SPS.
  23376. */
  23377. refreshVisibleSize(): SolidParticleSystem;
  23378. /**
  23379. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23380. * @param size the size (float) of the visibility box
  23381. * note : this doesn't lock the SPS mesh bounding box.
  23382. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23383. */
  23384. setVisibilityBox(size: number): void;
  23385. /**
  23386. * Gets whether the SPS as always visible or not
  23387. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23388. */
  23389. /**
  23390. * Sets the SPS as always visible or not
  23391. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23392. */
  23393. isAlwaysVisible: boolean;
  23394. /**
  23395. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23396. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23397. */
  23398. /**
  23399. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23400. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23401. */
  23402. isVisibilityBoxLocked: boolean;
  23403. /**
  23404. * Tells to `setParticles()` to compute the particle rotations or not.
  23405. * Default value : true. The SPS is faster when it's set to false.
  23406. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23407. */
  23408. /**
  23409. * Gets if `setParticles()` computes the particle rotations or not.
  23410. * Default value : true. The SPS is faster when it's set to false.
  23411. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23412. */
  23413. computeParticleRotation: boolean;
  23414. /**
  23415. * Tells to `setParticles()` to compute the particle colors or not.
  23416. * Default value : true. The SPS is faster when it's set to false.
  23417. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23418. */
  23419. /**
  23420. * Gets if `setParticles()` computes the particle colors or not.
  23421. * Default value : true. The SPS is faster when it's set to false.
  23422. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23423. */
  23424. computeParticleColor: boolean;
  23425. /**
  23426. * Gets if `setParticles()` computes the particle textures or not.
  23427. * Default value : true. The SPS is faster when it's set to false.
  23428. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23429. */
  23430. computeParticleTexture: boolean;
  23431. /**
  23432. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23433. * Default value : false. The SPS is faster when it's set to false.
  23434. * Note : the particle custom vertex positions aren't stored values.
  23435. */
  23436. /**
  23437. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23438. * Default value : false. The SPS is faster when it's set to false.
  23439. * Note : the particle custom vertex positions aren't stored values.
  23440. */
  23441. computeParticleVertex: boolean;
  23442. /**
  23443. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23444. */
  23445. /**
  23446. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23447. */
  23448. computeBoundingBox: boolean;
  23449. /**
  23450. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23451. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23452. * Default : `true`
  23453. */
  23454. /**
  23455. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23456. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23457. * Default : `true`
  23458. */
  23459. depthSortParticles: boolean;
  23460. /**
  23461. * This function does nothing. It may be overwritten to set all the particle first values.
  23462. * The SPS doesn't call this function, you may have to call it by your own.
  23463. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23464. */
  23465. initParticles(): void;
  23466. /**
  23467. * This function does nothing. It may be overwritten to recycle a particle.
  23468. * The SPS doesn't call this function, you may have to call it by your own.
  23469. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23470. * @param particle The particle to recycle
  23471. * @returns the recycled particle
  23472. */
  23473. recycleParticle(particle: SolidParticle): SolidParticle;
  23474. /**
  23475. * Updates a particle : this function should be overwritten by the user.
  23476. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23477. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23478. * @example : just set a particle position or velocity and recycle conditions
  23479. * @param particle The particle to update
  23480. * @returns the updated particle
  23481. */
  23482. updateParticle(particle: SolidParticle): SolidParticle;
  23483. /**
  23484. * Updates a vertex of a particle : it can be overwritten by the user.
  23485. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23486. * @param particle the current particle
  23487. * @param vertex the current index of the current particle
  23488. * @param pt the index of the current vertex in the particle shape
  23489. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23490. * @example : just set a vertex particle position
  23491. * @returns the updated vertex
  23492. */
  23493. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23494. /**
  23495. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23496. * This does nothing and may be overwritten by the user.
  23497. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23498. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23499. * @param update the boolean update value actually passed to setParticles()
  23500. */
  23501. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23502. /**
  23503. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23504. * This will be passed three parameters.
  23505. * This does nothing and may be overwritten by the user.
  23506. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23507. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23508. * @param update the boolean update value actually passed to setParticles()
  23509. */
  23510. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23511. }
  23512. }
  23513. declare module "babylonjs/Particles/solidParticle" {
  23514. import { Nullable } from "babylonjs/types";
  23515. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  23516. import { Mesh } from "babylonjs/Meshes/mesh";
  23517. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23518. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  23519. /**
  23520. * Represents one particle of a solid particle system.
  23521. */
  23522. export class SolidParticle {
  23523. /**
  23524. * particle global index
  23525. */
  23526. idx: number;
  23527. /**
  23528. * The color of the particle
  23529. */
  23530. color: Nullable<Color4>;
  23531. /**
  23532. * The world space position of the particle.
  23533. */
  23534. position: Vector3;
  23535. /**
  23536. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  23537. */
  23538. rotation: Vector3;
  23539. /**
  23540. * The world space rotation quaternion of the particle.
  23541. */
  23542. rotationQuaternion: Nullable<Quaternion>;
  23543. /**
  23544. * The scaling of the particle.
  23545. */
  23546. scaling: Vector3;
  23547. /**
  23548. * The uvs of the particle.
  23549. */
  23550. uvs: Vector4;
  23551. /**
  23552. * The current speed of the particle.
  23553. */
  23554. velocity: Vector3;
  23555. /**
  23556. * The pivot point in the particle local space.
  23557. */
  23558. pivot: Vector3;
  23559. /**
  23560. * Must the particle be translated from its pivot point in its local space ?
  23561. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  23562. * Default : false
  23563. */
  23564. translateFromPivot: boolean;
  23565. /**
  23566. * Is the particle active or not ?
  23567. */
  23568. alive: boolean;
  23569. /**
  23570. * Is the particle visible or not ?
  23571. */
  23572. isVisible: boolean;
  23573. /**
  23574. * Index of this particle in the global "positions" array (Internal use)
  23575. * @hidden
  23576. */
  23577. _pos: number;
  23578. /**
  23579. * @hidden Index of this particle in the global "indices" array (Internal use)
  23580. */
  23581. _ind: number;
  23582. /**
  23583. * @hidden ModelShape of this particle (Internal use)
  23584. */
  23585. _model: ModelShape;
  23586. /**
  23587. * ModelShape id of this particle
  23588. */
  23589. shapeId: number;
  23590. /**
  23591. * Index of the particle in its shape id (Internal use)
  23592. */
  23593. idxInShape: number;
  23594. /**
  23595. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  23596. */
  23597. _modelBoundingInfo: BoundingInfo;
  23598. /**
  23599. * @hidden Particle BoundingInfo object (Internal use)
  23600. */
  23601. _boundingInfo: BoundingInfo;
  23602. /**
  23603. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  23604. */
  23605. _sps: SolidParticleSystem;
  23606. /**
  23607. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  23608. */
  23609. _stillInvisible: boolean;
  23610. /**
  23611. * @hidden Last computed particle rotation matrix
  23612. */
  23613. _rotationMatrix: number[];
  23614. /**
  23615. * Parent particle Id, if any.
  23616. * Default null.
  23617. */
  23618. parentId: Nullable<number>;
  23619. /**
  23620. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  23621. * The possible values are :
  23622. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23623. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23624. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23625. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23626. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23627. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  23628. * */
  23629. cullingStrategy: number;
  23630. /**
  23631. * @hidden Internal global position in the SPS.
  23632. */
  23633. _globalPosition: Vector3;
  23634. /**
  23635. * Creates a Solid Particle object.
  23636. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  23637. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  23638. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  23639. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  23640. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  23641. * @param shapeId (integer) is the model shape identifier in the SPS.
  23642. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  23643. * @param sps defines the sps it is associated to
  23644. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  23645. */
  23646. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  23647. /**
  23648. * Legacy support, changed scale to scaling
  23649. */
  23650. /**
  23651. * Legacy support, changed scale to scaling
  23652. */
  23653. scale: Vector3;
  23654. /**
  23655. * Legacy support, changed quaternion to rotationQuaternion
  23656. */
  23657. /**
  23658. * Legacy support, changed quaternion to rotationQuaternion
  23659. */
  23660. quaternion: Nullable<Quaternion>;
  23661. /**
  23662. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  23663. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  23664. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  23665. * @returns true if it intersects
  23666. */
  23667. intersectsMesh(target: Mesh | SolidParticle): boolean;
  23668. /**
  23669. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  23670. * A particle is in the frustum if its bounding box intersects the frustum
  23671. * @param frustumPlanes defines the frustum to test
  23672. * @returns true if the particle is in the frustum planes
  23673. */
  23674. isInFrustum(frustumPlanes: Plane[]): boolean;
  23675. /**
  23676. * get the rotation matrix of the particle
  23677. * @hidden
  23678. */
  23679. getRotationMatrix(m: Matrix): void;
  23680. }
  23681. /**
  23682. * Represents the shape of the model used by one particle of a solid particle system.
  23683. * SPS internal tool, don't use it manually.
  23684. */
  23685. export class ModelShape {
  23686. /**
  23687. * The shape id
  23688. * @hidden
  23689. */
  23690. shapeID: number;
  23691. /**
  23692. * flat array of model positions (internal use)
  23693. * @hidden
  23694. */
  23695. _shape: Vector3[];
  23696. /**
  23697. * flat array of model UVs (internal use)
  23698. * @hidden
  23699. */
  23700. _shapeUV: number[];
  23701. /**
  23702. * length of the shape in the model indices array (internal use)
  23703. * @hidden
  23704. */
  23705. _indicesLength: number;
  23706. /**
  23707. * Custom position function (internal use)
  23708. * @hidden
  23709. */
  23710. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  23711. /**
  23712. * Custom vertex function (internal use)
  23713. * @hidden
  23714. */
  23715. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  23716. /**
  23717. * 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.
  23718. * SPS internal tool, don't use it manually.
  23719. * @hidden
  23720. */
  23721. 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>);
  23722. }
  23723. /**
  23724. * Represents a Depth Sorted Particle in the solid particle system.
  23725. */
  23726. export class DepthSortedParticle {
  23727. /**
  23728. * Index of the particle in the "indices" array
  23729. */
  23730. ind: number;
  23731. /**
  23732. * Length of the particle shape in the "indices" array
  23733. */
  23734. indicesLength: number;
  23735. /**
  23736. * Squared distance from the particle to the camera
  23737. */
  23738. sqDistance: number;
  23739. }
  23740. }
  23741. declare module "babylonjs/Meshes/abstractMesh" {
  23742. import { Observable } from "babylonjs/Misc/observable";
  23743. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  23744. import { Camera } from "babylonjs/Cameras/camera";
  23745. import { Scene, IDisposable } from "babylonjs/scene";
  23746. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  23747. import { Node } from "babylonjs/node";
  23748. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  23749. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23750. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23751. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  23752. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23753. import { Material } from "babylonjs/Materials/material";
  23754. import { Light } from "babylonjs/Lights/light";
  23755. import { Skeleton } from "babylonjs/Bones/skeleton";
  23756. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  23757. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  23758. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  23759. import { Ray } from "babylonjs/Culling/ray";
  23760. import { Collider } from "babylonjs/Collisions/collider";
  23761. /**
  23762. * Class used to store all common mesh properties
  23763. */
  23764. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  23765. /** No occlusion */
  23766. static OCCLUSION_TYPE_NONE: number;
  23767. /** Occlusion set to optimisitic */
  23768. static OCCLUSION_TYPE_OPTIMISTIC: number;
  23769. /** Occlusion set to strict */
  23770. static OCCLUSION_TYPE_STRICT: number;
  23771. /** Use an accurante occlusion algorithm */
  23772. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  23773. /** Use a conservative occlusion algorithm */
  23774. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  23775. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  23776. * Test order :
  23777. * Is the bounding sphere outside the frustum ?
  23778. * If not, are the bounding box vertices outside the frustum ?
  23779. * It not, then the cullable object is in the frustum.
  23780. */
  23781. static readonly CULLINGSTRATEGY_STANDARD: number;
  23782. /** Culling strategy : Bounding Sphere Only.
  23783. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  23784. * It's also less accurate than the standard because some not visible objects can still be selected.
  23785. * Test : is the bounding sphere outside the frustum ?
  23786. * If not, then the cullable object is in the frustum.
  23787. */
  23788. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  23789. /** Culling strategy : Optimistic Inclusion.
  23790. * This in an inclusion test first, then the standard exclusion test.
  23791. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  23792. * 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.
  23793. * Anyway, it's as accurate as the standard strategy.
  23794. * Test :
  23795. * Is the cullable object bounding sphere center in the frustum ?
  23796. * If not, apply the default culling strategy.
  23797. */
  23798. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  23799. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  23800. * This in an inclusion test first, then the bounding sphere only exclusion test.
  23801. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  23802. * 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.
  23803. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  23804. * Test :
  23805. * Is the cullable object bounding sphere center in the frustum ?
  23806. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  23807. */
  23808. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  23809. /**
  23810. * No billboard
  23811. */
  23812. static readonly BILLBOARDMODE_NONE: number;
  23813. /** Billboard on X axis */
  23814. static readonly BILLBOARDMODE_X: number;
  23815. /** Billboard on Y axis */
  23816. static readonly BILLBOARDMODE_Y: number;
  23817. /** Billboard on Z axis */
  23818. static readonly BILLBOARDMODE_Z: number;
  23819. /** Billboard on all axes */
  23820. static readonly BILLBOARDMODE_ALL: number;
  23821. private _facetData;
  23822. /**
  23823. * The culling strategy to use to check whether the mesh must be rendered or not.
  23824. * This value can be changed at any time and will be used on the next render mesh selection.
  23825. * The possible values are :
  23826. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23827. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23828. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23829. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23830. * Please read each static variable documentation to get details about the culling process.
  23831. * */
  23832. cullingStrategy: number;
  23833. /**
  23834. * Gets the number of facets in the mesh
  23835. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23836. */
  23837. readonly facetNb: number;
  23838. /**
  23839. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  23840. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23841. */
  23842. partitioningSubdivisions: number;
  23843. /**
  23844. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  23845. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  23846. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23847. */
  23848. partitioningBBoxRatio: number;
  23849. /**
  23850. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  23851. * Works only for updatable meshes.
  23852. * Doesn't work with multi-materials
  23853. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23854. */
  23855. mustDepthSortFacets: boolean;
  23856. /**
  23857. * The location (Vector3) where the facet depth sort must be computed from.
  23858. * By default, the active camera position.
  23859. * Used only when facet depth sort is enabled
  23860. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23861. */
  23862. facetDepthSortFrom: Vector3;
  23863. /**
  23864. * gets a boolean indicating if facetData is enabled
  23865. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23866. */
  23867. readonly isFacetDataEnabled: boolean;
  23868. /** @hidden */
  23869. _updateNonUniformScalingState(value: boolean): boolean;
  23870. /**
  23871. * An event triggered when this mesh collides with another one
  23872. */
  23873. onCollideObservable: Observable<AbstractMesh>;
  23874. private _onCollideObserver;
  23875. /** Set a function to call when this mesh collides with another one */
  23876. onCollide: () => void;
  23877. /**
  23878. * An event triggered when the collision's position changes
  23879. */
  23880. onCollisionPositionChangeObservable: Observable<Vector3>;
  23881. private _onCollisionPositionChangeObserver;
  23882. /** Set a function to call when the collision's position changes */
  23883. onCollisionPositionChange: () => void;
  23884. /**
  23885. * An event triggered when material is changed
  23886. */
  23887. onMaterialChangedObservable: Observable<AbstractMesh>;
  23888. /**
  23889. * Gets or sets the orientation for POV movement & rotation
  23890. */
  23891. definedFacingForward: boolean;
  23892. /** @hidden */
  23893. _occlusionQuery: Nullable<WebGLQuery>;
  23894. private _visibility;
  23895. /**
  23896. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23897. */
  23898. /**
  23899. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23900. */
  23901. visibility: number;
  23902. /** Gets or sets the alpha index used to sort transparent meshes
  23903. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  23904. */
  23905. alphaIndex: number;
  23906. /**
  23907. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  23908. */
  23909. isVisible: boolean;
  23910. /**
  23911. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  23912. */
  23913. isPickable: boolean;
  23914. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  23915. showSubMeshesBoundingBox: boolean;
  23916. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  23917. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  23918. */
  23919. isBlocker: boolean;
  23920. /**
  23921. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  23922. */
  23923. enablePointerMoveEvents: boolean;
  23924. /**
  23925. * Specifies the rendering group id for this mesh (0 by default)
  23926. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  23927. */
  23928. renderingGroupId: number;
  23929. private _material;
  23930. /** Gets or sets current material */
  23931. material: Nullable<Material>;
  23932. private _receiveShadows;
  23933. /**
  23934. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  23935. * @see http://doc.babylonjs.com/babylon101/shadows
  23936. */
  23937. receiveShadows: boolean;
  23938. /** Defines color to use when rendering outline */
  23939. outlineColor: Color3;
  23940. /** Define width to use when rendering outline */
  23941. outlineWidth: number;
  23942. /** Defines color to use when rendering overlay */
  23943. overlayColor: Color3;
  23944. /** Defines alpha to use when rendering overlay */
  23945. overlayAlpha: number;
  23946. private _hasVertexAlpha;
  23947. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  23948. hasVertexAlpha: boolean;
  23949. private _useVertexColors;
  23950. /** 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) */
  23951. useVertexColors: boolean;
  23952. private _computeBonesUsingShaders;
  23953. /**
  23954. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  23955. */
  23956. computeBonesUsingShaders: boolean;
  23957. private _numBoneInfluencers;
  23958. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  23959. numBoneInfluencers: number;
  23960. private _applyFog;
  23961. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  23962. applyFog: boolean;
  23963. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  23964. useOctreeForRenderingSelection: boolean;
  23965. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  23966. useOctreeForPicking: boolean;
  23967. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  23968. useOctreeForCollisions: boolean;
  23969. private _layerMask;
  23970. /**
  23971. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  23972. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  23973. */
  23974. layerMask: number;
  23975. /**
  23976. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  23977. */
  23978. alwaysSelectAsActiveMesh: boolean;
  23979. /**
  23980. * Gets or sets the current action manager
  23981. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  23982. */
  23983. actionManager: Nullable<AbstractActionManager>;
  23984. private _checkCollisions;
  23985. private _collisionMask;
  23986. private _collisionGroup;
  23987. /**
  23988. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  23989. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23990. */
  23991. ellipsoid: Vector3;
  23992. /**
  23993. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  23994. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23995. */
  23996. ellipsoidOffset: Vector3;
  23997. private _collider;
  23998. private _oldPositionForCollisions;
  23999. private _diffPositionForCollisions;
  24000. /**
  24001. * Gets or sets a collision mask used to mask collisions (default is -1).
  24002. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24003. */
  24004. collisionMask: number;
  24005. /**
  24006. * Gets or sets the current collision group mask (-1 by default).
  24007. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24008. */
  24009. collisionGroup: number;
  24010. /**
  24011. * Defines edge width used when edgesRenderer is enabled
  24012. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24013. */
  24014. edgesWidth: number;
  24015. /**
  24016. * Defines edge color used when edgesRenderer is enabled
  24017. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24018. */
  24019. edgesColor: Color4;
  24020. /** @hidden */
  24021. _edgesRenderer: Nullable<IEdgesRenderer>;
  24022. /** @hidden */
  24023. _masterMesh: Nullable<AbstractMesh>;
  24024. /** @hidden */
  24025. _boundingInfo: Nullable<BoundingInfo>;
  24026. /** @hidden */
  24027. _renderId: number;
  24028. /**
  24029. * Gets or sets the list of subMeshes
  24030. * @see http://doc.babylonjs.com/how_to/multi_materials
  24031. */
  24032. subMeshes: SubMesh[];
  24033. /** @hidden */
  24034. _intersectionsInProgress: AbstractMesh[];
  24035. /** @hidden */
  24036. _unIndexed: boolean;
  24037. /** @hidden */
  24038. _lightSources: Light[];
  24039. /** @hidden */
  24040. readonly _positions: Nullable<Vector3[]>;
  24041. /** @hidden */
  24042. _waitingActions: any;
  24043. /** @hidden */
  24044. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24045. private _skeleton;
  24046. /** @hidden */
  24047. _bonesTransformMatrices: Nullable<Float32Array>;
  24048. /**
  24049. * Gets or sets a skeleton to apply skining transformations
  24050. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24051. */
  24052. skeleton: Nullable<Skeleton>;
  24053. /**
  24054. * An event triggered when the mesh is rebuilt.
  24055. */
  24056. onRebuildObservable: Observable<AbstractMesh>;
  24057. /**
  24058. * Creates a new AbstractMesh
  24059. * @param name defines the name of the mesh
  24060. * @param scene defines the hosting scene
  24061. */
  24062. constructor(name: string, scene?: Nullable<Scene>);
  24063. /**
  24064. * Returns the string "AbstractMesh"
  24065. * @returns "AbstractMesh"
  24066. */
  24067. getClassName(): string;
  24068. /**
  24069. * Gets a string representation of the current mesh
  24070. * @param fullDetails defines a boolean indicating if full details must be included
  24071. * @returns a string representation of the current mesh
  24072. */
  24073. toString(fullDetails?: boolean): string;
  24074. /** @hidden */
  24075. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24076. /** @hidden */
  24077. _rebuild(): void;
  24078. /** @hidden */
  24079. _resyncLightSources(): void;
  24080. /** @hidden */
  24081. _resyncLighSource(light: Light): void;
  24082. /** @hidden */
  24083. _unBindEffect(): void;
  24084. /** @hidden */
  24085. _removeLightSource(light: Light): void;
  24086. private _markSubMeshesAsDirty;
  24087. /** @hidden */
  24088. _markSubMeshesAsLightDirty(): void;
  24089. /** @hidden */
  24090. _markSubMeshesAsAttributesDirty(): void;
  24091. /** @hidden */
  24092. _markSubMeshesAsMiscDirty(): void;
  24093. /**
  24094. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24095. */
  24096. scaling: Vector3;
  24097. /**
  24098. * Returns true if the mesh is blocked. Implemented by child classes
  24099. */
  24100. readonly isBlocked: boolean;
  24101. /**
  24102. * Returns the mesh itself by default. Implemented by child classes
  24103. * @param camera defines the camera to use to pick the right LOD level
  24104. * @returns the currentAbstractMesh
  24105. */
  24106. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24107. /**
  24108. * Returns 0 by default. Implemented by child classes
  24109. * @returns an integer
  24110. */
  24111. getTotalVertices(): number;
  24112. /**
  24113. * Returns a positive integer : the total number of indices in this mesh geometry.
  24114. * @returns the numner of indices or zero if the mesh has no geometry.
  24115. */
  24116. getTotalIndices(): number;
  24117. /**
  24118. * Returns null by default. Implemented by child classes
  24119. * @returns null
  24120. */
  24121. getIndices(): Nullable<IndicesArray>;
  24122. /**
  24123. * Returns the array of the requested vertex data kind. Implemented by child classes
  24124. * @param kind defines the vertex data kind to use
  24125. * @returns null
  24126. */
  24127. getVerticesData(kind: string): Nullable<FloatArray>;
  24128. /**
  24129. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24130. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24131. * Note that a new underlying VertexBuffer object is created each call.
  24132. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24133. * @param kind defines vertex data kind:
  24134. * * VertexBuffer.PositionKind
  24135. * * VertexBuffer.UVKind
  24136. * * VertexBuffer.UV2Kind
  24137. * * VertexBuffer.UV3Kind
  24138. * * VertexBuffer.UV4Kind
  24139. * * VertexBuffer.UV5Kind
  24140. * * VertexBuffer.UV6Kind
  24141. * * VertexBuffer.ColorKind
  24142. * * VertexBuffer.MatricesIndicesKind
  24143. * * VertexBuffer.MatricesIndicesExtraKind
  24144. * * VertexBuffer.MatricesWeightsKind
  24145. * * VertexBuffer.MatricesWeightsExtraKind
  24146. * @param data defines the data source
  24147. * @param updatable defines if the data must be flagged as updatable (or static)
  24148. * @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
  24149. * @returns the current mesh
  24150. */
  24151. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24152. /**
  24153. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24154. * If the mesh has no geometry, it is simply returned as it is.
  24155. * @param kind defines vertex data kind:
  24156. * * VertexBuffer.PositionKind
  24157. * * VertexBuffer.UVKind
  24158. * * VertexBuffer.UV2Kind
  24159. * * VertexBuffer.UV3Kind
  24160. * * VertexBuffer.UV4Kind
  24161. * * VertexBuffer.UV5Kind
  24162. * * VertexBuffer.UV6Kind
  24163. * * VertexBuffer.ColorKind
  24164. * * VertexBuffer.MatricesIndicesKind
  24165. * * VertexBuffer.MatricesIndicesExtraKind
  24166. * * VertexBuffer.MatricesWeightsKind
  24167. * * VertexBuffer.MatricesWeightsExtraKind
  24168. * @param data defines the data source
  24169. * @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
  24170. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24171. * @returns the current mesh
  24172. */
  24173. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24174. /**
  24175. * Sets the mesh indices,
  24176. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24177. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24178. * @param totalVertices Defines the total number of vertices
  24179. * @returns the current mesh
  24180. */
  24181. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24182. /**
  24183. * Gets a boolean indicating if specific vertex data is present
  24184. * @param kind defines the vertex data kind to use
  24185. * @returns true is data kind is present
  24186. */
  24187. isVerticesDataPresent(kind: string): boolean;
  24188. /**
  24189. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24190. * @returns a BoundingInfo
  24191. */
  24192. getBoundingInfo(): BoundingInfo;
  24193. /**
  24194. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24195. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  24196. * @returns the current mesh
  24197. */
  24198. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  24199. /**
  24200. * Overwrite the current bounding info
  24201. * @param boundingInfo defines the new bounding info
  24202. * @returns the current mesh
  24203. */
  24204. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24205. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24206. readonly useBones: boolean;
  24207. /** @hidden */
  24208. _preActivate(): void;
  24209. /** @hidden */
  24210. _preActivateForIntermediateRendering(renderId: number): void;
  24211. /** @hidden */
  24212. _activate(renderId: number): void;
  24213. /**
  24214. * Gets the current world matrix
  24215. * @returns a Matrix
  24216. */
  24217. getWorldMatrix(): Matrix;
  24218. /** @hidden */
  24219. _getWorldMatrixDeterminant(): number;
  24220. /**
  24221. * Perform relative position change from the point of view of behind the front of the mesh.
  24222. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24223. * Supports definition of mesh facing forward or backward
  24224. * @param amountRight defines the distance on the right axis
  24225. * @param amountUp defines the distance on the up axis
  24226. * @param amountForward defines the distance on the forward axis
  24227. * @returns the current mesh
  24228. */
  24229. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24230. /**
  24231. * Calculate relative position change from the point of view of behind the front of the mesh.
  24232. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24233. * Supports definition of mesh facing forward or backward
  24234. * @param amountRight defines the distance on the right axis
  24235. * @param amountUp defines the distance on the up axis
  24236. * @param amountForward defines the distance on the forward axis
  24237. * @returns the new displacement vector
  24238. */
  24239. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24240. /**
  24241. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24242. * Supports definition of mesh facing forward or backward
  24243. * @param flipBack defines the flip
  24244. * @param twirlClockwise defines the twirl
  24245. * @param tiltRight defines the tilt
  24246. * @returns the current mesh
  24247. */
  24248. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24249. /**
  24250. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24251. * Supports definition of mesh facing forward or backward.
  24252. * @param flipBack defines the flip
  24253. * @param twirlClockwise defines the twirl
  24254. * @param tiltRight defines the tilt
  24255. * @returns the new rotation vector
  24256. */
  24257. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24258. /**
  24259. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24260. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24261. * @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
  24262. * @returns the new bounding vectors
  24263. */
  24264. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24265. min: Vector3;
  24266. max: Vector3;
  24267. };
  24268. /**
  24269. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24270. * This means the mesh underlying bounding box and sphere are recomputed.
  24271. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24272. * @returns the current mesh
  24273. */
  24274. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24275. /** @hidden */
  24276. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24277. /** @hidden */
  24278. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24279. /** @hidden */
  24280. _updateBoundingInfo(): AbstractMesh;
  24281. /** @hidden */
  24282. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24283. /** @hidden */
  24284. protected _afterComputeWorldMatrix(): void;
  24285. /**
  24286. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24287. * A mesh is in the frustum if its bounding box intersects the frustum
  24288. * @param frustumPlanes defines the frustum to test
  24289. * @returns true if the mesh is in the frustum planes
  24290. */
  24291. isInFrustum(frustumPlanes: Plane[]): boolean;
  24292. /**
  24293. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24294. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24295. * @param frustumPlanes defines the frustum to test
  24296. * @returns true if the mesh is completely in the frustum planes
  24297. */
  24298. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24299. /**
  24300. * True if the mesh intersects another mesh or a SolidParticle object
  24301. * @param mesh defines a target mesh or SolidParticle to test
  24302. * @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)
  24303. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24304. * @returns true if there is an intersection
  24305. */
  24306. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24307. /**
  24308. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24309. * @param point defines the point to test
  24310. * @returns true if there is an intersection
  24311. */
  24312. intersectsPoint(point: Vector3): boolean;
  24313. /**
  24314. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24315. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24316. */
  24317. checkCollisions: boolean;
  24318. /**
  24319. * Gets Collider object used to compute collisions (not physics)
  24320. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24321. */
  24322. readonly collider: Collider;
  24323. /**
  24324. * Move the mesh using collision engine
  24325. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24326. * @param displacement defines the requested displacement vector
  24327. * @returns the current mesh
  24328. */
  24329. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24330. private _onCollisionPositionChange;
  24331. /** @hidden */
  24332. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24333. /** @hidden */
  24334. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24335. /** @hidden */
  24336. _checkCollision(collider: Collider): AbstractMesh;
  24337. /** @hidden */
  24338. _generatePointsArray(): boolean;
  24339. /**
  24340. * Checks if the passed Ray intersects with the mesh
  24341. * @param ray defines the ray to use
  24342. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24343. * @returns the picking info
  24344. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24345. */
  24346. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  24347. /**
  24348. * Clones the current mesh
  24349. * @param name defines the mesh name
  24350. * @param newParent defines the new mesh parent
  24351. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24352. * @returns the new mesh
  24353. */
  24354. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24355. /**
  24356. * Disposes all the submeshes of the current meshnp
  24357. * @returns the current mesh
  24358. */
  24359. releaseSubMeshes(): AbstractMesh;
  24360. /**
  24361. * Releases resources associated with this abstract mesh.
  24362. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24363. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24364. */
  24365. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24366. /**
  24367. * Adds the passed mesh as a child to the current mesh
  24368. * @param mesh defines the child mesh
  24369. * @returns the current mesh
  24370. */
  24371. addChild(mesh: AbstractMesh): AbstractMesh;
  24372. /**
  24373. * Removes the passed mesh from the current mesh children list
  24374. * @param mesh defines the child mesh
  24375. * @returns the current mesh
  24376. */
  24377. removeChild(mesh: AbstractMesh): AbstractMesh;
  24378. /** @hidden */
  24379. private _initFacetData;
  24380. /**
  24381. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24382. * This method can be called within the render loop.
  24383. * 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
  24384. * @returns the current mesh
  24385. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24386. */
  24387. updateFacetData(): AbstractMesh;
  24388. /**
  24389. * Returns the facetLocalNormals array.
  24390. * The normals are expressed in the mesh local spac
  24391. * @returns an array of Vector3
  24392. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24393. */
  24394. getFacetLocalNormals(): Vector3[];
  24395. /**
  24396. * Returns the facetLocalPositions array.
  24397. * The facet positions are expressed in the mesh local space
  24398. * @returns an array of Vector3
  24399. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24400. */
  24401. getFacetLocalPositions(): Vector3[];
  24402. /**
  24403. * Returns the facetLocalPartioning array
  24404. * @returns an array of array of numbers
  24405. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24406. */
  24407. getFacetLocalPartitioning(): number[][];
  24408. /**
  24409. * Returns the i-th facet position in the world system.
  24410. * This method allocates a new Vector3 per call
  24411. * @param i defines the facet index
  24412. * @returns a new Vector3
  24413. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24414. */
  24415. getFacetPosition(i: number): Vector3;
  24416. /**
  24417. * Sets the reference Vector3 with the i-th facet position in the world system
  24418. * @param i defines the facet index
  24419. * @param ref defines the target vector
  24420. * @returns the current mesh
  24421. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24422. */
  24423. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24424. /**
  24425. * Returns the i-th facet normal in the world system.
  24426. * This method allocates a new Vector3 per call
  24427. * @param i defines the facet index
  24428. * @returns a new Vector3
  24429. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24430. */
  24431. getFacetNormal(i: number): Vector3;
  24432. /**
  24433. * Sets the reference Vector3 with the i-th facet normal in the world system
  24434. * @param i defines the facet index
  24435. * @param ref defines the target vector
  24436. * @returns the current mesh
  24437. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24438. */
  24439. getFacetNormalToRef(i: number, ref: Vector3): this;
  24440. /**
  24441. * 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)
  24442. * @param x defines x coordinate
  24443. * @param y defines y coordinate
  24444. * @param z defines z coordinate
  24445. * @returns the array of facet indexes
  24446. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24447. */
  24448. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24449. /**
  24450. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24451. * @param projected sets as the (x,y,z) world projection on the facet
  24452. * @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
  24453. * @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
  24454. * @param x defines x coordinate
  24455. * @param y defines y coordinate
  24456. * @param z defines z coordinate
  24457. * @returns the face index if found (or null instead)
  24458. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24459. */
  24460. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24461. /**
  24462. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24463. * @param projected sets as the (x,y,z) local projection on the facet
  24464. * @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
  24465. * @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
  24466. * @param x defines x coordinate
  24467. * @param y defines y coordinate
  24468. * @param z defines z coordinate
  24469. * @returns the face index if found (or null instead)
  24470. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24471. */
  24472. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24473. /**
  24474. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24475. * @returns the parameters
  24476. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24477. */
  24478. getFacetDataParameters(): any;
  24479. /**
  24480. * Disables the feature FacetData and frees the related memory
  24481. * @returns the current mesh
  24482. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24483. */
  24484. disableFacetData(): AbstractMesh;
  24485. /**
  24486. * Updates the AbstractMesh indices array
  24487. * @param indices defines the data source
  24488. * @returns the current mesh
  24489. */
  24490. updateIndices(indices: IndicesArray): AbstractMesh;
  24491. /**
  24492. * Creates new normals data for the mesh
  24493. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24494. * @returns the current mesh
  24495. */
  24496. createNormals(updatable: boolean): AbstractMesh;
  24497. /**
  24498. * Align the mesh with a normal
  24499. * @param normal defines the normal to use
  24500. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24501. * @returns the current mesh
  24502. */
  24503. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24504. /** @hidden */
  24505. _checkOcclusionQuery(): boolean;
  24506. }
  24507. }
  24508. declare module "babylonjs/Actions/actionEvent" {
  24509. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24510. import { Nullable } from "babylonjs/types";
  24511. import { Sprite } from "babylonjs/Sprites/sprite";
  24512. import { Scene } from "babylonjs/scene";
  24513. import { Vector2 } from "babylonjs/Maths/math";
  24514. /**
  24515. * Interface used to define ActionEvent
  24516. */
  24517. export interface IActionEvent {
  24518. /** The mesh or sprite that triggered the action */
  24519. source: any;
  24520. /** The X mouse cursor position at the time of the event */
  24521. pointerX: number;
  24522. /** The Y mouse cursor position at the time of the event */
  24523. pointerY: number;
  24524. /** The mesh that is currently pointed at (can be null) */
  24525. meshUnderPointer: Nullable<AbstractMesh>;
  24526. /** the original (browser) event that triggered the ActionEvent */
  24527. sourceEvent?: any;
  24528. /** additional data for the event */
  24529. additionalData?: any;
  24530. }
  24531. /**
  24532. * ActionEvent is the event being sent when an action is triggered.
  24533. */
  24534. export class ActionEvent implements IActionEvent {
  24535. /** The mesh or sprite that triggered the action */
  24536. source: any;
  24537. /** The X mouse cursor position at the time of the event */
  24538. pointerX: number;
  24539. /** The Y mouse cursor position at the time of the event */
  24540. pointerY: number;
  24541. /** The mesh that is currently pointed at (can be null) */
  24542. meshUnderPointer: Nullable<AbstractMesh>;
  24543. /** the original (browser) event that triggered the ActionEvent */
  24544. sourceEvent?: any;
  24545. /** additional data for the event */
  24546. additionalData?: any;
  24547. /**
  24548. * Creates a new ActionEvent
  24549. * @param source The mesh or sprite that triggered the action
  24550. * @param pointerX The X mouse cursor position at the time of the event
  24551. * @param pointerY The Y mouse cursor position at the time of the event
  24552. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  24553. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  24554. * @param additionalData additional data for the event
  24555. */
  24556. constructor(
  24557. /** The mesh or sprite that triggered the action */
  24558. source: any,
  24559. /** The X mouse cursor position at the time of the event */
  24560. pointerX: number,
  24561. /** The Y mouse cursor position at the time of the event */
  24562. pointerY: number,
  24563. /** The mesh that is currently pointed at (can be null) */
  24564. meshUnderPointer: Nullable<AbstractMesh>,
  24565. /** the original (browser) event that triggered the ActionEvent */
  24566. sourceEvent?: any,
  24567. /** additional data for the event */
  24568. additionalData?: any);
  24569. /**
  24570. * Helper function to auto-create an ActionEvent from a source mesh.
  24571. * @param source The source mesh that triggered the event
  24572. * @param evt The original (browser) event
  24573. * @param additionalData additional data for the event
  24574. * @returns the new ActionEvent
  24575. */
  24576. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  24577. /**
  24578. * Helper function to auto-create an ActionEvent from a source sprite
  24579. * @param source The source sprite that triggered the event
  24580. * @param scene Scene associated with the sprite
  24581. * @param evt The original (browser) event
  24582. * @param additionalData additional data for the event
  24583. * @returns the new ActionEvent
  24584. */
  24585. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  24586. /**
  24587. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  24588. * @param scene the scene where the event occurred
  24589. * @param evt The original (browser) event
  24590. * @returns the new ActionEvent
  24591. */
  24592. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  24593. /**
  24594. * Helper function to auto-create an ActionEvent from a primitive
  24595. * @param prim defines the target primitive
  24596. * @param pointerPos defines the pointer position
  24597. * @param evt The original (browser) event
  24598. * @param additionalData additional data for the event
  24599. * @returns the new ActionEvent
  24600. */
  24601. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  24602. }
  24603. }
  24604. declare module "babylonjs/Actions/abstractActionManager" {
  24605. import { IDisposable } from "babylonjs/scene";
  24606. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  24607. import { IAction } from "babylonjs/Actions/action";
  24608. /**
  24609. * Abstract class used to decouple action Manager from scene and meshes.
  24610. * Do not instantiate.
  24611. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24612. */
  24613. export abstract class AbstractActionManager implements IDisposable {
  24614. /** Gets the list of active triggers */
  24615. static Triggers: {
  24616. [key: string]: number;
  24617. };
  24618. /** Gets the cursor to use when hovering items */
  24619. hoverCursor: string;
  24620. /** Gets the list of actions */
  24621. actions: IAction[];
  24622. /**
  24623. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  24624. */
  24625. isRecursive: boolean;
  24626. /**
  24627. * Releases all associated resources
  24628. */
  24629. abstract dispose(): void;
  24630. /**
  24631. * Does this action manager has pointer triggers
  24632. */
  24633. abstract readonly hasPointerTriggers: boolean;
  24634. /**
  24635. * Does this action manager has pick triggers
  24636. */
  24637. abstract readonly hasPickTriggers: boolean;
  24638. /**
  24639. * Process a specific trigger
  24640. * @param trigger defines the trigger to process
  24641. * @param evt defines the event details to be processed
  24642. */
  24643. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  24644. /**
  24645. * Does this action manager handles actions of any of the given triggers
  24646. * @param triggers defines the triggers to be tested
  24647. * @return a boolean indicating whether one (or more) of the triggers is handled
  24648. */
  24649. abstract hasSpecificTriggers(triggers: number[]): boolean;
  24650. /**
  24651. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  24652. * speed.
  24653. * @param triggerA defines the trigger to be tested
  24654. * @param triggerB defines the trigger to be tested
  24655. * @return a boolean indicating whether one (or more) of the triggers is handled
  24656. */
  24657. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  24658. /**
  24659. * Does this action manager handles actions of a given trigger
  24660. * @param trigger defines the trigger to be tested
  24661. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  24662. * @return whether the trigger is handled
  24663. */
  24664. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  24665. /**
  24666. * Serialize this manager to a JSON object
  24667. * @param name defines the property name to store this manager
  24668. * @returns a JSON representation of this manager
  24669. */
  24670. abstract serialize(name: string): any;
  24671. /**
  24672. * Does exist one action manager with at least one trigger
  24673. **/
  24674. static readonly HasTriggers: boolean;
  24675. /**
  24676. * Does exist one action manager with at least one pick trigger
  24677. **/
  24678. static readonly HasPickTriggers: boolean;
  24679. /**
  24680. * Does exist one action manager that handles actions of a given trigger
  24681. * @param trigger defines the trigger to be tested
  24682. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  24683. **/
  24684. static HasSpecificTrigger(trigger: number): boolean;
  24685. }
  24686. }
  24687. declare module "babylonjs/node" {
  24688. import { Scene } from "babylonjs/scene";
  24689. import { Nullable } from "babylonjs/types";
  24690. import { Matrix } from "babylonjs/Maths/math";
  24691. import { Engine } from "babylonjs/Engines/engine";
  24692. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  24693. import { Observable } from "babylonjs/Misc/observable";
  24694. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  24695. import { Animatable } from "babylonjs/Animations/animatable";
  24696. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  24697. import { Animation } from "babylonjs/Animations/animation";
  24698. import { AnimationRange } from "babylonjs/Animations/animationRange";
  24699. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24700. /**
  24701. * Defines how a node can be built from a string name.
  24702. */
  24703. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  24704. /**
  24705. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  24706. */
  24707. export class Node implements IBehaviorAware<Node> {
  24708. /** @hidden */
  24709. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  24710. private static _NodeConstructors;
  24711. /**
  24712. * Add a new node constructor
  24713. * @param type defines the type name of the node to construct
  24714. * @param constructorFunc defines the constructor function
  24715. */
  24716. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  24717. /**
  24718. * Returns a node constructor based on type name
  24719. * @param type defines the type name
  24720. * @param name defines the new node name
  24721. * @param scene defines the hosting scene
  24722. * @param options defines optional options to transmit to constructors
  24723. * @returns the new constructor or null
  24724. */
  24725. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  24726. /**
  24727. * Gets or sets the name of the node
  24728. */
  24729. name: string;
  24730. /**
  24731. * Gets or sets the id of the node
  24732. */
  24733. id: string;
  24734. /**
  24735. * Gets or sets the unique id of the node
  24736. */
  24737. uniqueId: number;
  24738. /**
  24739. * Gets or sets a string used to store user defined state for the node
  24740. */
  24741. state: string;
  24742. /**
  24743. * Gets or sets an object used to store user defined information for the node
  24744. */
  24745. metadata: any;
  24746. /**
  24747. * For internal use only. Please do not use.
  24748. */
  24749. reservedDataStore: any;
  24750. /**
  24751. * Gets or sets a boolean used to define if the node must be serialized
  24752. */
  24753. doNotSerialize: boolean;
  24754. /** @hidden */
  24755. _isDisposed: boolean;
  24756. /**
  24757. * Gets a list of Animations associated with the node
  24758. */
  24759. animations: import("babylonjs/Animations/animation").Animation[];
  24760. protected _ranges: {
  24761. [name: string]: Nullable<AnimationRange>;
  24762. };
  24763. /**
  24764. * Callback raised when the node is ready to be used
  24765. */
  24766. onReady: (node: Node) => void;
  24767. private _isEnabled;
  24768. private _isParentEnabled;
  24769. private _isReady;
  24770. /** @hidden */
  24771. _currentRenderId: number;
  24772. private _parentRenderId;
  24773. protected _childRenderId: number;
  24774. /** @hidden */
  24775. _waitingParentId: Nullable<string>;
  24776. /** @hidden */
  24777. _scene: Scene;
  24778. /** @hidden */
  24779. _cache: any;
  24780. private _parentNode;
  24781. private _children;
  24782. /** @hidden */
  24783. _worldMatrix: Matrix;
  24784. /** @hidden */
  24785. _worldMatrixDeterminant: number;
  24786. /** @hidden */
  24787. private _sceneRootNodesIndex;
  24788. /**
  24789. * Gets a boolean indicating if the node has been disposed
  24790. * @returns true if the node was disposed
  24791. */
  24792. isDisposed(): boolean;
  24793. /**
  24794. * Gets or sets the parent of the node
  24795. */
  24796. parent: Nullable<Node>;
  24797. private addToSceneRootNodes;
  24798. private removeFromSceneRootNodes;
  24799. private _animationPropertiesOverride;
  24800. /**
  24801. * Gets or sets the animation properties override
  24802. */
  24803. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24804. /**
  24805. * Gets a string idenfifying the name of the class
  24806. * @returns "Node" string
  24807. */
  24808. getClassName(): string;
  24809. /** @hidden */
  24810. readonly _isNode: boolean;
  24811. /**
  24812. * An event triggered when the mesh is disposed
  24813. */
  24814. onDisposeObservable: Observable<Node>;
  24815. private _onDisposeObserver;
  24816. /**
  24817. * Sets a callback that will be raised when the node will be disposed
  24818. */
  24819. onDispose: () => void;
  24820. /**
  24821. * Creates a new Node
  24822. * @param name the name and id to be given to this node
  24823. * @param scene the scene this node will be added to
  24824. * @param addToRootNodes the node will be added to scene.rootNodes
  24825. */
  24826. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  24827. /**
  24828. * Gets the scene of the node
  24829. * @returns a scene
  24830. */
  24831. getScene(): Scene;
  24832. /**
  24833. * Gets the engine of the node
  24834. * @returns a Engine
  24835. */
  24836. getEngine(): Engine;
  24837. private _behaviors;
  24838. /**
  24839. * Attach a behavior to the node
  24840. * @see http://doc.babylonjs.com/features/behaviour
  24841. * @param behavior defines the behavior to attach
  24842. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  24843. * @returns the current Node
  24844. */
  24845. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  24846. /**
  24847. * Remove an attached behavior
  24848. * @see http://doc.babylonjs.com/features/behaviour
  24849. * @param behavior defines the behavior to attach
  24850. * @returns the current Node
  24851. */
  24852. removeBehavior(behavior: Behavior<Node>): Node;
  24853. /**
  24854. * Gets the list of attached behaviors
  24855. * @see http://doc.babylonjs.com/features/behaviour
  24856. */
  24857. readonly behaviors: Behavior<Node>[];
  24858. /**
  24859. * Gets an attached behavior by name
  24860. * @param name defines the name of the behavior to look for
  24861. * @see http://doc.babylonjs.com/features/behaviour
  24862. * @returns null if behavior was not found else the requested behavior
  24863. */
  24864. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  24865. /**
  24866. * Returns the latest update of the World matrix
  24867. * @returns a Matrix
  24868. */
  24869. getWorldMatrix(): Matrix;
  24870. /** @hidden */
  24871. _getWorldMatrixDeterminant(): number;
  24872. /**
  24873. * Returns directly the latest state of the mesh World matrix.
  24874. * A Matrix is returned.
  24875. */
  24876. readonly worldMatrixFromCache: Matrix;
  24877. /** @hidden */
  24878. _initCache(): void;
  24879. /** @hidden */
  24880. updateCache(force?: boolean): void;
  24881. /** @hidden */
  24882. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24883. /** @hidden */
  24884. _updateCache(ignoreParentClass?: boolean): void;
  24885. /** @hidden */
  24886. _isSynchronized(): boolean;
  24887. /** @hidden */
  24888. _markSyncedWithParent(): void;
  24889. /** @hidden */
  24890. isSynchronizedWithParent(): boolean;
  24891. /** @hidden */
  24892. isSynchronized(): boolean;
  24893. /**
  24894. * Is this node ready to be used/rendered
  24895. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24896. * @return true if the node is ready
  24897. */
  24898. isReady(completeCheck?: boolean): boolean;
  24899. /**
  24900. * Is this node enabled?
  24901. * 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
  24902. * @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
  24903. * @return whether this node (and its parent) is enabled
  24904. */
  24905. isEnabled(checkAncestors?: boolean): boolean;
  24906. /** @hidden */
  24907. protected _syncParentEnabledState(): void;
  24908. /**
  24909. * Set the enabled state of this node
  24910. * @param value defines the new enabled state
  24911. */
  24912. setEnabled(value: boolean): void;
  24913. /**
  24914. * Is this node a descendant of the given node?
  24915. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  24916. * @param ancestor defines the parent node to inspect
  24917. * @returns a boolean indicating if this node is a descendant of the given node
  24918. */
  24919. isDescendantOf(ancestor: Node): boolean;
  24920. /** @hidden */
  24921. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  24922. /**
  24923. * Will return all nodes that have this node as ascendant
  24924. * @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
  24925. * @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
  24926. * @return all children nodes of all types
  24927. */
  24928. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  24929. /**
  24930. * Get all child-meshes of this node
  24931. * @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)
  24932. * @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
  24933. * @returns an array of AbstractMesh
  24934. */
  24935. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  24936. /**
  24937. * Get all direct children of this node
  24938. * @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
  24939. * @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)
  24940. * @returns an array of Node
  24941. */
  24942. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  24943. /** @hidden */
  24944. _setReady(state: boolean): void;
  24945. /**
  24946. * Get an animation by name
  24947. * @param name defines the name of the animation to look for
  24948. * @returns null if not found else the requested animation
  24949. */
  24950. getAnimationByName(name: string): Nullable<Animation>;
  24951. /**
  24952. * Creates an animation range for this node
  24953. * @param name defines the name of the range
  24954. * @param from defines the starting key
  24955. * @param to defines the end key
  24956. */
  24957. createAnimationRange(name: string, from: number, to: number): void;
  24958. /**
  24959. * Delete a specific animation range
  24960. * @param name defines the name of the range to delete
  24961. * @param deleteFrames defines if animation frames from the range must be deleted as well
  24962. */
  24963. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  24964. /**
  24965. * Get an animation range by name
  24966. * @param name defines the name of the animation range to look for
  24967. * @returns null if not found else the requested animation range
  24968. */
  24969. getAnimationRange(name: string): Nullable<AnimationRange>;
  24970. /**
  24971. * Will start the animation sequence
  24972. * @param name defines the range frames for animation sequence
  24973. * @param loop defines if the animation should loop (false by default)
  24974. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  24975. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  24976. * @returns the object created for this animation. If range does not exist, it will return null
  24977. */
  24978. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  24979. /**
  24980. * Serialize animation ranges into a JSON compatible object
  24981. * @returns serialization object
  24982. */
  24983. serializeAnimationRanges(): any;
  24984. /**
  24985. * Computes the world matrix of the node
  24986. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  24987. * @returns the world matrix
  24988. */
  24989. computeWorldMatrix(force?: boolean): Matrix;
  24990. /**
  24991. * Releases resources associated with this node.
  24992. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24993. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24994. */
  24995. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24996. /**
  24997. * Parse animation range data from a serialization object and store them into a given node
  24998. * @param node defines where to store the animation ranges
  24999. * @param parsedNode defines the serialization object to read data from
  25000. * @param scene defines the hosting scene
  25001. */
  25002. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25003. }
  25004. }
  25005. declare module "babylonjs/Animations/animation" {
  25006. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  25007. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  25008. import { Nullable } from "babylonjs/types";
  25009. import { Scene } from "babylonjs/scene";
  25010. import { IAnimatable } from "babylonjs/Misc/tools";
  25011. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  25012. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25013. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  25014. import { Node } from "babylonjs/node";
  25015. import { Animatable } from "babylonjs/Animations/animatable";
  25016. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  25017. /**
  25018. * Class used to store any kind of animation
  25019. */
  25020. export class Animation {
  25021. /**Name of the animation */
  25022. name: string;
  25023. /**Property to animate */
  25024. targetProperty: string;
  25025. /**The frames per second of the animation */
  25026. framePerSecond: number;
  25027. /**The data type of the animation */
  25028. dataType: number;
  25029. /**The loop mode of the animation */
  25030. loopMode?: number | undefined;
  25031. /**Specifies if blending should be enabled */
  25032. enableBlending?: boolean | undefined;
  25033. /**
  25034. * Use matrix interpolation instead of using direct key value when animating matrices
  25035. */
  25036. static AllowMatricesInterpolation: boolean;
  25037. /**
  25038. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25039. */
  25040. static AllowMatrixDecomposeForInterpolation: boolean;
  25041. /**
  25042. * Stores the key frames of the animation
  25043. */
  25044. private _keys;
  25045. /**
  25046. * Stores the easing function of the animation
  25047. */
  25048. private _easingFunction;
  25049. /**
  25050. * @hidden Internal use only
  25051. */
  25052. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  25053. /**
  25054. * The set of event that will be linked to this animation
  25055. */
  25056. private _events;
  25057. /**
  25058. * Stores an array of target property paths
  25059. */
  25060. targetPropertyPath: string[];
  25061. /**
  25062. * Stores the blending speed of the animation
  25063. */
  25064. blendingSpeed: number;
  25065. /**
  25066. * Stores the animation ranges for the animation
  25067. */
  25068. private _ranges;
  25069. /**
  25070. * @hidden Internal use
  25071. */
  25072. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25073. /**
  25074. * Sets up an animation
  25075. * @param property The property to animate
  25076. * @param animationType The animation type to apply
  25077. * @param framePerSecond The frames per second of the animation
  25078. * @param easingFunction The easing function used in the animation
  25079. * @returns The created animation
  25080. */
  25081. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25082. /**
  25083. * Create and start an animation on a node
  25084. * @param name defines the name of the global animation that will be run on all nodes
  25085. * @param node defines the root node where the animation will take place
  25086. * @param targetProperty defines property to animate
  25087. * @param framePerSecond defines the number of frame per second yo use
  25088. * @param totalFrame defines the number of frames in total
  25089. * @param from defines the initial value
  25090. * @param to defines the final value
  25091. * @param loopMode defines which loop mode you want to use (off by default)
  25092. * @param easingFunction defines the easing function to use (linear by default)
  25093. * @param onAnimationEnd defines the callback to call when animation end
  25094. * @returns the animatable created for this animation
  25095. */
  25096. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25097. /**
  25098. * Create and start an animation on a node and its descendants
  25099. * @param name defines the name of the global animation that will be run on all nodes
  25100. * @param node defines the root node where the animation will take place
  25101. * @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
  25102. * @param targetProperty defines property to animate
  25103. * @param framePerSecond defines the number of frame per second to use
  25104. * @param totalFrame defines the number of frames in total
  25105. * @param from defines the initial value
  25106. * @param to defines the final value
  25107. * @param loopMode defines which loop mode you want to use (off by default)
  25108. * @param easingFunction defines the easing function to use (linear by default)
  25109. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25110. * @returns the list of animatables created for all nodes
  25111. * @example https://www.babylonjs-playground.com/#MH0VLI
  25112. */
  25113. 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[]>;
  25114. /**
  25115. * Creates a new animation, merges it with the existing animations and starts it
  25116. * @param name Name of the animation
  25117. * @param node Node which contains the scene that begins the animations
  25118. * @param targetProperty Specifies which property to animate
  25119. * @param framePerSecond The frames per second of the animation
  25120. * @param totalFrame The total number of frames
  25121. * @param from The frame at the beginning of the animation
  25122. * @param to The frame at the end of the animation
  25123. * @param loopMode Specifies the loop mode of the animation
  25124. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25125. * @param onAnimationEnd Callback to run once the animation is complete
  25126. * @returns Nullable animation
  25127. */
  25128. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25129. /**
  25130. * Transition property of an host to the target Value
  25131. * @param property The property to transition
  25132. * @param targetValue The target Value of the property
  25133. * @param host The object where the property to animate belongs
  25134. * @param scene Scene used to run the animation
  25135. * @param frameRate Framerate (in frame/s) to use
  25136. * @param transition The transition type we want to use
  25137. * @param duration The duration of the animation, in milliseconds
  25138. * @param onAnimationEnd Callback trigger at the end of the animation
  25139. * @returns Nullable animation
  25140. */
  25141. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25142. /**
  25143. * Return the array of runtime animations currently using this animation
  25144. */
  25145. readonly runtimeAnimations: RuntimeAnimation[];
  25146. /**
  25147. * Specifies if any of the runtime animations are currently running
  25148. */
  25149. readonly hasRunningRuntimeAnimations: boolean;
  25150. /**
  25151. * Initializes the animation
  25152. * @param name Name of the animation
  25153. * @param targetProperty Property to animate
  25154. * @param framePerSecond The frames per second of the animation
  25155. * @param dataType The data type of the animation
  25156. * @param loopMode The loop mode of the animation
  25157. * @param enableBlending Specifies if blending should be enabled
  25158. */
  25159. constructor(
  25160. /**Name of the animation */
  25161. name: string,
  25162. /**Property to animate */
  25163. targetProperty: string,
  25164. /**The frames per second of the animation */
  25165. framePerSecond: number,
  25166. /**The data type of the animation */
  25167. dataType: number,
  25168. /**The loop mode of the animation */
  25169. loopMode?: number | undefined,
  25170. /**Specifies if blending should be enabled */
  25171. enableBlending?: boolean | undefined);
  25172. /**
  25173. * Converts the animation to a string
  25174. * @param fullDetails support for multiple levels of logging within scene loading
  25175. * @returns String form of the animation
  25176. */
  25177. toString(fullDetails?: boolean): string;
  25178. /**
  25179. * Add an event to this animation
  25180. * @param event Event to add
  25181. */
  25182. addEvent(event: AnimationEvent): void;
  25183. /**
  25184. * Remove all events found at the given frame
  25185. * @param frame The frame to remove events from
  25186. */
  25187. removeEvents(frame: number): void;
  25188. /**
  25189. * Retrieves all the events from the animation
  25190. * @returns Events from the animation
  25191. */
  25192. getEvents(): AnimationEvent[];
  25193. /**
  25194. * Creates an animation range
  25195. * @param name Name of the animation range
  25196. * @param from Starting frame of the animation range
  25197. * @param to Ending frame of the animation
  25198. */
  25199. createRange(name: string, from: number, to: number): void;
  25200. /**
  25201. * Deletes an animation range by name
  25202. * @param name Name of the animation range to delete
  25203. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25204. */
  25205. deleteRange(name: string, deleteFrames?: boolean): void;
  25206. /**
  25207. * Gets the animation range by name, or null if not defined
  25208. * @param name Name of the animation range
  25209. * @returns Nullable animation range
  25210. */
  25211. getRange(name: string): Nullable<AnimationRange>;
  25212. /**
  25213. * Gets the key frames from the animation
  25214. * @returns The key frames of the animation
  25215. */
  25216. getKeys(): Array<IAnimationKey>;
  25217. /**
  25218. * Gets the highest frame rate of the animation
  25219. * @returns Highest frame rate of the animation
  25220. */
  25221. getHighestFrame(): number;
  25222. /**
  25223. * Gets the easing function of the animation
  25224. * @returns Easing function of the animation
  25225. */
  25226. getEasingFunction(): IEasingFunction;
  25227. /**
  25228. * Sets the easing function of the animation
  25229. * @param easingFunction A custom mathematical formula for animation
  25230. */
  25231. setEasingFunction(easingFunction: EasingFunction): void;
  25232. /**
  25233. * Interpolates a scalar linearly
  25234. * @param startValue Start value of the animation curve
  25235. * @param endValue End value of the animation curve
  25236. * @param gradient Scalar amount to interpolate
  25237. * @returns Interpolated scalar value
  25238. */
  25239. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25240. /**
  25241. * Interpolates a scalar cubically
  25242. * @param startValue Start value of the animation curve
  25243. * @param outTangent End tangent of the animation
  25244. * @param endValue End value of the animation curve
  25245. * @param inTangent Start tangent of the animation curve
  25246. * @param gradient Scalar amount to interpolate
  25247. * @returns Interpolated scalar value
  25248. */
  25249. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25250. /**
  25251. * Interpolates a quaternion using a spherical linear interpolation
  25252. * @param startValue Start value of the animation curve
  25253. * @param endValue End value of the animation curve
  25254. * @param gradient Scalar amount to interpolate
  25255. * @returns Interpolated quaternion value
  25256. */
  25257. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25258. /**
  25259. * Interpolates a quaternion cubically
  25260. * @param startValue Start value of the animation curve
  25261. * @param outTangent End tangent of the animation curve
  25262. * @param endValue End value of the animation curve
  25263. * @param inTangent Start tangent of the animation curve
  25264. * @param gradient Scalar amount to interpolate
  25265. * @returns Interpolated quaternion value
  25266. */
  25267. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25268. /**
  25269. * Interpolates a Vector3 linearl
  25270. * @param startValue Start value of the animation curve
  25271. * @param endValue End value of the animation curve
  25272. * @param gradient Scalar amount to interpolate
  25273. * @returns Interpolated scalar value
  25274. */
  25275. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25276. /**
  25277. * Interpolates a Vector3 cubically
  25278. * @param startValue Start value of the animation curve
  25279. * @param outTangent End tangent of the animation
  25280. * @param endValue End value of the animation curve
  25281. * @param inTangent Start tangent of the animation curve
  25282. * @param gradient Scalar amount to interpolate
  25283. * @returns InterpolatedVector3 value
  25284. */
  25285. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25286. /**
  25287. * Interpolates a Vector2 linearly
  25288. * @param startValue Start value of the animation curve
  25289. * @param endValue End value of the animation curve
  25290. * @param gradient Scalar amount to interpolate
  25291. * @returns Interpolated Vector2 value
  25292. */
  25293. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25294. /**
  25295. * Interpolates a Vector2 cubically
  25296. * @param startValue Start value of the animation curve
  25297. * @param outTangent End tangent of the animation
  25298. * @param endValue End value of the animation curve
  25299. * @param inTangent Start tangent of the animation curve
  25300. * @param gradient Scalar amount to interpolate
  25301. * @returns Interpolated Vector2 value
  25302. */
  25303. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25304. /**
  25305. * Interpolates a size linearly
  25306. * @param startValue Start value of the animation curve
  25307. * @param endValue End value of the animation curve
  25308. * @param gradient Scalar amount to interpolate
  25309. * @returns Interpolated Size value
  25310. */
  25311. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25312. /**
  25313. * Interpolates a Color3 linearly
  25314. * @param startValue Start value of the animation curve
  25315. * @param endValue End value of the animation curve
  25316. * @param gradient Scalar amount to interpolate
  25317. * @returns Interpolated Color3 value
  25318. */
  25319. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25320. /**
  25321. * @hidden Internal use only
  25322. */
  25323. _getKeyValue(value: any): any;
  25324. /**
  25325. * @hidden Internal use only
  25326. */
  25327. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  25328. /**
  25329. * Defines the function to use to interpolate matrices
  25330. * @param startValue defines the start matrix
  25331. * @param endValue defines the end matrix
  25332. * @param gradient defines the gradient between both matrices
  25333. * @param result defines an optional target matrix where to store the interpolation
  25334. * @returns the interpolated matrix
  25335. */
  25336. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25337. /**
  25338. * Makes a copy of the animation
  25339. * @returns Cloned animation
  25340. */
  25341. clone(): Animation;
  25342. /**
  25343. * Sets the key frames of the animation
  25344. * @param values The animation key frames to set
  25345. */
  25346. setKeys(values: Array<IAnimationKey>): void;
  25347. /**
  25348. * Serializes the animation to an object
  25349. * @returns Serialized object
  25350. */
  25351. serialize(): any;
  25352. /**
  25353. * Float animation type
  25354. */
  25355. private static _ANIMATIONTYPE_FLOAT;
  25356. /**
  25357. * Vector3 animation type
  25358. */
  25359. private static _ANIMATIONTYPE_VECTOR3;
  25360. /**
  25361. * Quaternion animation type
  25362. */
  25363. private static _ANIMATIONTYPE_QUATERNION;
  25364. /**
  25365. * Matrix animation type
  25366. */
  25367. private static _ANIMATIONTYPE_MATRIX;
  25368. /**
  25369. * Color3 animation type
  25370. */
  25371. private static _ANIMATIONTYPE_COLOR3;
  25372. /**
  25373. * Vector2 animation type
  25374. */
  25375. private static _ANIMATIONTYPE_VECTOR2;
  25376. /**
  25377. * Size animation type
  25378. */
  25379. private static _ANIMATIONTYPE_SIZE;
  25380. /**
  25381. * Relative Loop Mode
  25382. */
  25383. private static _ANIMATIONLOOPMODE_RELATIVE;
  25384. /**
  25385. * Cycle Loop Mode
  25386. */
  25387. private static _ANIMATIONLOOPMODE_CYCLE;
  25388. /**
  25389. * Constant Loop Mode
  25390. */
  25391. private static _ANIMATIONLOOPMODE_CONSTANT;
  25392. /**
  25393. * Get the float animation type
  25394. */
  25395. static readonly ANIMATIONTYPE_FLOAT: number;
  25396. /**
  25397. * Get the Vector3 animation type
  25398. */
  25399. static readonly ANIMATIONTYPE_VECTOR3: number;
  25400. /**
  25401. * Get the Vector2 animation type
  25402. */
  25403. static readonly ANIMATIONTYPE_VECTOR2: number;
  25404. /**
  25405. * Get the Size animation type
  25406. */
  25407. static readonly ANIMATIONTYPE_SIZE: number;
  25408. /**
  25409. * Get the Quaternion animation type
  25410. */
  25411. static readonly ANIMATIONTYPE_QUATERNION: number;
  25412. /**
  25413. * Get the Matrix animation type
  25414. */
  25415. static readonly ANIMATIONTYPE_MATRIX: number;
  25416. /**
  25417. * Get the Color3 animation type
  25418. */
  25419. static readonly ANIMATIONTYPE_COLOR3: number;
  25420. /**
  25421. * Get the Relative Loop Mode
  25422. */
  25423. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25424. /**
  25425. * Get the Cycle Loop Mode
  25426. */
  25427. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25428. /**
  25429. * Get the Constant Loop Mode
  25430. */
  25431. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25432. /** @hidden */
  25433. static _UniversalLerp(left: any, right: any, amount: number): any;
  25434. /**
  25435. * Parses an animation object and creates an animation
  25436. * @param parsedAnimation Parsed animation object
  25437. * @returns Animation object
  25438. */
  25439. static Parse(parsedAnimation: any): Animation;
  25440. /**
  25441. * Appends the serialized animations from the source animations
  25442. * @param source Source containing the animations
  25443. * @param destination Target to store the animations
  25444. */
  25445. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25446. }
  25447. }
  25448. declare module "babylonjs/Materials/Textures/baseTexture" {
  25449. import { Observable } from "babylonjs/Misc/observable";
  25450. import { IAnimatable } from "babylonjs/Misc/tools";
  25451. import { Nullable } from "babylonjs/types";
  25452. import { Scene } from "babylonjs/scene";
  25453. import { Matrix, ISize } from "babylonjs/Maths/math";
  25454. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  25455. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  25456. /**
  25457. * Base class of all the textures in babylon.
  25458. * It groups all the common properties the materials, post process, lights... might need
  25459. * in order to make a correct use of the texture.
  25460. */
  25461. export class BaseTexture implements IAnimatable {
  25462. /**
  25463. * Default anisotropic filtering level for the application.
  25464. * It is set to 4 as a good tradeoff between perf and quality.
  25465. */
  25466. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25467. /**
  25468. * Gets or sets the unique id of the texture
  25469. */
  25470. uniqueId: number;
  25471. /**
  25472. * Define the name of the texture.
  25473. */
  25474. name: string;
  25475. /**
  25476. * Gets or sets an object used to store user defined information.
  25477. */
  25478. metadata: any;
  25479. /**
  25480. * For internal use only. Please do not use.
  25481. */
  25482. reservedDataStore: any;
  25483. private _hasAlpha;
  25484. /**
  25485. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25486. */
  25487. hasAlpha: boolean;
  25488. /**
  25489. * Defines if the alpha value should be determined via the rgb values.
  25490. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25491. */
  25492. getAlphaFromRGB: boolean;
  25493. /**
  25494. * Intensity or strength of the texture.
  25495. * It is commonly used by materials to fine tune the intensity of the texture
  25496. */
  25497. level: number;
  25498. /**
  25499. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25500. * This is part of the texture as textures usually maps to one uv set.
  25501. */
  25502. coordinatesIndex: number;
  25503. private _coordinatesMode;
  25504. /**
  25505. * How a texture is mapped.
  25506. *
  25507. * | Value | Type | Description |
  25508. * | ----- | ----------------------------------- | ----------- |
  25509. * | 0 | EXPLICIT_MODE | |
  25510. * | 1 | SPHERICAL_MODE | |
  25511. * | 2 | PLANAR_MODE | |
  25512. * | 3 | CUBIC_MODE | |
  25513. * | 4 | PROJECTION_MODE | |
  25514. * | 5 | SKYBOX_MODE | |
  25515. * | 6 | INVCUBIC_MODE | |
  25516. * | 7 | EQUIRECTANGULAR_MODE | |
  25517. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  25518. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  25519. */
  25520. coordinatesMode: number;
  25521. /**
  25522. * | Value | Type | Description |
  25523. * | ----- | ------------------ | ----------- |
  25524. * | 0 | CLAMP_ADDRESSMODE | |
  25525. * | 1 | WRAP_ADDRESSMODE | |
  25526. * | 2 | MIRROR_ADDRESSMODE | |
  25527. */
  25528. wrapU: number;
  25529. /**
  25530. * | Value | Type | Description |
  25531. * | ----- | ------------------ | ----------- |
  25532. * | 0 | CLAMP_ADDRESSMODE | |
  25533. * | 1 | WRAP_ADDRESSMODE | |
  25534. * | 2 | MIRROR_ADDRESSMODE | |
  25535. */
  25536. wrapV: number;
  25537. /**
  25538. * | Value | Type | Description |
  25539. * | ----- | ------------------ | ----------- |
  25540. * | 0 | CLAMP_ADDRESSMODE | |
  25541. * | 1 | WRAP_ADDRESSMODE | |
  25542. * | 2 | MIRROR_ADDRESSMODE | |
  25543. */
  25544. wrapR: number;
  25545. /**
  25546. * With compliant hardware and browser (supporting anisotropic filtering)
  25547. * this defines the level of anisotropic filtering in the texture.
  25548. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  25549. */
  25550. anisotropicFilteringLevel: number;
  25551. /**
  25552. * Define if the texture is a cube texture or if false a 2d texture.
  25553. */
  25554. isCube: boolean;
  25555. /**
  25556. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  25557. */
  25558. is3D: boolean;
  25559. /**
  25560. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  25561. * HDR texture are usually stored in linear space.
  25562. * This only impacts the PBR and Background materials
  25563. */
  25564. gammaSpace: boolean;
  25565. /**
  25566. * Gets whether or not the texture contains RGBD data.
  25567. */
  25568. readonly isRGBD: boolean;
  25569. /**
  25570. * Is Z inverted in the texture (useful in a cube texture).
  25571. */
  25572. invertZ: boolean;
  25573. /**
  25574. * Are mip maps generated for this texture or not.
  25575. */
  25576. readonly noMipmap: boolean;
  25577. /**
  25578. * @hidden
  25579. */
  25580. lodLevelInAlpha: boolean;
  25581. /**
  25582. * With prefiltered texture, defined the offset used during the prefiltering steps.
  25583. */
  25584. lodGenerationOffset: number;
  25585. /**
  25586. * With prefiltered texture, defined the scale used during the prefiltering steps.
  25587. */
  25588. lodGenerationScale: number;
  25589. /**
  25590. * Define if the texture is a render target.
  25591. */
  25592. isRenderTarget: boolean;
  25593. /**
  25594. * Define the unique id of the texture in the scene.
  25595. */
  25596. readonly uid: string;
  25597. /**
  25598. * Return a string representation of the texture.
  25599. * @returns the texture as a string
  25600. */
  25601. toString(): string;
  25602. /**
  25603. * Get the class name of the texture.
  25604. * @returns "BaseTexture"
  25605. */
  25606. getClassName(): string;
  25607. /**
  25608. * Define the list of animation attached to the texture.
  25609. */
  25610. animations: import("babylonjs/Animations/animation").Animation[];
  25611. /**
  25612. * An event triggered when the texture is disposed.
  25613. */
  25614. onDisposeObservable: Observable<BaseTexture>;
  25615. private _onDisposeObserver;
  25616. /**
  25617. * Callback triggered when the texture has been disposed.
  25618. * Kept for back compatibility, you can use the onDisposeObservable instead.
  25619. */
  25620. onDispose: () => void;
  25621. /**
  25622. * Define the current state of the loading sequence when in delayed load mode.
  25623. */
  25624. delayLoadState: number;
  25625. private _scene;
  25626. /** @hidden */
  25627. _texture: Nullable<InternalTexture>;
  25628. private _uid;
  25629. /**
  25630. * Define if the texture is preventinga material to render or not.
  25631. * If not and the texture is not ready, the engine will use a default black texture instead.
  25632. */
  25633. readonly isBlocking: boolean;
  25634. /**
  25635. * Instantiates a new BaseTexture.
  25636. * Base class of all the textures in babylon.
  25637. * It groups all the common properties the materials, post process, lights... might need
  25638. * in order to make a correct use of the texture.
  25639. * @param scene Define the scene the texture blongs to
  25640. */
  25641. constructor(scene: Nullable<Scene>);
  25642. /**
  25643. * Get the scene the texture belongs to.
  25644. * @returns the scene or null if undefined
  25645. */
  25646. getScene(): Nullable<Scene>;
  25647. /**
  25648. * Get the texture transform matrix used to offset tile the texture for istance.
  25649. * @returns the transformation matrix
  25650. */
  25651. getTextureMatrix(): Matrix;
  25652. /**
  25653. * Get the texture reflection matrix used to rotate/transform the reflection.
  25654. * @returns the reflection matrix
  25655. */
  25656. getReflectionTextureMatrix(): Matrix;
  25657. /**
  25658. * Get the underlying lower level texture from Babylon.
  25659. * @returns the insternal texture
  25660. */
  25661. getInternalTexture(): Nullable<InternalTexture>;
  25662. /**
  25663. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  25664. * @returns true if ready or not blocking
  25665. */
  25666. isReadyOrNotBlocking(): boolean;
  25667. /**
  25668. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  25669. * @returns true if fully ready
  25670. */
  25671. isReady(): boolean;
  25672. private _cachedSize;
  25673. /**
  25674. * Get the size of the texture.
  25675. * @returns the texture size.
  25676. */
  25677. getSize(): ISize;
  25678. /**
  25679. * Get the base size of the texture.
  25680. * It can be different from the size if the texture has been resized for POT for instance
  25681. * @returns the base size
  25682. */
  25683. getBaseSize(): ISize;
  25684. /**
  25685. * Update the sampling mode of the texture.
  25686. * Default is Trilinear mode.
  25687. *
  25688. * | Value | Type | Description |
  25689. * | ----- | ------------------ | ----------- |
  25690. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  25691. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  25692. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  25693. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  25694. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  25695. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  25696. * | 7 | NEAREST_LINEAR | |
  25697. * | 8 | NEAREST_NEAREST | |
  25698. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  25699. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  25700. * | 11 | LINEAR_LINEAR | |
  25701. * | 12 | LINEAR_NEAREST | |
  25702. *
  25703. * > _mag_: magnification filter (close to the viewer)
  25704. * > _min_: minification filter (far from the viewer)
  25705. * > _mip_: filter used between mip map levels
  25706. *@param samplingMode Define the new sampling mode of the texture
  25707. */
  25708. updateSamplingMode(samplingMode: number): void;
  25709. /**
  25710. * Scales the texture if is `canRescale()`
  25711. * @param ratio the resize factor we want to use to rescale
  25712. */
  25713. scale(ratio: number): void;
  25714. /**
  25715. * Get if the texture can rescale.
  25716. */
  25717. readonly canRescale: boolean;
  25718. /** @hidden */
  25719. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  25720. /** @hidden */
  25721. _rebuild(): void;
  25722. /**
  25723. * Triggers the load sequence in delayed load mode.
  25724. */
  25725. delayLoad(): void;
  25726. /**
  25727. * Clones the texture.
  25728. * @returns the cloned texture
  25729. */
  25730. clone(): Nullable<BaseTexture>;
  25731. /**
  25732. * Get the texture underlying type (INT, FLOAT...)
  25733. */
  25734. readonly textureType: number;
  25735. /**
  25736. * Get the texture underlying format (RGB, RGBA...)
  25737. */
  25738. readonly textureFormat: number;
  25739. /**
  25740. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  25741. * This will returns an RGBA array buffer containing either in values (0-255) or
  25742. * float values (0-1) depending of the underlying buffer type.
  25743. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  25744. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  25745. * @param buffer defines a user defined buffer to fill with data (can be null)
  25746. * @returns The Array buffer containing the pixels data.
  25747. */
  25748. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  25749. /**
  25750. * Release and destroy the underlying lower level texture aka internalTexture.
  25751. */
  25752. releaseInternalTexture(): void;
  25753. /**
  25754. * Get the polynomial representation of the texture data.
  25755. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25756. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25757. */
  25758. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25759. /** @hidden */
  25760. readonly _lodTextureHigh: Nullable<BaseTexture>;
  25761. /** @hidden */
  25762. readonly _lodTextureMid: Nullable<BaseTexture>;
  25763. /** @hidden */
  25764. readonly _lodTextureLow: Nullable<BaseTexture>;
  25765. /**
  25766. * Dispose the texture and release its associated resources.
  25767. */
  25768. dispose(): void;
  25769. /**
  25770. * Serialize the texture into a JSON representation that can be parsed later on.
  25771. * @returns the JSON representation of the texture
  25772. */
  25773. serialize(): any;
  25774. /**
  25775. * Helper function to be called back once a list of texture contains only ready textures.
  25776. * @param textures Define the list of textures to wait for
  25777. * @param callback Define the callback triggered once the entire list will be ready
  25778. */
  25779. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  25780. }
  25781. }
  25782. declare module "babylonjs/Materials/uniformBuffer" {
  25783. import { Nullable, FloatArray } from "babylonjs/types";
  25784. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  25785. import { Engine } from "babylonjs/Engines/engine";
  25786. import { Effect } from "babylonjs/Materials/effect";
  25787. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25788. /**
  25789. * Uniform buffer objects.
  25790. *
  25791. * Handles blocks of uniform on the GPU.
  25792. *
  25793. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25794. *
  25795. * For more information, please refer to :
  25796. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25797. */
  25798. export class UniformBuffer {
  25799. private _engine;
  25800. private _buffer;
  25801. private _data;
  25802. private _bufferData;
  25803. private _dynamic?;
  25804. private _uniformLocations;
  25805. private _uniformSizes;
  25806. private _uniformLocationPointer;
  25807. private _needSync;
  25808. private _noUBO;
  25809. private _currentEffect;
  25810. private static _MAX_UNIFORM_SIZE;
  25811. private static _tempBuffer;
  25812. /**
  25813. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  25814. * This is dynamic to allow compat with webgl 1 and 2.
  25815. * You will need to pass the name of the uniform as well as the value.
  25816. */
  25817. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  25818. /**
  25819. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  25820. * This is dynamic to allow compat with webgl 1 and 2.
  25821. * You will need to pass the name of the uniform as well as the value.
  25822. */
  25823. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  25824. /**
  25825. * Lambda to Update a single float in a uniform buffer.
  25826. * This is dynamic to allow compat with webgl 1 and 2.
  25827. * You will need to pass the name of the uniform as well as the value.
  25828. */
  25829. updateFloat: (name: string, x: number) => void;
  25830. /**
  25831. * Lambda to Update a vec2 of float in a uniform buffer.
  25832. * This is dynamic to allow compat with webgl 1 and 2.
  25833. * You will need to pass the name of the uniform as well as the value.
  25834. */
  25835. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  25836. /**
  25837. * Lambda to Update a vec3 of float in a uniform buffer.
  25838. * This is dynamic to allow compat with webgl 1 and 2.
  25839. * You will need to pass the name of the uniform as well as the value.
  25840. */
  25841. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  25842. /**
  25843. * Lambda to Update a vec4 of float in a uniform buffer.
  25844. * This is dynamic to allow compat with webgl 1 and 2.
  25845. * You will need to pass the name of the uniform as well as the value.
  25846. */
  25847. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  25848. /**
  25849. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  25850. * This is dynamic to allow compat with webgl 1 and 2.
  25851. * You will need to pass the name of the uniform as well as the value.
  25852. */
  25853. updateMatrix: (name: string, mat: Matrix) => void;
  25854. /**
  25855. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  25856. * This is dynamic to allow compat with webgl 1 and 2.
  25857. * You will need to pass the name of the uniform as well as the value.
  25858. */
  25859. updateVector3: (name: string, vector: Vector3) => void;
  25860. /**
  25861. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  25862. * This is dynamic to allow compat with webgl 1 and 2.
  25863. * You will need to pass the name of the uniform as well as the value.
  25864. */
  25865. updateVector4: (name: string, vector: Vector4) => void;
  25866. /**
  25867. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  25868. * This is dynamic to allow compat with webgl 1 and 2.
  25869. * You will need to pass the name of the uniform as well as the value.
  25870. */
  25871. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  25872. /**
  25873. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  25874. * This is dynamic to allow compat with webgl 1 and 2.
  25875. * You will need to pass the name of the uniform as well as the value.
  25876. */
  25877. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  25878. /**
  25879. * Instantiates a new Uniform buffer objects.
  25880. *
  25881. * Handles blocks of uniform on the GPU.
  25882. *
  25883. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25884. *
  25885. * For more information, please refer to :
  25886. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25887. * @param engine Define the engine the buffer is associated with
  25888. * @param data Define the data contained in the buffer
  25889. * @param dynamic Define if the buffer is updatable
  25890. */
  25891. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  25892. /**
  25893. * Indicates if the buffer is using the WebGL2 UBO implementation,
  25894. * or just falling back on setUniformXXX calls.
  25895. */
  25896. readonly useUbo: boolean;
  25897. /**
  25898. * Indicates if the WebGL underlying uniform buffer is in sync
  25899. * with the javascript cache data.
  25900. */
  25901. readonly isSync: boolean;
  25902. /**
  25903. * Indicates if the WebGL underlying uniform buffer is dynamic.
  25904. * Also, a dynamic UniformBuffer will disable cache verification and always
  25905. * update the underlying WebGL uniform buffer to the GPU.
  25906. * @returns if Dynamic, otherwise false
  25907. */
  25908. isDynamic(): boolean;
  25909. /**
  25910. * The data cache on JS side.
  25911. * @returns the underlying data as a float array
  25912. */
  25913. getData(): Float32Array;
  25914. /**
  25915. * The underlying WebGL Uniform buffer.
  25916. * @returns the webgl buffer
  25917. */
  25918. getBuffer(): Nullable<WebGLBuffer>;
  25919. /**
  25920. * std140 layout specifies how to align data within an UBO structure.
  25921. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  25922. * for specs.
  25923. */
  25924. private _fillAlignment;
  25925. /**
  25926. * Adds an uniform in the buffer.
  25927. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  25928. * for the layout to be correct !
  25929. * @param name Name of the uniform, as used in the uniform block in the shader.
  25930. * @param size Data size, or data directly.
  25931. */
  25932. addUniform(name: string, size: number | number[]): void;
  25933. /**
  25934. * Adds a Matrix 4x4 to the uniform buffer.
  25935. * @param name Name of the uniform, as used in the uniform block in the shader.
  25936. * @param mat A 4x4 matrix.
  25937. */
  25938. addMatrix(name: string, mat: Matrix): void;
  25939. /**
  25940. * Adds a vec2 to the uniform buffer.
  25941. * @param name Name of the uniform, as used in the uniform block in the shader.
  25942. * @param x Define the x component value of the vec2
  25943. * @param y Define the y component value of the vec2
  25944. */
  25945. addFloat2(name: string, x: number, y: number): void;
  25946. /**
  25947. * Adds a vec3 to the uniform buffer.
  25948. * @param name Name of the uniform, as used in the uniform block in the shader.
  25949. * @param x Define the x component value of the vec3
  25950. * @param y Define the y component value of the vec3
  25951. * @param z Define the z component value of the vec3
  25952. */
  25953. addFloat3(name: string, x: number, y: number, z: number): void;
  25954. /**
  25955. * Adds a vec3 to the uniform buffer.
  25956. * @param name Name of the uniform, as used in the uniform block in the shader.
  25957. * @param color Define the vec3 from a Color
  25958. */
  25959. addColor3(name: string, color: Color3): void;
  25960. /**
  25961. * Adds a vec4 to the uniform buffer.
  25962. * @param name Name of the uniform, as used in the uniform block in the shader.
  25963. * @param color Define the rgb components from a Color
  25964. * @param alpha Define the a component of the vec4
  25965. */
  25966. addColor4(name: string, color: Color3, alpha: number): void;
  25967. /**
  25968. * Adds a vec3 to the uniform buffer.
  25969. * @param name Name of the uniform, as used in the uniform block in the shader.
  25970. * @param vector Define the vec3 components from a Vector
  25971. */
  25972. addVector3(name: string, vector: Vector3): void;
  25973. /**
  25974. * Adds a Matrix 3x3 to the uniform buffer.
  25975. * @param name Name of the uniform, as used in the uniform block in the shader.
  25976. */
  25977. addMatrix3x3(name: string): void;
  25978. /**
  25979. * Adds a Matrix 2x2 to the uniform buffer.
  25980. * @param name Name of the uniform, as used in the uniform block in the shader.
  25981. */
  25982. addMatrix2x2(name: string): void;
  25983. /**
  25984. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  25985. */
  25986. create(): void;
  25987. /** @hidden */
  25988. _rebuild(): void;
  25989. /**
  25990. * Updates the WebGL Uniform Buffer on the GPU.
  25991. * If the `dynamic` flag is set to true, no cache comparison is done.
  25992. * Otherwise, the buffer will be updated only if the cache differs.
  25993. */
  25994. update(): void;
  25995. /**
  25996. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  25997. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  25998. * @param data Define the flattened data
  25999. * @param size Define the size of the data.
  26000. */
  26001. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26002. private _updateMatrix3x3ForUniform;
  26003. private _updateMatrix3x3ForEffect;
  26004. private _updateMatrix2x2ForEffect;
  26005. private _updateMatrix2x2ForUniform;
  26006. private _updateFloatForEffect;
  26007. private _updateFloatForUniform;
  26008. private _updateFloat2ForEffect;
  26009. private _updateFloat2ForUniform;
  26010. private _updateFloat3ForEffect;
  26011. private _updateFloat3ForUniform;
  26012. private _updateFloat4ForEffect;
  26013. private _updateFloat4ForUniform;
  26014. private _updateMatrixForEffect;
  26015. private _updateMatrixForUniform;
  26016. private _updateVector3ForEffect;
  26017. private _updateVector3ForUniform;
  26018. private _updateVector4ForEffect;
  26019. private _updateVector4ForUniform;
  26020. private _updateColor3ForEffect;
  26021. private _updateColor3ForUniform;
  26022. private _updateColor4ForEffect;
  26023. private _updateColor4ForUniform;
  26024. /**
  26025. * Sets a sampler uniform on the effect.
  26026. * @param name Define the name of the sampler.
  26027. * @param texture Define the texture to set in the sampler
  26028. */
  26029. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26030. /**
  26031. * Directly updates the value of the uniform in the cache AND on the GPU.
  26032. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26033. * @param data Define the flattened data
  26034. */
  26035. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26036. /**
  26037. * Binds this uniform buffer to an effect.
  26038. * @param effect Define the effect to bind the buffer to
  26039. * @param name Name of the uniform block in the shader.
  26040. */
  26041. bindToEffect(effect: Effect, name: string): void;
  26042. /**
  26043. * Disposes the uniform buffer.
  26044. */
  26045. dispose(): void;
  26046. }
  26047. }
  26048. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  26049. import { Nullable } from "babylonjs/types";
  26050. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26051. /**
  26052. * This represents the required contract to create a new type of texture loader.
  26053. */
  26054. export interface IInternalTextureLoader {
  26055. /**
  26056. * Defines wether the loader supports cascade loading the different faces.
  26057. */
  26058. supportCascades: boolean;
  26059. /**
  26060. * This returns if the loader support the current file information.
  26061. * @param extension defines the file extension of the file being loaded
  26062. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26063. * @param fallback defines the fallback internal texture if any
  26064. * @param isBase64 defines whether the texture is encoded as a base64
  26065. * @param isBuffer defines whether the texture data are stored as a buffer
  26066. * @returns true if the loader can load the specified file
  26067. */
  26068. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  26069. /**
  26070. * Transform the url before loading if required.
  26071. * @param rootUrl the url of the texture
  26072. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26073. * @returns the transformed texture
  26074. */
  26075. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  26076. /**
  26077. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  26078. * @param rootUrl the url of the texture
  26079. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26080. * @returns the fallback texture
  26081. */
  26082. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  26083. /**
  26084. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  26085. * @param data contains the texture data
  26086. * @param texture defines the BabylonJS internal texture
  26087. * @param createPolynomials will be true if polynomials have been requested
  26088. * @param onLoad defines the callback to trigger once the texture is ready
  26089. * @param onError defines the callback to trigger in case of error
  26090. */
  26091. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  26092. /**
  26093. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  26094. * @param data contains the texture data
  26095. * @param texture defines the BabylonJS internal texture
  26096. * @param callback defines the method to call once ready to upload
  26097. */
  26098. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  26099. }
  26100. }
  26101. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  26102. import { Scene } from "babylonjs/scene";
  26103. import { Engine } from "babylonjs/Engines/engine";
  26104. import { Texture } from "babylonjs/Materials/Textures/texture";
  26105. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26106. /**
  26107. * Creation options of the multi render target texture.
  26108. */
  26109. export interface IMultiRenderTargetOptions {
  26110. /**
  26111. * Define if the texture needs to create mip maps after render.
  26112. */
  26113. generateMipMaps?: boolean;
  26114. /**
  26115. * Define the types of all the draw buffers we want to create
  26116. */
  26117. types?: number[];
  26118. /**
  26119. * Define the sampling modes of all the draw buffers we want to create
  26120. */
  26121. samplingModes?: number[];
  26122. /**
  26123. * Define if a depth buffer is required
  26124. */
  26125. generateDepthBuffer?: boolean;
  26126. /**
  26127. * Define if a stencil buffer is required
  26128. */
  26129. generateStencilBuffer?: boolean;
  26130. /**
  26131. * Define if a depth texture is required instead of a depth buffer
  26132. */
  26133. generateDepthTexture?: boolean;
  26134. /**
  26135. * Define the number of desired draw buffers
  26136. */
  26137. textureCount?: number;
  26138. /**
  26139. * Define if aspect ratio should be adapted to the texture or stay the scene one
  26140. */
  26141. doNotChangeAspectRatio?: boolean;
  26142. /**
  26143. * Define the default type of the buffers we are creating
  26144. */
  26145. defaultType?: number;
  26146. }
  26147. /**
  26148. * A multi render target, like a render target provides the ability to render to a texture.
  26149. * Unlike the render target, it can render to several draw buffers in one draw.
  26150. * This is specially interesting in deferred rendering or for any effects requiring more than
  26151. * just one color from a single pass.
  26152. */
  26153. export class MultiRenderTarget extends RenderTargetTexture {
  26154. private _internalTextures;
  26155. private _textures;
  26156. private _multiRenderTargetOptions;
  26157. /**
  26158. * Get if draw buffers are currently supported by the used hardware and browser.
  26159. */
  26160. readonly isSupported: boolean;
  26161. /**
  26162. * Get the list of textures generated by the multi render target.
  26163. */
  26164. readonly textures: Texture[];
  26165. /**
  26166. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  26167. */
  26168. readonly depthTexture: Texture;
  26169. /**
  26170. * Set the wrapping mode on U of all the textures we are rendering to.
  26171. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26172. */
  26173. wrapU: number;
  26174. /**
  26175. * Set the wrapping mode on V of all the textures we are rendering to.
  26176. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26177. */
  26178. wrapV: number;
  26179. /**
  26180. * Instantiate a new multi render target texture.
  26181. * A multi render target, like a render target provides the ability to render to a texture.
  26182. * Unlike the render target, it can render to several draw buffers in one draw.
  26183. * This is specially interesting in deferred rendering or for any effects requiring more than
  26184. * just one color from a single pass.
  26185. * @param name Define the name of the texture
  26186. * @param size Define the size of the buffers to render to
  26187. * @param count Define the number of target we are rendering into
  26188. * @param scene Define the scene the texture belongs to
  26189. * @param options Define the options used to create the multi render target
  26190. */
  26191. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  26192. /** @hidden */
  26193. _rebuild(): void;
  26194. private _createInternalTextures;
  26195. private _createTextures;
  26196. /**
  26197. * Define the number of samples used if MSAA is enabled.
  26198. */
  26199. samples: number;
  26200. /**
  26201. * Resize all the textures in the multi render target.
  26202. * Be carrefull as it will recreate all the data in the new texture.
  26203. * @param size Define the new size
  26204. */
  26205. resize(size: any): void;
  26206. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  26207. /**
  26208. * Dispose the render targets and their associated resources
  26209. */
  26210. dispose(): void;
  26211. /**
  26212. * Release all the underlying texture used as draw buffers.
  26213. */
  26214. releaseInternalTextures(): void;
  26215. }
  26216. }
  26217. declare module "babylonjs/Audio/analyser" {
  26218. import { Scene } from "babylonjs/scene";
  26219. /**
  26220. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26221. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26222. */
  26223. export class Analyser {
  26224. /**
  26225. * Gets or sets the smoothing
  26226. * @ignorenaming
  26227. */
  26228. SMOOTHING: number;
  26229. /**
  26230. * Gets or sets the FFT table size
  26231. * @ignorenaming
  26232. */
  26233. FFT_SIZE: number;
  26234. /**
  26235. * Gets or sets the bar graph amplitude
  26236. * @ignorenaming
  26237. */
  26238. BARGRAPHAMPLITUDE: number;
  26239. /**
  26240. * Gets or sets the position of the debug canvas
  26241. * @ignorenaming
  26242. */
  26243. DEBUGCANVASPOS: {
  26244. x: number;
  26245. y: number;
  26246. };
  26247. /**
  26248. * Gets or sets the debug canvas size
  26249. * @ignorenaming
  26250. */
  26251. DEBUGCANVASSIZE: {
  26252. width: number;
  26253. height: number;
  26254. };
  26255. private _byteFreqs;
  26256. private _byteTime;
  26257. private _floatFreqs;
  26258. private _webAudioAnalyser;
  26259. private _debugCanvas;
  26260. private _debugCanvasContext;
  26261. private _scene;
  26262. private _registerFunc;
  26263. private _audioEngine;
  26264. /**
  26265. * Creates a new analyser
  26266. * @param scene defines hosting scene
  26267. */
  26268. constructor(scene: Scene);
  26269. /**
  26270. * Get the number of data values you will have to play with for the visualization
  26271. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26272. * @returns a number
  26273. */
  26274. getFrequencyBinCount(): number;
  26275. /**
  26276. * Gets the current frequency data as a byte array
  26277. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26278. * @returns a Uint8Array
  26279. */
  26280. getByteFrequencyData(): Uint8Array;
  26281. /**
  26282. * Gets the current waveform as a byte array
  26283. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26284. * @returns a Uint8Array
  26285. */
  26286. getByteTimeDomainData(): Uint8Array;
  26287. /**
  26288. * Gets the current frequency data as a float array
  26289. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26290. * @returns a Float32Array
  26291. */
  26292. getFloatFrequencyData(): Float32Array;
  26293. /**
  26294. * Renders the debug canvas
  26295. */
  26296. drawDebugCanvas(): void;
  26297. /**
  26298. * Stops rendering the debug canvas and removes it
  26299. */
  26300. stopDebugCanvas(): void;
  26301. /**
  26302. * Connects two audio nodes
  26303. * @param inputAudioNode defines first node to connect
  26304. * @param outputAudioNode defines second node to connect
  26305. */
  26306. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26307. /**
  26308. * Releases all associated resources
  26309. */
  26310. dispose(): void;
  26311. }
  26312. }
  26313. declare module "babylonjs/Audio/audioEngine" {
  26314. import { IDisposable } from "babylonjs/scene";
  26315. import { Analyser } from "babylonjs/Audio/analyser";
  26316. import { Nullable } from "babylonjs/types";
  26317. import { Observable } from "babylonjs/Misc/observable";
  26318. /**
  26319. * This represents an audio engine and it is responsible
  26320. * to play, synchronize and analyse sounds throughout the application.
  26321. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26322. */
  26323. export interface IAudioEngine extends IDisposable {
  26324. /**
  26325. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26326. */
  26327. readonly canUseWebAudio: boolean;
  26328. /**
  26329. * Gets the current AudioContext if available.
  26330. */
  26331. readonly audioContext: Nullable<AudioContext>;
  26332. /**
  26333. * The master gain node defines the global audio volume of your audio engine.
  26334. */
  26335. readonly masterGain: GainNode;
  26336. /**
  26337. * Gets whether or not mp3 are supported by your browser.
  26338. */
  26339. readonly isMP3supported: boolean;
  26340. /**
  26341. * Gets whether or not ogg are supported by your browser.
  26342. */
  26343. readonly isOGGsupported: boolean;
  26344. /**
  26345. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26346. * @ignoreNaming
  26347. */
  26348. WarnedWebAudioUnsupported: boolean;
  26349. /**
  26350. * Defines if the audio engine relies on a custom unlocked button.
  26351. * In this case, the embedded button will not be displayed.
  26352. */
  26353. useCustomUnlockedButton: boolean;
  26354. /**
  26355. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26356. */
  26357. readonly unlocked: boolean;
  26358. /**
  26359. * Event raised when audio has been unlocked on the browser.
  26360. */
  26361. onAudioUnlockedObservable: Observable<AudioEngine>;
  26362. /**
  26363. * Event raised when audio has been locked on the browser.
  26364. */
  26365. onAudioLockedObservable: Observable<AudioEngine>;
  26366. /**
  26367. * Flags the audio engine in Locked state.
  26368. * This happens due to new browser policies preventing audio to autoplay.
  26369. */
  26370. lock(): void;
  26371. /**
  26372. * Unlocks the audio engine once a user action has been done on the dom.
  26373. * This is helpful to resume play once browser policies have been satisfied.
  26374. */
  26375. unlock(): void;
  26376. }
  26377. /**
  26378. * This represents the default audio engine used in babylon.
  26379. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26380. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26381. */
  26382. export class AudioEngine implements IAudioEngine {
  26383. private _audioContext;
  26384. private _audioContextInitialized;
  26385. private _muteButton;
  26386. private _hostElement;
  26387. /**
  26388. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26389. */
  26390. canUseWebAudio: boolean;
  26391. /**
  26392. * The master gain node defines the global audio volume of your audio engine.
  26393. */
  26394. masterGain: GainNode;
  26395. /**
  26396. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26397. * @ignoreNaming
  26398. */
  26399. WarnedWebAudioUnsupported: boolean;
  26400. /**
  26401. * Gets whether or not mp3 are supported by your browser.
  26402. */
  26403. isMP3supported: boolean;
  26404. /**
  26405. * Gets whether or not ogg are supported by your browser.
  26406. */
  26407. isOGGsupported: boolean;
  26408. /**
  26409. * Gets whether audio has been unlocked on the device.
  26410. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26411. * a user interaction has happened.
  26412. */
  26413. unlocked: boolean;
  26414. /**
  26415. * Defines if the audio engine relies on a custom unlocked button.
  26416. * In this case, the embedded button will not be displayed.
  26417. */
  26418. useCustomUnlockedButton: boolean;
  26419. /**
  26420. * Event raised when audio has been unlocked on the browser.
  26421. */
  26422. onAudioUnlockedObservable: Observable<AudioEngine>;
  26423. /**
  26424. * Event raised when audio has been locked on the browser.
  26425. */
  26426. onAudioLockedObservable: Observable<AudioEngine>;
  26427. /**
  26428. * Gets the current AudioContext if available.
  26429. */
  26430. readonly audioContext: Nullable<AudioContext>;
  26431. private _connectedAnalyser;
  26432. /**
  26433. * Instantiates a new audio engine.
  26434. *
  26435. * There should be only one per page as some browsers restrict the number
  26436. * of audio contexts you can create.
  26437. * @param hostElement defines the host element where to display the mute icon if necessary
  26438. */
  26439. constructor(hostElement?: Nullable<HTMLElement>);
  26440. /**
  26441. * Flags the audio engine in Locked state.
  26442. * This happens due to new browser policies preventing audio to autoplay.
  26443. */
  26444. lock(): void;
  26445. /**
  26446. * Unlocks the audio engine once a user action has been done on the dom.
  26447. * This is helpful to resume play once browser policies have been satisfied.
  26448. */
  26449. unlock(): void;
  26450. private _resumeAudioContext;
  26451. private _initializeAudioContext;
  26452. private _tryToRun;
  26453. private _triggerRunningState;
  26454. private _triggerSuspendedState;
  26455. private _displayMuteButton;
  26456. private _moveButtonToTopLeft;
  26457. private _onResize;
  26458. private _hideMuteButton;
  26459. /**
  26460. * Destroy and release the resources associated with the audio ccontext.
  26461. */
  26462. dispose(): void;
  26463. /**
  26464. * Gets the global volume sets on the master gain.
  26465. * @returns the global volume if set or -1 otherwise
  26466. */
  26467. getGlobalVolume(): number;
  26468. /**
  26469. * Sets the global volume of your experience (sets on the master gain).
  26470. * @param newVolume Defines the new global volume of the application
  26471. */
  26472. setGlobalVolume(newVolume: number): void;
  26473. /**
  26474. * Connect the audio engine to an audio analyser allowing some amazing
  26475. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26476. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26477. * @param analyser The analyser to connect to the engine
  26478. */
  26479. connectToAnalyser(analyser: Analyser): void;
  26480. }
  26481. }
  26482. declare module "babylonjs/Loading/loadingScreen" {
  26483. /**
  26484. * Interface used to present a loading screen while loading a scene
  26485. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26486. */
  26487. export interface ILoadingScreen {
  26488. /**
  26489. * Function called to display the loading screen
  26490. */
  26491. displayLoadingUI: () => void;
  26492. /**
  26493. * Function called to hide the loading screen
  26494. */
  26495. hideLoadingUI: () => void;
  26496. /**
  26497. * Gets or sets the color to use for the background
  26498. */
  26499. loadingUIBackgroundColor: string;
  26500. /**
  26501. * Gets or sets the text to display while loading
  26502. */
  26503. loadingUIText: string;
  26504. }
  26505. /**
  26506. * Class used for the default loading screen
  26507. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26508. */
  26509. export class DefaultLoadingScreen implements ILoadingScreen {
  26510. private _renderingCanvas;
  26511. private _loadingText;
  26512. private _loadingDivBackgroundColor;
  26513. private _loadingDiv;
  26514. private _loadingTextDiv;
  26515. /**
  26516. * Creates a new default loading screen
  26517. * @param _renderingCanvas defines the canvas used to render the scene
  26518. * @param _loadingText defines the default text to display
  26519. * @param _loadingDivBackgroundColor defines the default background color
  26520. */
  26521. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26522. /**
  26523. * Function called to display the loading screen
  26524. */
  26525. displayLoadingUI(): void;
  26526. /**
  26527. * Function called to hide the loading screen
  26528. */
  26529. hideLoadingUI(): void;
  26530. /**
  26531. * Gets or sets the text to display while loading
  26532. */
  26533. loadingUIText: string;
  26534. /**
  26535. * Gets or sets the color to use for the background
  26536. */
  26537. loadingUIBackgroundColor: string;
  26538. private _resizeLoadingUI;
  26539. }
  26540. }
  26541. declare module "babylonjs/Materials/Textures/videoTexture" {
  26542. import { Observable } from "babylonjs/Misc/observable";
  26543. import { Nullable } from "babylonjs/types";
  26544. import { Scene } from "babylonjs/scene";
  26545. import { Texture } from "babylonjs/Materials/Textures/texture";
  26546. /**
  26547. * Settings for finer control over video usage
  26548. */
  26549. export interface VideoTextureSettings {
  26550. /**
  26551. * Applies `autoplay` to video, if specified
  26552. */
  26553. autoPlay?: boolean;
  26554. /**
  26555. * Applies `loop` to video, if specified
  26556. */
  26557. loop?: boolean;
  26558. /**
  26559. * Automatically updates internal texture from video at every frame in the render loop
  26560. */
  26561. autoUpdateTexture: boolean;
  26562. /**
  26563. * Image src displayed during the video loading or until the user interacts with the video.
  26564. */
  26565. poster?: string;
  26566. }
  26567. /**
  26568. * If you want to display a video in your scene, this is the special texture for that.
  26569. * This special texture works similar to other textures, with the exception of a few parameters.
  26570. * @see https://doc.babylonjs.com/how_to/video_texture
  26571. */
  26572. export class VideoTexture extends Texture {
  26573. /**
  26574. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26575. */
  26576. readonly autoUpdateTexture: boolean;
  26577. /**
  26578. * The video instance used by the texture internally
  26579. */
  26580. readonly video: HTMLVideoElement;
  26581. private _onUserActionRequestedObservable;
  26582. /**
  26583. * Event triggerd when a dom action is required by the user to play the video.
  26584. * This happens due to recent changes in browser policies preventing video to auto start.
  26585. */
  26586. readonly onUserActionRequestedObservable: Observable<Texture>;
  26587. private _generateMipMaps;
  26588. private _engine;
  26589. private _stillImageCaptured;
  26590. private _displayingPosterTexture;
  26591. private _settings;
  26592. private _createInternalTextureOnEvent;
  26593. /**
  26594. * Creates a video texture.
  26595. * If you want to display a video in your scene, this is the special texture for that.
  26596. * This special texture works similar to other textures, with the exception of a few parameters.
  26597. * @see https://doc.babylonjs.com/how_to/video_texture
  26598. * @param name optional name, will detect from video source, if not defined
  26599. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26600. * @param scene is obviously the current scene.
  26601. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26602. * @param invertY is false by default but can be used to invert video on Y axis
  26603. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26604. * @param settings allows finer control over video usage
  26605. */
  26606. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26607. private _getName;
  26608. private _getVideo;
  26609. private _createInternalTexture;
  26610. private reset;
  26611. /**
  26612. * @hidden Internal method to initiate `update`.
  26613. */
  26614. _rebuild(): void;
  26615. /**
  26616. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  26617. */
  26618. update(): void;
  26619. /**
  26620. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  26621. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  26622. */
  26623. updateTexture(isVisible: boolean): void;
  26624. protected _updateInternalTexture: () => void;
  26625. /**
  26626. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  26627. * @param url New url.
  26628. */
  26629. updateURL(url: string): void;
  26630. /**
  26631. * Dispose the texture and release its associated resources.
  26632. */
  26633. dispose(): void;
  26634. /**
  26635. * Creates a video texture straight from a stream.
  26636. * @param scene Define the scene the texture should be created in
  26637. * @param stream Define the stream the texture should be created from
  26638. * @returns The created video texture as a promise
  26639. */
  26640. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  26641. /**
  26642. * Creates a video texture straight from your WebCam video feed.
  26643. * @param scene Define the scene the texture should be created in
  26644. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26645. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26646. * @returns The created video texture as a promise
  26647. */
  26648. static CreateFromWebCamAsync(scene: Scene, constraints: {
  26649. minWidth: number;
  26650. maxWidth: number;
  26651. minHeight: number;
  26652. maxHeight: number;
  26653. deviceId: string;
  26654. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  26655. /**
  26656. * Creates a video texture straight from your WebCam video feed.
  26657. * @param scene Define the scene the texture should be created in
  26658. * @param onReady Define a callback to triggered once the texture will be ready
  26659. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26660. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26661. */
  26662. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  26663. minWidth: number;
  26664. maxWidth: number;
  26665. minHeight: number;
  26666. maxHeight: number;
  26667. deviceId: string;
  26668. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  26669. }
  26670. }
  26671. declare module "babylonjs/Engines/engine" {
  26672. import { Observable } from "babylonjs/Misc/observable";
  26673. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  26674. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  26675. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  26676. import { Camera } from "babylonjs/Cameras/camera";
  26677. import { Scene } from "babylonjs/scene";
  26678. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  26679. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  26680. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  26681. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  26682. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  26683. import { Material } from "babylonjs/Materials/material";
  26684. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  26685. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26686. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26687. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  26688. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  26689. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  26690. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  26691. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  26692. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  26693. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26694. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26695. /**
  26696. * Interface for attribute information associated with buffer instanciation
  26697. */
  26698. export class InstancingAttributeInfo {
  26699. /**
  26700. * Index/offset of the attribute in the vertex shader
  26701. */
  26702. index: number;
  26703. /**
  26704. * size of the attribute, 1, 2, 3 or 4
  26705. */
  26706. attributeSize: number;
  26707. /**
  26708. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  26709. * default is FLOAT
  26710. */
  26711. attribyteType: number;
  26712. /**
  26713. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  26714. */
  26715. normalized: boolean;
  26716. /**
  26717. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  26718. */
  26719. offset: number;
  26720. /**
  26721. * Name of the GLSL attribute, for debugging purpose only
  26722. */
  26723. attributeName: string;
  26724. }
  26725. /**
  26726. * Define options used to create a depth texture
  26727. */
  26728. export class DepthTextureCreationOptions {
  26729. /** Specifies whether or not a stencil should be allocated in the texture */
  26730. generateStencil?: boolean;
  26731. /** Specifies whether or not bilinear filtering is enable on the texture */
  26732. bilinearFiltering?: boolean;
  26733. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  26734. comparisonFunction?: number;
  26735. /** Specifies if the created texture is a cube texture */
  26736. isCube?: boolean;
  26737. }
  26738. /**
  26739. * Class used to describe the capabilities of the engine relatively to the current browser
  26740. */
  26741. export class EngineCapabilities {
  26742. /** Maximum textures units per fragment shader */
  26743. maxTexturesImageUnits: number;
  26744. /** Maximum texture units per vertex shader */
  26745. maxVertexTextureImageUnits: number;
  26746. /** Maximum textures units in the entire pipeline */
  26747. maxCombinedTexturesImageUnits: number;
  26748. /** Maximum texture size */
  26749. maxTextureSize: number;
  26750. /** Maximum cube texture size */
  26751. maxCubemapTextureSize: number;
  26752. /** Maximum render texture size */
  26753. maxRenderTextureSize: number;
  26754. /** Maximum number of vertex attributes */
  26755. maxVertexAttribs: number;
  26756. /** Maximum number of varyings */
  26757. maxVaryingVectors: number;
  26758. /** Maximum number of uniforms per vertex shader */
  26759. maxVertexUniformVectors: number;
  26760. /** Maximum number of uniforms per fragment shader */
  26761. maxFragmentUniformVectors: number;
  26762. /** Defines if standard derivates (dx/dy) are supported */
  26763. standardDerivatives: boolean;
  26764. /** Defines if s3tc texture compression is supported */
  26765. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  26766. /** Defines if pvrtc texture compression is supported */
  26767. pvrtc: any;
  26768. /** Defines if etc1 texture compression is supported */
  26769. etc1: any;
  26770. /** Defines if etc2 texture compression is supported */
  26771. etc2: any;
  26772. /** Defines if astc texture compression is supported */
  26773. astc: any;
  26774. /** Defines if float textures are supported */
  26775. textureFloat: boolean;
  26776. /** Defines if vertex array objects are supported */
  26777. vertexArrayObject: boolean;
  26778. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  26779. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  26780. /** Gets the maximum level of anisotropy supported */
  26781. maxAnisotropy: number;
  26782. /** Defines if instancing is supported */
  26783. instancedArrays: boolean;
  26784. /** Defines if 32 bits indices are supported */
  26785. uintIndices: boolean;
  26786. /** Defines if high precision shaders are supported */
  26787. highPrecisionShaderSupported: boolean;
  26788. /** Defines if depth reading in the fragment shader is supported */
  26789. fragmentDepthSupported: boolean;
  26790. /** Defines if float texture linear filtering is supported*/
  26791. textureFloatLinearFiltering: boolean;
  26792. /** Defines if rendering to float textures is supported */
  26793. textureFloatRender: boolean;
  26794. /** Defines if half float textures are supported*/
  26795. textureHalfFloat: boolean;
  26796. /** Defines if half float texture linear filtering is supported*/
  26797. textureHalfFloatLinearFiltering: boolean;
  26798. /** Defines if rendering to half float textures is supported */
  26799. textureHalfFloatRender: boolean;
  26800. /** Defines if textureLOD shader command is supported */
  26801. textureLOD: boolean;
  26802. /** Defines if draw buffers extension is supported */
  26803. drawBuffersExtension: boolean;
  26804. /** Defines if depth textures are supported */
  26805. depthTextureExtension: boolean;
  26806. /** Defines if float color buffer are supported */
  26807. colorBufferFloat: boolean;
  26808. /** Gets disjoint timer query extension (null if not supported) */
  26809. timerQuery: EXT_disjoint_timer_query;
  26810. /** Defines if timestamp can be used with timer query */
  26811. canUseTimestampForTimerQuery: boolean;
  26812. /** Function used to let the system compiles shaders in background */
  26813. parallelShaderCompile: {
  26814. MAX_SHADER_COMPILER_THREADS_KHR: number;
  26815. maxShaderCompilerThreadsKHR: (thread: number) => void;
  26816. COMPLETION_STATUS_KHR: number;
  26817. };
  26818. }
  26819. /** Interface defining initialization parameters for Engine class */
  26820. export interface EngineOptions extends WebGLContextAttributes {
  26821. /**
  26822. * Defines if the engine should no exceed a specified device ratio
  26823. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  26824. */
  26825. limitDeviceRatio?: number;
  26826. /**
  26827. * Defines if webvr should be enabled automatically
  26828. * @see http://doc.babylonjs.com/how_to/webvr_camera
  26829. */
  26830. autoEnableWebVR?: boolean;
  26831. /**
  26832. * Defines if webgl2 should be turned off even if supported
  26833. * @see http://doc.babylonjs.com/features/webgl2
  26834. */
  26835. disableWebGL2Support?: boolean;
  26836. /**
  26837. * Defines if webaudio should be initialized as well
  26838. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26839. */
  26840. audioEngine?: boolean;
  26841. /**
  26842. * Defines if animations should run using a deterministic lock step
  26843. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26844. */
  26845. deterministicLockstep?: boolean;
  26846. /** Defines the maximum steps to use with deterministic lock step mode */
  26847. lockstepMaxSteps?: number;
  26848. /**
  26849. * Defines that engine should ignore context lost events
  26850. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  26851. */
  26852. doNotHandleContextLost?: boolean;
  26853. /**
  26854. * Defines that engine should ignore modifying touch action attribute and style
  26855. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  26856. */
  26857. doNotHandleTouchAction?: boolean;
  26858. }
  26859. /**
  26860. * Defines the interface used by display changed events
  26861. */
  26862. export interface IDisplayChangedEventArgs {
  26863. /** Gets the vrDisplay object (if any) */
  26864. vrDisplay: Nullable<any>;
  26865. /** Gets a boolean indicating if webVR is supported */
  26866. vrSupported: boolean;
  26867. }
  26868. /**
  26869. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  26870. */
  26871. export class Engine {
  26872. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  26873. static ExceptionList: ({
  26874. key: string;
  26875. capture: string;
  26876. captureConstraint: number;
  26877. targets: string[];
  26878. } | {
  26879. key: string;
  26880. capture: null;
  26881. captureConstraint: null;
  26882. targets: string[];
  26883. })[];
  26884. /** Gets the list of created engines */
  26885. static readonly Instances: Engine[];
  26886. /**
  26887. * Gets the latest created engine
  26888. */
  26889. static readonly LastCreatedEngine: Nullable<Engine>;
  26890. /**
  26891. * Gets the latest created scene
  26892. */
  26893. static readonly LastCreatedScene: Nullable<Scene>;
  26894. /**
  26895. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  26896. * @param flag defines which part of the materials must be marked as dirty
  26897. * @param predicate defines a predicate used to filter which materials should be affected
  26898. */
  26899. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  26900. /**
  26901. * Hidden
  26902. */
  26903. static _TextureLoaders: IInternalTextureLoader[];
  26904. /** Defines that alpha blending is disabled */
  26905. static readonly ALPHA_DISABLE: number;
  26906. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  26907. static readonly ALPHA_ADD: number;
  26908. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  26909. static readonly ALPHA_COMBINE: number;
  26910. /** Defines that alpha blending to DEST - SRC * DEST */
  26911. static readonly ALPHA_SUBTRACT: number;
  26912. /** Defines that alpha blending to SRC * DEST */
  26913. static readonly ALPHA_MULTIPLY: number;
  26914. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  26915. static readonly ALPHA_MAXIMIZED: number;
  26916. /** Defines that alpha blending to SRC + DEST */
  26917. static readonly ALPHA_ONEONE: number;
  26918. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  26919. static readonly ALPHA_PREMULTIPLIED: number;
  26920. /**
  26921. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  26922. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  26923. */
  26924. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  26925. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  26926. static readonly ALPHA_INTERPOLATE: number;
  26927. /**
  26928. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  26929. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  26930. */
  26931. static readonly ALPHA_SCREENMODE: number;
  26932. /** Defines that the ressource is not delayed*/
  26933. static readonly DELAYLOADSTATE_NONE: number;
  26934. /** Defines that the ressource was successfully delay loaded */
  26935. static readonly DELAYLOADSTATE_LOADED: number;
  26936. /** Defines that the ressource is currently delay loading */
  26937. static readonly DELAYLOADSTATE_LOADING: number;
  26938. /** Defines that the ressource is delayed and has not started loading */
  26939. static readonly DELAYLOADSTATE_NOTLOADED: number;
  26940. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  26941. static readonly NEVER: number;
  26942. /** 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 */
  26943. static readonly ALWAYS: number;
  26944. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  26945. static readonly LESS: number;
  26946. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  26947. static readonly EQUAL: number;
  26948. /** 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 */
  26949. static readonly LEQUAL: number;
  26950. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  26951. static readonly GREATER: number;
  26952. /** 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 */
  26953. static readonly GEQUAL: number;
  26954. /** 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 */
  26955. static readonly NOTEQUAL: number;
  26956. /** Passed to stencilOperation to specify that stencil value must be kept */
  26957. static readonly KEEP: number;
  26958. /** Passed to stencilOperation to specify that stencil value must be replaced */
  26959. static readonly REPLACE: number;
  26960. /** Passed to stencilOperation to specify that stencil value must be incremented */
  26961. static readonly INCR: number;
  26962. /** Passed to stencilOperation to specify that stencil value must be decremented */
  26963. static readonly DECR: number;
  26964. /** Passed to stencilOperation to specify that stencil value must be inverted */
  26965. static readonly INVERT: number;
  26966. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  26967. static readonly INCR_WRAP: number;
  26968. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  26969. static readonly DECR_WRAP: number;
  26970. /** Texture is not repeating outside of 0..1 UVs */
  26971. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  26972. /** Texture is repeating outside of 0..1 UVs */
  26973. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  26974. /** Texture is repeating and mirrored */
  26975. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  26976. /** ALPHA */
  26977. static readonly TEXTUREFORMAT_ALPHA: number;
  26978. /** LUMINANCE */
  26979. static readonly TEXTUREFORMAT_LUMINANCE: number;
  26980. /** LUMINANCE_ALPHA */
  26981. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  26982. /** RGB */
  26983. static readonly TEXTUREFORMAT_RGB: number;
  26984. /** RGBA */
  26985. static readonly TEXTUREFORMAT_RGBA: number;
  26986. /** RED */
  26987. static readonly TEXTUREFORMAT_RED: number;
  26988. /** RED (2nd reference) */
  26989. static readonly TEXTUREFORMAT_R: number;
  26990. /** RG */
  26991. static readonly TEXTUREFORMAT_RG: number;
  26992. /** RED_INTEGER */
  26993. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  26994. /** RED_INTEGER (2nd reference) */
  26995. static readonly TEXTUREFORMAT_R_INTEGER: number;
  26996. /** RG_INTEGER */
  26997. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  26998. /** RGB_INTEGER */
  26999. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27000. /** RGBA_INTEGER */
  27001. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27002. /** UNSIGNED_BYTE */
  27003. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27004. /** UNSIGNED_BYTE (2nd reference) */
  27005. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27006. /** FLOAT */
  27007. static readonly TEXTURETYPE_FLOAT: number;
  27008. /** HALF_FLOAT */
  27009. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27010. /** BYTE */
  27011. static readonly TEXTURETYPE_BYTE: number;
  27012. /** SHORT */
  27013. static readonly TEXTURETYPE_SHORT: number;
  27014. /** UNSIGNED_SHORT */
  27015. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27016. /** INT */
  27017. static readonly TEXTURETYPE_INT: number;
  27018. /** UNSIGNED_INT */
  27019. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27020. /** UNSIGNED_SHORT_4_4_4_4 */
  27021. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27022. /** UNSIGNED_SHORT_5_5_5_1 */
  27023. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27024. /** UNSIGNED_SHORT_5_6_5 */
  27025. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27026. /** UNSIGNED_INT_2_10_10_10_REV */
  27027. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27028. /** UNSIGNED_INT_24_8 */
  27029. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27030. /** UNSIGNED_INT_10F_11F_11F_REV */
  27031. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27032. /** UNSIGNED_INT_5_9_9_9_REV */
  27033. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27034. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27035. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27036. /** nearest is mag = nearest and min = nearest and mip = linear */
  27037. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27038. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27039. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27040. /** Trilinear is mag = linear and min = linear and mip = linear */
  27041. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27042. /** nearest is mag = nearest and min = nearest and mip = linear */
  27043. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27044. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27045. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27046. /** Trilinear is mag = linear and min = linear and mip = linear */
  27047. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27048. /** mag = nearest and min = nearest and mip = nearest */
  27049. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27050. /** mag = nearest and min = linear and mip = nearest */
  27051. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27052. /** mag = nearest and min = linear and mip = linear */
  27053. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27054. /** mag = nearest and min = linear and mip = none */
  27055. static readonly TEXTURE_NEAREST_LINEAR: number;
  27056. /** mag = nearest and min = nearest and mip = none */
  27057. static readonly TEXTURE_NEAREST_NEAREST: number;
  27058. /** mag = linear and min = nearest and mip = nearest */
  27059. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27060. /** mag = linear and min = nearest and mip = linear */
  27061. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27062. /** mag = linear and min = linear and mip = none */
  27063. static readonly TEXTURE_LINEAR_LINEAR: number;
  27064. /** mag = linear and min = nearest and mip = none */
  27065. static readonly TEXTURE_LINEAR_NEAREST: number;
  27066. /** Explicit coordinates mode */
  27067. static readonly TEXTURE_EXPLICIT_MODE: number;
  27068. /** Spherical coordinates mode */
  27069. static readonly TEXTURE_SPHERICAL_MODE: number;
  27070. /** Planar coordinates mode */
  27071. static readonly TEXTURE_PLANAR_MODE: number;
  27072. /** Cubic coordinates mode */
  27073. static readonly TEXTURE_CUBIC_MODE: number;
  27074. /** Projection coordinates mode */
  27075. static readonly TEXTURE_PROJECTION_MODE: number;
  27076. /** Skybox coordinates mode */
  27077. static readonly TEXTURE_SKYBOX_MODE: number;
  27078. /** Inverse Cubic coordinates mode */
  27079. static readonly TEXTURE_INVCUBIC_MODE: number;
  27080. /** Equirectangular coordinates mode */
  27081. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27082. /** Equirectangular Fixed coordinates mode */
  27083. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27084. /** Equirectangular Fixed Mirrored coordinates mode */
  27085. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27086. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27087. static readonly SCALEMODE_FLOOR: number;
  27088. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27089. static readonly SCALEMODE_NEAREST: number;
  27090. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27091. static readonly SCALEMODE_CEILING: number;
  27092. /**
  27093. * Returns the current version of the framework
  27094. */
  27095. static readonly Version: string;
  27096. /**
  27097. * Returns a string describing the current engine
  27098. */
  27099. readonly description: string;
  27100. /**
  27101. * Gets or sets the epsilon value used by collision engine
  27102. */
  27103. static CollisionsEpsilon: number;
  27104. /**
  27105. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27106. */
  27107. static ShadersRepository: string;
  27108. /**
  27109. * Method called to create the default loading screen.
  27110. * This can be overriden in your own app.
  27111. * @param canvas The rendering canvas element
  27112. * @returns The loading screen
  27113. */
  27114. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27115. /**
  27116. * Method called to create the default rescale post process on each engine.
  27117. */
  27118. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27119. /**
  27120. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27121. */
  27122. forcePOTTextures: boolean;
  27123. /**
  27124. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27125. */
  27126. isFullscreen: boolean;
  27127. /**
  27128. * Gets a boolean indicating if the pointer is currently locked
  27129. */
  27130. isPointerLock: boolean;
  27131. /**
  27132. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27133. */
  27134. cullBackFaces: boolean;
  27135. /**
  27136. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27137. */
  27138. renderEvenInBackground: boolean;
  27139. /**
  27140. * Gets or sets a boolean indicating that cache can be kept between frames
  27141. */
  27142. preventCacheWipeBetweenFrames: boolean;
  27143. /**
  27144. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27145. **/
  27146. enableOfflineSupport: boolean;
  27147. /**
  27148. * 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)
  27149. **/
  27150. disableManifestCheck: boolean;
  27151. /**
  27152. * Gets the list of created scenes
  27153. */
  27154. scenes: Scene[];
  27155. /**
  27156. * Event raised when a new scene is created
  27157. */
  27158. onNewSceneAddedObservable: Observable<Scene>;
  27159. /**
  27160. * Gets the list of created postprocesses
  27161. */
  27162. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  27163. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27164. validateShaderPrograms: boolean;
  27165. /**
  27166. * Observable event triggered each time the rendering canvas is resized
  27167. */
  27168. onResizeObservable: Observable<Engine>;
  27169. /**
  27170. * Observable event triggered each time the canvas loses focus
  27171. */
  27172. onCanvasBlurObservable: Observable<Engine>;
  27173. /**
  27174. * Observable event triggered each time the canvas gains focus
  27175. */
  27176. onCanvasFocusObservable: Observable<Engine>;
  27177. /**
  27178. * Observable event triggered each time the canvas receives pointerout event
  27179. */
  27180. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27181. /**
  27182. * Observable event triggered before each texture is initialized
  27183. */
  27184. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  27185. private _vrDisplay;
  27186. private _vrSupported;
  27187. private _oldSize;
  27188. private _oldHardwareScaleFactor;
  27189. private _vrExclusivePointerMode;
  27190. private _webVRInitPromise;
  27191. /**
  27192. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27193. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27194. */
  27195. readonly isInVRExclusivePointerMode: boolean;
  27196. /**
  27197. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27198. */
  27199. disableUniformBuffers: boolean;
  27200. /** @hidden */
  27201. _uniformBuffers: UniformBuffer[];
  27202. /**
  27203. * Gets a boolean indicating that the engine supports uniform buffers
  27204. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27205. */
  27206. readonly supportsUniformBuffers: boolean;
  27207. /**
  27208. * Observable raised when the engine begins a new frame
  27209. */
  27210. onBeginFrameObservable: Observable<Engine>;
  27211. /**
  27212. * If set, will be used to request the next animation frame for the render loop
  27213. */
  27214. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27215. /**
  27216. * Observable raised when the engine ends the current frame
  27217. */
  27218. onEndFrameObservable: Observable<Engine>;
  27219. /**
  27220. * Observable raised when the engine is about to compile a shader
  27221. */
  27222. onBeforeShaderCompilationObservable: Observable<Engine>;
  27223. /**
  27224. * Observable raised when the engine has jsut compiled a shader
  27225. */
  27226. onAfterShaderCompilationObservable: Observable<Engine>;
  27227. /** @hidden */
  27228. _gl: WebGLRenderingContext;
  27229. private _renderingCanvas;
  27230. private _windowIsBackground;
  27231. private _webGLVersion;
  27232. /**
  27233. * Gets a boolean indicating that only power of 2 textures are supported
  27234. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27235. */
  27236. readonly needPOTTextures: boolean;
  27237. /** @hidden */
  27238. _badOS: boolean;
  27239. /** @hidden */
  27240. _badDesktopOS: boolean;
  27241. /**
  27242. * Gets or sets a value indicating if we want to disable texture binding optimization.
  27243. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  27244. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  27245. */
  27246. disableTextureBindingOptimization: boolean;
  27247. /**
  27248. * Gets the audio engine
  27249. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27250. * @ignorenaming
  27251. */
  27252. static audioEngine: IAudioEngine;
  27253. /**
  27254. * Default AudioEngine factory responsible of creating the Audio Engine.
  27255. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27256. */
  27257. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27258. /**
  27259. * Default offline support factory responsible of creating a tool used to store data locally.
  27260. * By default, this will create a Database object if the workload has been embedded.
  27261. */
  27262. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27263. private _onFocus;
  27264. private _onBlur;
  27265. private _onCanvasPointerOut;
  27266. private _onCanvasBlur;
  27267. private _onCanvasFocus;
  27268. private _onFullscreenChange;
  27269. private _onPointerLockChange;
  27270. private _onVRDisplayPointerRestricted;
  27271. private _onVRDisplayPointerUnrestricted;
  27272. private _onVrDisplayConnect;
  27273. private _onVrDisplayDisconnect;
  27274. private _onVrDisplayPresentChange;
  27275. /**
  27276. * Observable signaled when VR display mode changes
  27277. */
  27278. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27279. /**
  27280. * Observable signaled when VR request present is complete
  27281. */
  27282. onVRRequestPresentComplete: Observable<boolean>;
  27283. /**
  27284. * Observable signaled when VR request present starts
  27285. */
  27286. onVRRequestPresentStart: Observable<Engine>;
  27287. private _hardwareScalingLevel;
  27288. /** @hidden */
  27289. protected _caps: EngineCapabilities;
  27290. private _pointerLockRequested;
  27291. private _isStencilEnable;
  27292. private _colorWrite;
  27293. private _loadingScreen;
  27294. /** @hidden */
  27295. _drawCalls: PerfCounter;
  27296. /** @hidden */
  27297. _textureCollisions: PerfCounter;
  27298. private _glVersion;
  27299. private _glRenderer;
  27300. private _glVendor;
  27301. private _videoTextureSupported;
  27302. private _renderingQueueLaunched;
  27303. private _activeRenderLoops;
  27304. private _deterministicLockstep;
  27305. private _lockstepMaxSteps;
  27306. /**
  27307. * Observable signaled when a context lost event is raised
  27308. */
  27309. onContextLostObservable: Observable<Engine>;
  27310. /**
  27311. * Observable signaled when a context restored event is raised
  27312. */
  27313. onContextRestoredObservable: Observable<Engine>;
  27314. private _onContextLost;
  27315. private _onContextRestored;
  27316. private _contextWasLost;
  27317. private _doNotHandleContextLost;
  27318. /**
  27319. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27320. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27321. */
  27322. doNotHandleContextLost: boolean;
  27323. private _performanceMonitor;
  27324. private _fps;
  27325. private _deltaTime;
  27326. /**
  27327. * Turn this value on if you want to pause FPS computation when in background
  27328. */
  27329. disablePerformanceMonitorInBackground: boolean;
  27330. /**
  27331. * Gets the performance monitor attached to this engine
  27332. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27333. */
  27334. readonly performanceMonitor: PerformanceMonitor;
  27335. /** @hidden */
  27336. protected _depthCullingState: _DepthCullingState;
  27337. /** @hidden */
  27338. protected _stencilState: _StencilState;
  27339. /** @hidden */
  27340. protected _alphaState: _AlphaState;
  27341. /** @hidden */
  27342. protected _alphaMode: number;
  27343. protected _internalTexturesCache: InternalTexture[];
  27344. /** @hidden */
  27345. protected _activeChannel: number;
  27346. private _currentTextureChannel;
  27347. /** @hidden */
  27348. protected _boundTexturesCache: {
  27349. [key: string]: Nullable<InternalTexture>;
  27350. };
  27351. /** @hidden */
  27352. protected _currentEffect: Nullable<Effect>;
  27353. /** @hidden */
  27354. protected _currentProgram: Nullable<WebGLProgram>;
  27355. private _compiledEffects;
  27356. private _vertexAttribArraysEnabled;
  27357. /** @hidden */
  27358. protected _cachedViewport: Nullable<Viewport>;
  27359. private _cachedVertexArrayObject;
  27360. /** @hidden */
  27361. protected _cachedVertexBuffers: any;
  27362. /** @hidden */
  27363. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  27364. /** @hidden */
  27365. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27366. /** @hidden */
  27367. protected _currentRenderTarget: Nullable<InternalTexture>;
  27368. private _uintIndicesCurrentlySet;
  27369. private _currentBoundBuffer;
  27370. /** @hidden */
  27371. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27372. private _currentBufferPointers;
  27373. private _currentInstanceLocations;
  27374. private _currentInstanceBuffers;
  27375. private _textureUnits;
  27376. private _firstBoundInternalTextureTracker;
  27377. private _lastBoundInternalTextureTracker;
  27378. private _workingCanvas;
  27379. private _workingContext;
  27380. private _rescalePostProcess;
  27381. private _dummyFramebuffer;
  27382. private _externalData;
  27383. private _bindedRenderFunction;
  27384. private _vaoRecordInProgress;
  27385. private _mustWipeVertexAttributes;
  27386. private _emptyTexture;
  27387. private _emptyCubeTexture;
  27388. private _emptyTexture3D;
  27389. /** @hidden */
  27390. _frameHandler: number;
  27391. private _nextFreeTextureSlots;
  27392. private _maxSimultaneousTextures;
  27393. private _activeRequests;
  27394. private _texturesSupported;
  27395. private _textureFormatInUse;
  27396. /**
  27397. * Gets the list of texture formats supported
  27398. */
  27399. readonly texturesSupported: Array<string>;
  27400. /**
  27401. * Gets the list of texture formats in use
  27402. */
  27403. readonly textureFormatInUse: Nullable<string>;
  27404. /**
  27405. * Gets the current viewport
  27406. */
  27407. readonly currentViewport: Nullable<Viewport>;
  27408. /**
  27409. * Gets the default empty texture
  27410. */
  27411. readonly emptyTexture: InternalTexture;
  27412. /**
  27413. * Gets the default empty 3D texture
  27414. */
  27415. readonly emptyTexture3D: InternalTexture;
  27416. /**
  27417. * Gets the default empty cube texture
  27418. */
  27419. readonly emptyCubeTexture: InternalTexture;
  27420. /**
  27421. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27422. */
  27423. readonly premultipliedAlpha: boolean;
  27424. /**
  27425. * Creates a new engine
  27426. * @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
  27427. * @param antialias defines enable antialiasing (default: false)
  27428. * @param options defines further options to be sent to the getContext() function
  27429. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27430. */
  27431. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27432. private _disableTouchAction;
  27433. private _rebuildInternalTextures;
  27434. private _rebuildEffects;
  27435. /**
  27436. * Gets a boolean indicating if all created effects are ready
  27437. * @returns true if all effects are ready
  27438. */
  27439. areAllEffectsReady(): boolean;
  27440. private _rebuildBuffers;
  27441. private _initGLContext;
  27442. /**
  27443. * Gets version of the current webGL context
  27444. */
  27445. readonly webGLVersion: number;
  27446. /**
  27447. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27448. */
  27449. readonly isStencilEnable: boolean;
  27450. private _prepareWorkingCanvas;
  27451. /**
  27452. * Reset the texture cache to empty state
  27453. */
  27454. resetTextureCache(): void;
  27455. /**
  27456. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27457. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27458. * @returns true if engine is in deterministic lock step mode
  27459. */
  27460. isDeterministicLockStep(): boolean;
  27461. /**
  27462. * Gets the max steps when engine is running in deterministic lock step
  27463. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27464. * @returns the max steps
  27465. */
  27466. getLockstepMaxSteps(): number;
  27467. /**
  27468. * Gets an object containing information about the current webGL context
  27469. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27470. */
  27471. getGlInfo(): {
  27472. vendor: string;
  27473. renderer: string;
  27474. version: string;
  27475. };
  27476. /**
  27477. * Gets current aspect ratio
  27478. * @param camera defines the camera to use to get the aspect ratio
  27479. * @param useScreen defines if screen size must be used (or the current render target if any)
  27480. * @returns a number defining the aspect ratio
  27481. */
  27482. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27483. /**
  27484. * Gets current screen aspect ratio
  27485. * @returns a number defining the aspect ratio
  27486. */
  27487. getScreenAspectRatio(): number;
  27488. /**
  27489. * Gets the current render width
  27490. * @param useScreen defines if screen size must be used (or the current render target if any)
  27491. * @returns a number defining the current render width
  27492. */
  27493. getRenderWidth(useScreen?: boolean): number;
  27494. /**
  27495. * Gets the current render height
  27496. * @param useScreen defines if screen size must be used (or the current render target if any)
  27497. * @returns a number defining the current render height
  27498. */
  27499. getRenderHeight(useScreen?: boolean): number;
  27500. /**
  27501. * Gets the HTML canvas attached with the current webGL context
  27502. * @returns a HTML canvas
  27503. */
  27504. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27505. /**
  27506. * Gets the client rect of the HTML canvas attached with the current webGL context
  27507. * @returns a client rectanglee
  27508. */
  27509. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27510. /**
  27511. * Defines the hardware scaling level.
  27512. * By default the hardware scaling level is computed from the window device ratio.
  27513. * 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.
  27514. * @param level defines the level to use
  27515. */
  27516. setHardwareScalingLevel(level: number): void;
  27517. /**
  27518. * Gets the current hardware scaling level.
  27519. * By default the hardware scaling level is computed from the window device ratio.
  27520. * 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.
  27521. * @returns a number indicating the current hardware scaling level
  27522. */
  27523. getHardwareScalingLevel(): number;
  27524. /**
  27525. * Gets the list of loaded textures
  27526. * @returns an array containing all loaded textures
  27527. */
  27528. getLoadedTexturesCache(): InternalTexture[];
  27529. /**
  27530. * Gets the object containing all engine capabilities
  27531. * @returns the EngineCapabilities object
  27532. */
  27533. getCaps(): EngineCapabilities;
  27534. /**
  27535. * Gets the current depth function
  27536. * @returns a number defining the depth function
  27537. */
  27538. getDepthFunction(): Nullable<number>;
  27539. /**
  27540. * Sets the current depth function
  27541. * @param depthFunc defines the function to use
  27542. */
  27543. setDepthFunction(depthFunc: number): void;
  27544. /**
  27545. * Sets the current depth function to GREATER
  27546. */
  27547. setDepthFunctionToGreater(): void;
  27548. /**
  27549. * Sets the current depth function to GEQUAL
  27550. */
  27551. setDepthFunctionToGreaterOrEqual(): void;
  27552. /**
  27553. * Sets the current depth function to LESS
  27554. */
  27555. setDepthFunctionToLess(): void;
  27556. /**
  27557. * Sets the current depth function to LEQUAL
  27558. */
  27559. setDepthFunctionToLessOrEqual(): void;
  27560. /**
  27561. * Gets a boolean indicating if stencil buffer is enabled
  27562. * @returns the current stencil buffer state
  27563. */
  27564. getStencilBuffer(): boolean;
  27565. /**
  27566. * Enable or disable the stencil buffer
  27567. * @param enable defines if the stencil buffer must be enabled or disabled
  27568. */
  27569. setStencilBuffer(enable: boolean): void;
  27570. /**
  27571. * Gets the current stencil mask
  27572. * @returns a number defining the new stencil mask to use
  27573. */
  27574. getStencilMask(): number;
  27575. /**
  27576. * Sets the current stencil mask
  27577. * @param mask defines the new stencil mask to use
  27578. */
  27579. setStencilMask(mask: number): void;
  27580. /**
  27581. * Gets the current stencil function
  27582. * @returns a number defining the stencil function to use
  27583. */
  27584. getStencilFunction(): number;
  27585. /**
  27586. * Gets the current stencil reference value
  27587. * @returns a number defining the stencil reference value to use
  27588. */
  27589. getStencilFunctionReference(): number;
  27590. /**
  27591. * Gets the current stencil mask
  27592. * @returns a number defining the stencil mask to use
  27593. */
  27594. getStencilFunctionMask(): number;
  27595. /**
  27596. * Sets the current stencil function
  27597. * @param stencilFunc defines the new stencil function to use
  27598. */
  27599. setStencilFunction(stencilFunc: number): void;
  27600. /**
  27601. * Sets the current stencil reference
  27602. * @param reference defines the new stencil reference to use
  27603. */
  27604. setStencilFunctionReference(reference: number): void;
  27605. /**
  27606. * Sets the current stencil mask
  27607. * @param mask defines the new stencil mask to use
  27608. */
  27609. setStencilFunctionMask(mask: number): void;
  27610. /**
  27611. * Gets the current stencil operation when stencil fails
  27612. * @returns a number defining stencil operation to use when stencil fails
  27613. */
  27614. getStencilOperationFail(): number;
  27615. /**
  27616. * Gets the current stencil operation when depth fails
  27617. * @returns a number defining stencil operation to use when depth fails
  27618. */
  27619. getStencilOperationDepthFail(): number;
  27620. /**
  27621. * Gets the current stencil operation when stencil passes
  27622. * @returns a number defining stencil operation to use when stencil passes
  27623. */
  27624. getStencilOperationPass(): number;
  27625. /**
  27626. * Sets the stencil operation to use when stencil fails
  27627. * @param operation defines the stencil operation to use when stencil fails
  27628. */
  27629. setStencilOperationFail(operation: number): void;
  27630. /**
  27631. * Sets the stencil operation to use when depth fails
  27632. * @param operation defines the stencil operation to use when depth fails
  27633. */
  27634. setStencilOperationDepthFail(operation: number): void;
  27635. /**
  27636. * Sets the stencil operation to use when stencil passes
  27637. * @param operation defines the stencil operation to use when stencil passes
  27638. */
  27639. setStencilOperationPass(operation: number): void;
  27640. /**
  27641. * Sets a boolean indicating if the dithering state is enabled or disabled
  27642. * @param value defines the dithering state
  27643. */
  27644. setDitheringState(value: boolean): void;
  27645. /**
  27646. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  27647. * @param value defines the rasterizer state
  27648. */
  27649. setRasterizerState(value: boolean): void;
  27650. /**
  27651. * stop executing a render loop function and remove it from the execution array
  27652. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  27653. */
  27654. stopRenderLoop(renderFunction?: () => void): void;
  27655. /** @hidden */
  27656. _renderLoop(): void;
  27657. /**
  27658. * Register and execute a render loop. The engine can have more than one render function
  27659. * @param renderFunction defines the function to continuously execute
  27660. */
  27661. runRenderLoop(renderFunction: () => void): void;
  27662. /**
  27663. * Toggle full screen mode
  27664. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27665. */
  27666. switchFullscreen(requestPointerLock: boolean): void;
  27667. /**
  27668. * Enters full screen mode
  27669. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27670. */
  27671. enterFullscreen(requestPointerLock: boolean): void;
  27672. /**
  27673. * Exits full screen mode
  27674. */
  27675. exitFullscreen(): void;
  27676. /**
  27677. * Clear the current render buffer or the current render target (if any is set up)
  27678. * @param color defines the color to use
  27679. * @param backBuffer defines if the back buffer must be cleared
  27680. * @param depth defines if the depth buffer must be cleared
  27681. * @param stencil defines if the stencil buffer must be cleared
  27682. */
  27683. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  27684. /**
  27685. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  27686. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27687. * @param y defines the y-coordinate of the corner of the clear rectangle
  27688. * @param width defines the width of the clear rectangle
  27689. * @param height defines the height of the clear rectangle
  27690. * @param clearColor defines the clear color
  27691. */
  27692. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  27693. /**
  27694. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  27695. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27696. * @param y defines the y-coordinate of the corner of the clear rectangle
  27697. * @param width defines the width of the clear rectangle
  27698. * @param height defines the height of the clear rectangle
  27699. */
  27700. enableScissor(x: number, y: number, width: number, height: number): void;
  27701. /**
  27702. * Disable previously set scissor test rectangle
  27703. */
  27704. disableScissor(): void;
  27705. private _viewportCached;
  27706. /** @hidden */
  27707. _viewport(x: number, y: number, width: number, height: number): void;
  27708. /**
  27709. * Set the WebGL's viewport
  27710. * @param viewport defines the viewport element to be used
  27711. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  27712. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  27713. */
  27714. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  27715. /**
  27716. * Directly set the WebGL Viewport
  27717. * @param x defines the x coordinate of the viewport (in screen space)
  27718. * @param y defines the y coordinate of the viewport (in screen space)
  27719. * @param width defines the width of the viewport (in screen space)
  27720. * @param height defines the height of the viewport (in screen space)
  27721. * @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
  27722. */
  27723. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  27724. /**
  27725. * Begin a new frame
  27726. */
  27727. beginFrame(): void;
  27728. /**
  27729. * Enf the current frame
  27730. */
  27731. endFrame(): void;
  27732. /**
  27733. * Resize the view according to the canvas' size
  27734. */
  27735. resize(): void;
  27736. /**
  27737. * Force a specific size of the canvas
  27738. * @param width defines the new canvas' width
  27739. * @param height defines the new canvas' height
  27740. */
  27741. setSize(width: number, height: number): void;
  27742. /**
  27743. * Gets a boolean indicating if a webVR device was detected
  27744. * @returns true if a webVR device was detected
  27745. */
  27746. isVRDevicePresent(): boolean;
  27747. /**
  27748. * Gets the current webVR device
  27749. * @returns the current webVR device (or null)
  27750. */
  27751. getVRDevice(): any;
  27752. /**
  27753. * Initializes a webVR display and starts listening to display change events
  27754. * The onVRDisplayChangedObservable will be notified upon these changes
  27755. * @returns The onVRDisplayChangedObservable
  27756. */
  27757. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27758. /**
  27759. * Initializes a webVR display and starts listening to display change events
  27760. * The onVRDisplayChangedObservable will be notified upon these changes
  27761. * @returns A promise containing a VRDisplay and if vr is supported
  27762. */
  27763. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27764. /**
  27765. * Call this function to switch to webVR mode
  27766. * Will do nothing if webVR is not supported or if there is no webVR device
  27767. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27768. */
  27769. enableVR(): void;
  27770. /**
  27771. * Call this function to leave webVR mode
  27772. * Will do nothing if webVR is not supported or if there is no webVR device
  27773. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27774. */
  27775. disableVR(): void;
  27776. private _onVRFullScreenTriggered;
  27777. private _getVRDisplaysAsync;
  27778. /**
  27779. * Binds the frame buffer to the specified texture.
  27780. * @param texture The texture to render to or null for the default canvas
  27781. * @param faceIndex The face of the texture to render to in case of cube texture
  27782. * @param requiredWidth The width of the target to render to
  27783. * @param requiredHeight The height of the target to render to
  27784. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  27785. * @param depthStencilTexture The depth stencil texture to use to render
  27786. * @param lodLevel defines le lod level to bind to the frame buffer
  27787. */
  27788. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  27789. private bindUnboundFramebuffer;
  27790. /**
  27791. * Unbind the current render target texture from the webGL context
  27792. * @param texture defines the render target texture to unbind
  27793. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27794. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27795. */
  27796. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27797. /**
  27798. * Unbind a list of render target textures from the webGL context
  27799. * This is used only when drawBuffer extension or webGL2 are active
  27800. * @param textures defines the render target textures to unbind
  27801. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27802. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27803. */
  27804. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27805. /**
  27806. * Force the mipmap generation for the given render target texture
  27807. * @param texture defines the render target texture to use
  27808. */
  27809. generateMipMapsForCubemap(texture: InternalTexture): void;
  27810. /**
  27811. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  27812. */
  27813. flushFramebuffer(): void;
  27814. /**
  27815. * Unbind the current render target and bind the default framebuffer
  27816. */
  27817. restoreDefaultFramebuffer(): void;
  27818. /**
  27819. * Create an uniform buffer
  27820. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27821. * @param elements defines the content of the uniform buffer
  27822. * @returns the webGL uniform buffer
  27823. */
  27824. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  27825. /**
  27826. * Create a dynamic uniform buffer
  27827. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27828. * @param elements defines the content of the uniform buffer
  27829. * @returns the webGL uniform buffer
  27830. */
  27831. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  27832. /**
  27833. * Update an existing uniform buffer
  27834. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27835. * @param uniformBuffer defines the target uniform buffer
  27836. * @param elements defines the content to update
  27837. * @param offset defines the offset in the uniform buffer where update should start
  27838. * @param count defines the size of the data to update
  27839. */
  27840. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  27841. private _resetVertexBufferBinding;
  27842. /**
  27843. * Creates a vertex buffer
  27844. * @param data the data for the vertex buffer
  27845. * @returns the new WebGL static buffer
  27846. */
  27847. createVertexBuffer(data: DataArray): WebGLBuffer;
  27848. /**
  27849. * Creates a dynamic vertex buffer
  27850. * @param data the data for the dynamic vertex buffer
  27851. * @returns the new WebGL dynamic buffer
  27852. */
  27853. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  27854. /**
  27855. * Update a dynamic index buffer
  27856. * @param indexBuffer defines the target index buffer
  27857. * @param indices defines the data to update
  27858. * @param offset defines the offset in the target index buffer where update should start
  27859. */
  27860. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  27861. /**
  27862. * Updates a dynamic vertex buffer.
  27863. * @param vertexBuffer the vertex buffer to update
  27864. * @param data the data used to update the vertex buffer
  27865. * @param byteOffset the byte offset of the data
  27866. * @param byteLength the byte length of the data
  27867. */
  27868. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  27869. private _resetIndexBufferBinding;
  27870. /**
  27871. * Creates a new index buffer
  27872. * @param indices defines the content of the index buffer
  27873. * @param updatable defines if the index buffer must be updatable
  27874. * @returns a new webGL buffer
  27875. */
  27876. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  27877. /**
  27878. * Bind a webGL buffer to the webGL context
  27879. * @param buffer defines the buffer to bind
  27880. */
  27881. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  27882. /**
  27883. * Bind an uniform buffer to the current webGL context
  27884. * @param buffer defines the buffer to bind
  27885. */
  27886. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  27887. /**
  27888. * Bind a buffer to the current webGL context at a given location
  27889. * @param buffer defines the buffer to bind
  27890. * @param location defines the index where to bind the buffer
  27891. */
  27892. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  27893. /**
  27894. * Bind a specific block at a given index in a specific shader program
  27895. * @param shaderProgram defines the shader program
  27896. * @param blockName defines the block name
  27897. * @param index defines the index where to bind the block
  27898. */
  27899. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  27900. private bindIndexBuffer;
  27901. private bindBuffer;
  27902. /**
  27903. * update the bound buffer with the given data
  27904. * @param data defines the data to update
  27905. */
  27906. updateArrayBuffer(data: Float32Array): void;
  27907. private _vertexAttribPointer;
  27908. private _bindIndexBufferWithCache;
  27909. private _bindVertexBuffersAttributes;
  27910. /**
  27911. * Records a vertex array object
  27912. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27913. * @param vertexBuffers defines the list of vertex buffers to store
  27914. * @param indexBuffer defines the index buffer to store
  27915. * @param effect defines the effect to store
  27916. * @returns the new vertex array object
  27917. */
  27918. recordVertexArrayObject(vertexBuffers: {
  27919. [key: string]: VertexBuffer;
  27920. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  27921. /**
  27922. * Bind a specific vertex array object
  27923. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27924. * @param vertexArrayObject defines the vertex array object to bind
  27925. * @param indexBuffer defines the index buffer to bind
  27926. */
  27927. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  27928. /**
  27929. * Bind webGl buffers directly to the webGL context
  27930. * @param vertexBuffer defines the vertex buffer to bind
  27931. * @param indexBuffer defines the index buffer to bind
  27932. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  27933. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  27934. * @param effect defines the effect associated with the vertex buffer
  27935. */
  27936. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  27937. private _unbindVertexArrayObject;
  27938. /**
  27939. * Bind a list of vertex buffers to the webGL context
  27940. * @param vertexBuffers defines the list of vertex buffers to bind
  27941. * @param indexBuffer defines the index buffer to bind
  27942. * @param effect defines the effect associated with the vertex buffers
  27943. */
  27944. bindBuffers(vertexBuffers: {
  27945. [key: string]: Nullable<VertexBuffer>;
  27946. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  27947. /**
  27948. * Unbind all instance attributes
  27949. */
  27950. unbindInstanceAttributes(): void;
  27951. /**
  27952. * Release and free the memory of a vertex array object
  27953. * @param vao defines the vertex array object to delete
  27954. */
  27955. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  27956. /** @hidden */
  27957. _releaseBuffer(buffer: WebGLBuffer): boolean;
  27958. /**
  27959. * Creates a webGL buffer to use with instanciation
  27960. * @param capacity defines the size of the buffer
  27961. * @returns the webGL buffer
  27962. */
  27963. createInstancesBuffer(capacity: number): WebGLBuffer;
  27964. /**
  27965. * Delete a webGL buffer used with instanciation
  27966. * @param buffer defines the webGL buffer to delete
  27967. */
  27968. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  27969. /**
  27970. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  27971. * @param instancesBuffer defines the webGL buffer to update and bind
  27972. * @param data defines the data to store in the buffer
  27973. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  27974. */
  27975. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  27976. /**
  27977. * Apply all cached states (depth, culling, stencil and alpha)
  27978. */
  27979. applyStates(): void;
  27980. /**
  27981. * Send a draw order
  27982. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27983. * @param indexStart defines the starting index
  27984. * @param indexCount defines the number of index to draw
  27985. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27986. */
  27987. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  27988. /**
  27989. * Draw a list of points
  27990. * @param verticesStart defines the index of first vertex to draw
  27991. * @param verticesCount defines the count of vertices to draw
  27992. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27993. */
  27994. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27995. /**
  27996. * Draw a list of unindexed primitives
  27997. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27998. * @param verticesStart defines the index of first vertex to draw
  27999. * @param verticesCount defines the count of vertices to draw
  28000. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28001. */
  28002. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28003. /**
  28004. * Draw a list of indexed primitives
  28005. * @param fillMode defines the primitive to use
  28006. * @param indexStart defines the starting index
  28007. * @param indexCount defines the number of index to draw
  28008. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28009. */
  28010. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28011. /**
  28012. * Draw a list of unindexed primitives
  28013. * @param fillMode defines the primitive to use
  28014. * @param verticesStart defines the index of first vertex to draw
  28015. * @param verticesCount defines the count of vertices to draw
  28016. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28017. */
  28018. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28019. private _drawMode;
  28020. /** @hidden */
  28021. _releaseEffect(effect: Effect): void;
  28022. /** @hidden */
  28023. _deleteProgram(program: WebGLProgram): void;
  28024. /**
  28025. * Create a new effect (used to store vertex/fragment shaders)
  28026. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28027. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28028. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28029. * @param samplers defines an array of string used to represent textures
  28030. * @param defines defines the string containing the defines to use to compile the shaders
  28031. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28032. * @param onCompiled defines a function to call when the effect creation is successful
  28033. * @param onError defines a function to call when the effect creation has failed
  28034. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28035. * @returns the new Effect
  28036. */
  28037. 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;
  28038. private _compileShader;
  28039. private _compileRawShader;
  28040. /**
  28041. * Directly creates a webGL program
  28042. * @param vertexCode defines the vertex shader code to use
  28043. * @param fragmentCode defines the fragment shader code to use
  28044. * @param context defines the webGL context to use (if not set, the current one will be used)
  28045. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28046. * @returns the new webGL program
  28047. */
  28048. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28049. /**
  28050. * Creates a webGL program
  28051. * @param vertexCode defines the vertex shader code to use
  28052. * @param fragmentCode defines the fragment shader code to use
  28053. * @param defines defines the string containing the defines to use to compile the shaders
  28054. * @param context defines the webGL context to use (if not set, the current one will be used)
  28055. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28056. * @returns the new webGL program
  28057. */
  28058. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28059. private _createShaderProgram;
  28060. private _finalizeProgram;
  28061. /** @hidden */
  28062. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  28063. /** @hidden */
  28064. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  28065. /**
  28066. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28067. * @param shaderProgram defines the webGL program to use
  28068. * @param uniformsNames defines the list of uniform names
  28069. * @returns an array of webGL uniform locations
  28070. */
  28071. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28072. /**
  28073. * Gets the lsit of active attributes for a given webGL program
  28074. * @param shaderProgram defines the webGL program to use
  28075. * @param attributesNames defines the list of attribute names to get
  28076. * @returns an array of indices indicating the offset of each attribute
  28077. */
  28078. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  28079. /**
  28080. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28081. * @param effect defines the effect to activate
  28082. */
  28083. enableEffect(effect: Nullable<Effect>): void;
  28084. /**
  28085. * Set the value of an uniform to an array of int32
  28086. * @param uniform defines the webGL uniform location where to store the value
  28087. * @param array defines the array of int32 to store
  28088. */
  28089. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28090. /**
  28091. * Set the value of an uniform to an array of int32 (stored as vec2)
  28092. * @param uniform defines the webGL uniform location where to store the value
  28093. * @param array defines the array of int32 to store
  28094. */
  28095. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28096. /**
  28097. * Set the value of an uniform to an array of int32 (stored as vec3)
  28098. * @param uniform defines the webGL uniform location where to store the value
  28099. * @param array defines the array of int32 to store
  28100. */
  28101. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28102. /**
  28103. * Set the value of an uniform to an array of int32 (stored as vec4)
  28104. * @param uniform defines the webGL uniform location where to store the value
  28105. * @param array defines the array of int32 to store
  28106. */
  28107. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28108. /**
  28109. * Set the value of an uniform to an array of float32
  28110. * @param uniform defines the webGL uniform location where to store the value
  28111. * @param array defines the array of float32 to store
  28112. */
  28113. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28114. /**
  28115. * Set the value of an uniform to an array of float32 (stored as vec2)
  28116. * @param uniform defines the webGL uniform location where to store the value
  28117. * @param array defines the array of float32 to store
  28118. */
  28119. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28120. /**
  28121. * Set the value of an uniform to an array of float32 (stored as vec3)
  28122. * @param uniform defines the webGL uniform location where to store the value
  28123. * @param array defines the array of float32 to store
  28124. */
  28125. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28126. /**
  28127. * Set the value of an uniform to an array of float32 (stored as vec4)
  28128. * @param uniform defines the webGL uniform location where to store the value
  28129. * @param array defines the array of float32 to store
  28130. */
  28131. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28132. /**
  28133. * Set the value of an uniform to an array of number
  28134. * @param uniform defines the webGL uniform location where to store the value
  28135. * @param array defines the array of number to store
  28136. */
  28137. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28138. /**
  28139. * Set the value of an uniform to an array of number (stored as vec2)
  28140. * @param uniform defines the webGL uniform location where to store the value
  28141. * @param array defines the array of number to store
  28142. */
  28143. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28144. /**
  28145. * Set the value of an uniform to an array of number (stored as vec3)
  28146. * @param uniform defines the webGL uniform location where to store the value
  28147. * @param array defines the array of number to store
  28148. */
  28149. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28150. /**
  28151. * Set the value of an uniform to an array of number (stored as vec4)
  28152. * @param uniform defines the webGL uniform location where to store the value
  28153. * @param array defines the array of number to store
  28154. */
  28155. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28156. /**
  28157. * Set the value of an uniform to an array of float32 (stored as matrices)
  28158. * @param uniform defines the webGL uniform location where to store the value
  28159. * @param matrices defines the array of float32 to store
  28160. */
  28161. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28162. /**
  28163. * Set the value of an uniform to a matrix
  28164. * @param uniform defines the webGL uniform location where to store the value
  28165. * @param matrix defines the matrix to store
  28166. */
  28167. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28168. /**
  28169. * Set the value of an uniform to a matrix (3x3)
  28170. * @param uniform defines the webGL uniform location where to store the value
  28171. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28172. */
  28173. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28174. /**
  28175. * Set the value of an uniform to a matrix (2x2)
  28176. * @param uniform defines the webGL uniform location where to store the value
  28177. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28178. */
  28179. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28180. /**
  28181. * Set the value of an uniform to a number (int)
  28182. * @param uniform defines the webGL uniform location where to store the value
  28183. * @param value defines the int number to store
  28184. */
  28185. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28186. /**
  28187. * Set the value of an uniform to a number (float)
  28188. * @param uniform defines the webGL uniform location where to store the value
  28189. * @param value defines the float number to store
  28190. */
  28191. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28192. /**
  28193. * Set the value of an uniform to a vec2
  28194. * @param uniform defines the webGL uniform location where to store the value
  28195. * @param x defines the 1st component of the value
  28196. * @param y defines the 2nd component of the value
  28197. */
  28198. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28199. /**
  28200. * Set the value of an uniform to a vec3
  28201. * @param uniform defines the webGL uniform location where to store the value
  28202. * @param x defines the 1st component of the value
  28203. * @param y defines the 2nd component of the value
  28204. * @param z defines the 3rd component of the value
  28205. */
  28206. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28207. /**
  28208. * Set the value of an uniform to a boolean
  28209. * @param uniform defines the webGL uniform location where to store the value
  28210. * @param bool defines the boolean to store
  28211. */
  28212. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28213. /**
  28214. * Set the value of an uniform to a vec4
  28215. * @param uniform defines the webGL uniform location where to store the value
  28216. * @param x defines the 1st component of the value
  28217. * @param y defines the 2nd component of the value
  28218. * @param z defines the 3rd component of the value
  28219. * @param w defines the 4th component of the value
  28220. */
  28221. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28222. /**
  28223. * Set the value of an uniform to a Color3
  28224. * @param uniform defines the webGL uniform location where to store the value
  28225. * @param color3 defines the color to store
  28226. */
  28227. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28228. /**
  28229. * Set the value of an uniform to a Color3 and an alpha value
  28230. * @param uniform defines the webGL uniform location where to store the value
  28231. * @param color3 defines the color to store
  28232. * @param alpha defines the alpha component to store
  28233. */
  28234. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28235. /**
  28236. * Sets a Color4 on a uniform variable
  28237. * @param uniform defines the uniform location
  28238. * @param color4 defines the value to be set
  28239. */
  28240. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28241. /**
  28242. * Set various states to the webGL context
  28243. * @param culling defines backface culling state
  28244. * @param zOffset defines the value to apply to zOffset (0 by default)
  28245. * @param force defines if states must be applied even if cache is up to date
  28246. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28247. */
  28248. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28249. /**
  28250. * Set the z offset to apply to current rendering
  28251. * @param value defines the offset to apply
  28252. */
  28253. setZOffset(value: number): void;
  28254. /**
  28255. * Gets the current value of the zOffset
  28256. * @returns the current zOffset state
  28257. */
  28258. getZOffset(): number;
  28259. /**
  28260. * Enable or disable depth buffering
  28261. * @param enable defines the state to set
  28262. */
  28263. setDepthBuffer(enable: boolean): void;
  28264. /**
  28265. * Gets a boolean indicating if depth writing is enabled
  28266. * @returns the current depth writing state
  28267. */
  28268. getDepthWrite(): boolean;
  28269. /**
  28270. * Enable or disable depth writing
  28271. * @param enable defines the state to set
  28272. */
  28273. setDepthWrite(enable: boolean): void;
  28274. /**
  28275. * Enable or disable color writing
  28276. * @param enable defines the state to set
  28277. */
  28278. setColorWrite(enable: boolean): void;
  28279. /**
  28280. * Gets a boolean indicating if color writing is enabled
  28281. * @returns the current color writing state
  28282. */
  28283. getColorWrite(): boolean;
  28284. /**
  28285. * Sets alpha constants used by some alpha blending modes
  28286. * @param r defines the red component
  28287. * @param g defines the green component
  28288. * @param b defines the blue component
  28289. * @param a defines the alpha component
  28290. */
  28291. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28292. /**
  28293. * Sets the current alpha mode
  28294. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28295. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28296. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28297. */
  28298. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28299. /**
  28300. * Gets the current alpha mode
  28301. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28302. * @returns the current alpha mode
  28303. */
  28304. getAlphaMode(): number;
  28305. /**
  28306. * Clears the list of texture accessible through engine.
  28307. * This can help preventing texture load conflict due to name collision.
  28308. */
  28309. clearInternalTexturesCache(): void;
  28310. /**
  28311. * Force the entire cache to be cleared
  28312. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28313. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28314. */
  28315. wipeCaches(bruteForce?: boolean): void;
  28316. /**
  28317. * Set the compressed texture format to use, based on the formats you have, and the formats
  28318. * supported by the hardware / browser.
  28319. *
  28320. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28321. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28322. * to API arguments needed to compressed textures. This puts the burden on the container
  28323. * generator to house the arcane code for determining these for current & future formats.
  28324. *
  28325. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28326. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28327. *
  28328. * Note: The result of this call is not taken into account when a texture is base64.
  28329. *
  28330. * @param formatsAvailable defines the list of those format families you have created
  28331. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28332. *
  28333. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28334. * @returns The extension selected.
  28335. */
  28336. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28337. private _getSamplingParameters;
  28338. private _partialLoadImg;
  28339. private _cascadeLoadImgs;
  28340. /** @hidden */
  28341. _createTexture(): WebGLTexture;
  28342. /**
  28343. * Usually called from Texture.ts.
  28344. * Passed information to create a WebGLTexture
  28345. * @param urlArg defines a value which contains one of the following:
  28346. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28347. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28348. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28349. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28350. * @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)
  28351. * @param scene needed for loading to the correct scene
  28352. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28353. * @param onLoad optional callback to be called upon successful completion
  28354. * @param onError optional callback to be called upon failure
  28355. * @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
  28356. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28357. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28358. * @param forcedExtension defines the extension to use to pick the right loader
  28359. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28360. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28361. */
  28362. 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;
  28363. private _rescaleTexture;
  28364. /**
  28365. * Update a raw texture
  28366. * @param texture defines the texture to update
  28367. * @param data defines the data to store in the texture
  28368. * @param format defines the format of the data
  28369. * @param invertY defines if data must be stored with Y axis inverted
  28370. * @param compression defines the compression used (null by default)
  28371. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28372. */
  28373. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  28374. /**
  28375. * Creates a raw texture
  28376. * @param data defines the data to store in the texture
  28377. * @param width defines the width of the texture
  28378. * @param height defines the height of the texture
  28379. * @param format defines the format of the data
  28380. * @param generateMipMaps defines if the engine should generate the mip levels
  28381. * @param invertY defines if data must be stored with Y axis inverted
  28382. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28383. * @param compression defines the compression used (null by default)
  28384. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28385. * @returns the raw texture inside an InternalTexture
  28386. */
  28387. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  28388. private _unpackFlipYCached;
  28389. /**
  28390. * In case you are sharing the context with other applications, it might
  28391. * be interested to not cache the unpack flip y state to ensure a consistent
  28392. * value would be set.
  28393. */
  28394. enableUnpackFlipYCached: boolean;
  28395. /** @hidden */
  28396. _unpackFlipY(value: boolean): void;
  28397. /** @hidden */
  28398. _getUnpackAlignement(): number;
  28399. /**
  28400. * Creates a dynamic texture
  28401. * @param width defines the width of the texture
  28402. * @param height defines the height of the texture
  28403. * @param generateMipMaps defines if the engine should generate the mip levels
  28404. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28405. * @returns the dynamic texture inside an InternalTexture
  28406. */
  28407. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28408. /**
  28409. * Update the sampling mode of a given texture
  28410. * @param samplingMode defines the required sampling mode
  28411. * @param texture defines the texture to update
  28412. */
  28413. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28414. /**
  28415. * Update the content of a dynamic texture
  28416. * @param texture defines the texture to update
  28417. * @param canvas defines the canvas containing the source
  28418. * @param invertY defines if data must be stored with Y axis inverted
  28419. * @param premulAlpha defines if alpha is stored as premultiplied
  28420. * @param format defines the format of the data
  28421. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28422. */
  28423. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28424. /**
  28425. * Update a video texture
  28426. * @param texture defines the texture to update
  28427. * @param video defines the video element to use
  28428. * @param invertY defines if data must be stored with Y axis inverted
  28429. */
  28430. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28431. /**
  28432. * Updates a depth texture Comparison Mode and Function.
  28433. * If the comparison Function is equal to 0, the mode will be set to none.
  28434. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28435. * @param texture The texture to set the comparison function for
  28436. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28437. */
  28438. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28439. private _setupDepthStencilTexture;
  28440. /**
  28441. * Creates a depth stencil texture.
  28442. * This is only available in WebGL 2 or with the depth texture extension available.
  28443. * @param size The size of face edge in the texture.
  28444. * @param options The options defining the texture.
  28445. * @returns The texture
  28446. */
  28447. createDepthStencilTexture(size: number | {
  28448. width: number;
  28449. height: number;
  28450. }, options: DepthTextureCreationOptions): InternalTexture;
  28451. /**
  28452. * Creates a depth stencil texture.
  28453. * This is only available in WebGL 2 or with the depth texture extension available.
  28454. * @param size The size of face edge in the texture.
  28455. * @param options The options defining the texture.
  28456. * @returns The texture
  28457. */
  28458. private _createDepthStencilTexture;
  28459. /**
  28460. * Creates a depth stencil cube texture.
  28461. * This is only available in WebGL 2.
  28462. * @param size The size of face edge in the cube texture.
  28463. * @param options The options defining the cube texture.
  28464. * @returns The cube texture
  28465. */
  28466. private _createDepthStencilCubeTexture;
  28467. /**
  28468. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28469. * @param renderTarget The render target to set the frame buffer for
  28470. */
  28471. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28472. /**
  28473. * Creates a new render target texture
  28474. * @param size defines the size of the texture
  28475. * @param options defines the options used to create the texture
  28476. * @returns a new render target texture stored in an InternalTexture
  28477. */
  28478. createRenderTargetTexture(size: number | {
  28479. width: number;
  28480. height: number;
  28481. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28482. /**
  28483. * Create a multi render target texture
  28484. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  28485. * @param size defines the size of the texture
  28486. * @param options defines the creation options
  28487. * @returns the cube texture as an InternalTexture
  28488. */
  28489. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  28490. private _setupFramebufferDepthAttachments;
  28491. /**
  28492. * Updates the sample count of a render target texture
  28493. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28494. * @param texture defines the texture to update
  28495. * @param samples defines the sample count to set
  28496. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28497. */
  28498. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28499. /**
  28500. * Update the sample count for a given multiple render target texture
  28501. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28502. * @param textures defines the textures to update
  28503. * @param samples defines the sample count to set
  28504. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28505. */
  28506. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  28507. /** @hidden */
  28508. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28509. /** @hidden */
  28510. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28511. /** @hidden */
  28512. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28513. /** @hidden */
  28514. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28515. /**
  28516. * Creates a new render target cube texture
  28517. * @param size defines the size of the texture
  28518. * @param options defines the options used to create the texture
  28519. * @returns a new render target cube texture stored in an InternalTexture
  28520. */
  28521. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  28522. /**
  28523. * Creates a cube texture
  28524. * @param rootUrl defines the url where the files to load is located
  28525. * @param scene defines the current scene
  28526. * @param files defines the list of files to load (1 per face)
  28527. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  28528. * @param onLoad defines an optional callback raised when the texture is loaded
  28529. * @param onError defines an optional callback raised if there is an issue to load the texture
  28530. * @param format defines the format of the data
  28531. * @param forcedExtension defines the extension to use to pick the right loader
  28532. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  28533. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  28534. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  28535. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  28536. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  28537. * @returns the cube texture as an InternalTexture
  28538. */
  28539. 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;
  28540. /**
  28541. * @hidden
  28542. */
  28543. _setCubeMapTextureParams(loadMipmap: boolean): void;
  28544. /**
  28545. * Update a raw cube texture
  28546. * @param texture defines the texture to udpdate
  28547. * @param data defines the data to store
  28548. * @param format defines the data format
  28549. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28550. * @param invertY defines if data must be stored with Y axis inverted
  28551. * @param compression defines the compression used (null by default)
  28552. * @param level defines which level of the texture to update
  28553. */
  28554. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  28555. /**
  28556. * Creates a new raw cube texture
  28557. * @param data defines the array of data to use to create each face
  28558. * @param size defines the size of the textures
  28559. * @param format defines the format of the data
  28560. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28561. * @param generateMipMaps defines if the engine should generate the mip levels
  28562. * @param invertY defines if data must be stored with Y axis inverted
  28563. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28564. * @param compression defines the compression used (null by default)
  28565. * @returns the cube texture as an InternalTexture
  28566. */
  28567. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  28568. /**
  28569. * Creates a new raw cube texture from a specified url
  28570. * @param url defines the url where the data is located
  28571. * @param scene defines the current scene
  28572. * @param size defines the size of the textures
  28573. * @param format defines the format of the data
  28574. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28575. * @param noMipmap defines if the engine should avoid generating the mip levels
  28576. * @param callback defines a callback used to extract texture data from loaded data
  28577. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  28578. * @param onLoad defines a callback called when texture is loaded
  28579. * @param onError defines a callback called if there is an error
  28580. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28581. * @param invertY defines if data must be stored with Y axis inverted
  28582. * @returns the cube texture as an InternalTexture
  28583. */
  28584. 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;
  28585. /**
  28586. * Update a raw 3D texture
  28587. * @param texture defines the texture to update
  28588. * @param data defines the data to store
  28589. * @param format defines the data format
  28590. * @param invertY defines if data must be stored with Y axis inverted
  28591. * @param compression defines the used compression (can be null)
  28592. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  28593. */
  28594. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  28595. /**
  28596. * Creates a new raw 3D texture
  28597. * @param data defines the data used to create the texture
  28598. * @param width defines the width of the texture
  28599. * @param height defines the height of the texture
  28600. * @param depth defines the depth of the texture
  28601. * @param format defines the format of the texture
  28602. * @param generateMipMaps defines if the engine must generate mip levels
  28603. * @param invertY defines if data must be stored with Y axis inverted
  28604. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28605. * @param compression defines the compressed used (can be null)
  28606. * @param textureType defines the compressed used (can be null)
  28607. * @returns a new raw 3D texture (stored in an InternalTexture)
  28608. */
  28609. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  28610. private _prepareWebGLTextureContinuation;
  28611. private _prepareWebGLTexture;
  28612. private _convertRGBtoRGBATextureData;
  28613. /** @hidden */
  28614. _releaseFramebufferObjects(texture: InternalTexture): void;
  28615. /** @hidden */
  28616. _releaseTexture(texture: InternalTexture): void;
  28617. private setProgram;
  28618. private _boundUniforms;
  28619. /**
  28620. * Binds an effect to the webGL context
  28621. * @param effect defines the effect to bind
  28622. */
  28623. bindSamplers(effect: Effect): void;
  28624. private _moveBoundTextureOnTop;
  28625. private _getCorrectTextureChannel;
  28626. private _linkTrackers;
  28627. private _removeDesignatedSlot;
  28628. private _activateCurrentTexture;
  28629. /** @hidden */
  28630. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28631. /** @hidden */
  28632. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28633. /**
  28634. * Sets a texture to the webGL context from a postprocess
  28635. * @param channel defines the channel to use
  28636. * @param postProcess defines the source postprocess
  28637. */
  28638. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28639. /**
  28640. * Binds the output of the passed in post process to the texture channel specified
  28641. * @param channel The channel the texture should be bound to
  28642. * @param postProcess The post process which's output should be bound
  28643. */
  28644. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28645. /**
  28646. * Unbind all textures from the webGL context
  28647. */
  28648. unbindAllTextures(): void;
  28649. /**
  28650. * Sets a texture to the according uniform.
  28651. * @param channel The texture channel
  28652. * @param uniform The uniform to set
  28653. * @param texture The texture to apply
  28654. */
  28655. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28656. /**
  28657. * Sets a depth stencil texture from a render target to the according uniform.
  28658. * @param channel The texture channel
  28659. * @param uniform The uniform to set
  28660. * @param texture The render target texture containing the depth stencil texture to apply
  28661. */
  28662. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28663. private _bindSamplerUniformToChannel;
  28664. private _getTextureWrapMode;
  28665. private _setTexture;
  28666. /**
  28667. * Sets an array of texture to the webGL context
  28668. * @param channel defines the channel where the texture array must be set
  28669. * @param uniform defines the associated uniform location
  28670. * @param textures defines the array of textures to bind
  28671. */
  28672. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28673. /** @hidden */
  28674. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28675. private _setTextureParameterFloat;
  28676. private _setTextureParameterInteger;
  28677. /**
  28678. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28679. * @param x defines the x coordinate of the rectangle where pixels must be read
  28680. * @param y defines the y coordinate of the rectangle where pixels must be read
  28681. * @param width defines the width of the rectangle where pixels must be read
  28682. * @param height defines the height of the rectangle where pixels must be read
  28683. * @returns a Uint8Array containing RGBA colors
  28684. */
  28685. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28686. /**
  28687. * Add an externaly attached data from its key.
  28688. * This method call will fail and return false, if such key already exists.
  28689. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28690. * @param key the unique key that identifies the data
  28691. * @param data the data object to associate to the key for this Engine instance
  28692. * @return true if no such key were already present and the data was added successfully, false otherwise
  28693. */
  28694. addExternalData<T>(key: string, data: T): boolean;
  28695. /**
  28696. * Get an externaly attached data from its key
  28697. * @param key the unique key that identifies the data
  28698. * @return the associated data, if present (can be null), or undefined if not present
  28699. */
  28700. getExternalData<T>(key: string): T;
  28701. /**
  28702. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28703. * @param key the unique key that identifies the data
  28704. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28705. * @return the associated data, can be null if the factory returned null.
  28706. */
  28707. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28708. /**
  28709. * Remove an externaly attached data from the Engine instance
  28710. * @param key the unique key that identifies the data
  28711. * @return true if the data was successfully removed, false if it doesn't exist
  28712. */
  28713. removeExternalData(key: string): boolean;
  28714. /**
  28715. * Unbind all vertex attributes from the webGL context
  28716. */
  28717. unbindAllAttributes(): void;
  28718. /**
  28719. * 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
  28720. */
  28721. releaseEffects(): void;
  28722. /**
  28723. * Dispose and release all associated resources
  28724. */
  28725. dispose(): void;
  28726. /**
  28727. * Display the loading screen
  28728. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28729. */
  28730. displayLoadingUI(): void;
  28731. /**
  28732. * Hide the loading screen
  28733. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28734. */
  28735. hideLoadingUI(): void;
  28736. /**
  28737. * Gets the current loading screen object
  28738. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28739. */
  28740. /**
  28741. * Sets the current loading screen object
  28742. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28743. */
  28744. loadingScreen: ILoadingScreen;
  28745. /**
  28746. * Sets the current loading screen text
  28747. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28748. */
  28749. loadingUIText: string;
  28750. /**
  28751. * Sets the current loading screen background color
  28752. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28753. */
  28754. loadingUIBackgroundColor: string;
  28755. /**
  28756. * Attach a new callback raised when context lost event is fired
  28757. * @param callback defines the callback to call
  28758. */
  28759. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28760. /**
  28761. * Attach a new callback raised when context restored event is fired
  28762. * @param callback defines the callback to call
  28763. */
  28764. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28765. /**
  28766. * Gets the source code of the vertex shader associated with a specific webGL program
  28767. * @param program defines the program to use
  28768. * @returns a string containing the source code of the vertex shader associated with the program
  28769. */
  28770. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28771. /**
  28772. * Gets the source code of the fragment shader associated with a specific webGL program
  28773. * @param program defines the program to use
  28774. * @returns a string containing the source code of the fragment shader associated with the program
  28775. */
  28776. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28777. /**
  28778. * Get the current error code of the webGL context
  28779. * @returns the error code
  28780. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28781. */
  28782. getError(): number;
  28783. /**
  28784. * Gets the current framerate
  28785. * @returns a number representing the framerate
  28786. */
  28787. getFps(): number;
  28788. /**
  28789. * Gets the time spent between current and previous frame
  28790. * @returns a number representing the delta time in ms
  28791. */
  28792. getDeltaTime(): number;
  28793. private _measureFps;
  28794. /** @hidden */
  28795. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28796. private _canRenderToFloatFramebuffer;
  28797. private _canRenderToHalfFloatFramebuffer;
  28798. private _canRenderToFramebuffer;
  28799. /** @hidden */
  28800. _getWebGLTextureType(type: number): number;
  28801. private _getInternalFormat;
  28802. /** @hidden */
  28803. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28804. /** @hidden */
  28805. _getRGBAMultiSampleBufferFormat(type: number): number;
  28806. /** @hidden */
  28807. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  28808. /** @hidden */
  28809. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  28810. private _partialLoadFile;
  28811. private _cascadeLoadFiles;
  28812. /**
  28813. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  28814. * @returns true if the engine can be created
  28815. * @ignorenaming
  28816. */
  28817. static isSupported(): boolean;
  28818. }
  28819. }
  28820. declare module "babylonjs/Materials/effect" {
  28821. import { Observable } from "babylonjs/Misc/observable";
  28822. import { Nullable } from "babylonjs/types";
  28823. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  28824. import { Engine } from "babylonjs/Engines/engine";
  28825. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28826. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28827. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28828. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28829. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28830. /**
  28831. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28832. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28833. */
  28834. export class EffectFallbacks {
  28835. private _defines;
  28836. private _currentRank;
  28837. private _maxRank;
  28838. private _mesh;
  28839. /**
  28840. * Removes the fallback from the bound mesh.
  28841. */
  28842. unBindMesh(): void;
  28843. /**
  28844. * Adds a fallback on the specified property.
  28845. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28846. * @param define The name of the define in the shader
  28847. */
  28848. addFallback(rank: number, define: string): void;
  28849. /**
  28850. * Sets the mesh to use CPU skinning when needing to fallback.
  28851. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28852. * @param mesh The mesh to use the fallbacks.
  28853. */
  28854. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28855. /**
  28856. * Checks to see if more fallbacks are still availible.
  28857. */
  28858. readonly isMoreFallbacks: boolean;
  28859. /**
  28860. * Removes the defines that shoould be removed when falling back.
  28861. * @param currentDefines defines the current define statements for the shader.
  28862. * @param effect defines the current effect we try to compile
  28863. * @returns The resulting defines with defines of the current rank removed.
  28864. */
  28865. reduce(currentDefines: string, effect: Effect): string;
  28866. }
  28867. /**
  28868. * Options to be used when creating an effect.
  28869. */
  28870. export class EffectCreationOptions {
  28871. /**
  28872. * Atrributes that will be used in the shader.
  28873. */
  28874. attributes: string[];
  28875. /**
  28876. * Uniform varible names that will be set in the shader.
  28877. */
  28878. uniformsNames: string[];
  28879. /**
  28880. * Uniform buffer varible names that will be set in the shader.
  28881. */
  28882. uniformBuffersNames: string[];
  28883. /**
  28884. * Sampler texture variable names that will be set in the shader.
  28885. */
  28886. samplers: string[];
  28887. /**
  28888. * Define statements that will be set in the shader.
  28889. */
  28890. defines: any;
  28891. /**
  28892. * Possible fallbacks for this effect to improve performance when needed.
  28893. */
  28894. fallbacks: Nullable<EffectFallbacks>;
  28895. /**
  28896. * Callback that will be called when the shader is compiled.
  28897. */
  28898. onCompiled: Nullable<(effect: Effect) => void>;
  28899. /**
  28900. * Callback that will be called if an error occurs during shader compilation.
  28901. */
  28902. onError: Nullable<(effect: Effect, errors: string) => void>;
  28903. /**
  28904. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28905. */
  28906. indexParameters: any;
  28907. /**
  28908. * Max number of lights that can be used in the shader.
  28909. */
  28910. maxSimultaneousLights: number;
  28911. /**
  28912. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28913. */
  28914. transformFeedbackVaryings: Nullable<string[]>;
  28915. }
  28916. /**
  28917. * Effect containing vertex and fragment shader that can be executed on an object.
  28918. */
  28919. export class Effect {
  28920. /**
  28921. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28922. */
  28923. static ShadersRepository: string;
  28924. /**
  28925. * Name of the effect.
  28926. */
  28927. name: any;
  28928. /**
  28929. * String container all the define statements that should be set on the shader.
  28930. */
  28931. defines: string;
  28932. /**
  28933. * Callback that will be called when the shader is compiled.
  28934. */
  28935. onCompiled: Nullable<(effect: Effect) => void>;
  28936. /**
  28937. * Callback that will be called if an error occurs during shader compilation.
  28938. */
  28939. onError: Nullable<(effect: Effect, errors: string) => void>;
  28940. /**
  28941. * Callback that will be called when effect is bound.
  28942. */
  28943. onBind: Nullable<(effect: Effect) => void>;
  28944. /**
  28945. * Unique ID of the effect.
  28946. */
  28947. uniqueId: number;
  28948. /**
  28949. * Observable that will be called when the shader is compiled.
  28950. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28951. */
  28952. onCompileObservable: Observable<Effect>;
  28953. /**
  28954. * Observable that will be called if an error occurs during shader compilation.
  28955. */
  28956. onErrorObservable: Observable<Effect>;
  28957. /** @hidden */
  28958. _onBindObservable: Nullable<Observable<Effect>>;
  28959. /**
  28960. * Observable that will be called when effect is bound.
  28961. */
  28962. readonly onBindObservable: Observable<Effect>;
  28963. /** @hidden */
  28964. _bonesComputationForcedToCPU: boolean;
  28965. private static _uniqueIdSeed;
  28966. private _engine;
  28967. private _uniformBuffersNames;
  28968. private _uniformsNames;
  28969. private _samplers;
  28970. private _isReady;
  28971. private _compilationError;
  28972. private _attributesNames;
  28973. private _attributes;
  28974. private _uniforms;
  28975. /**
  28976. * Key for the effect.
  28977. * @hidden
  28978. */
  28979. _key: string;
  28980. private _indexParameters;
  28981. private _fallbacks;
  28982. private _vertexSourceCode;
  28983. private _fragmentSourceCode;
  28984. private _vertexSourceCodeOverride;
  28985. private _fragmentSourceCodeOverride;
  28986. private _transformFeedbackVaryings;
  28987. /**
  28988. * Compiled shader to webGL program.
  28989. * @hidden
  28990. */
  28991. _program: WebGLProgram;
  28992. private _valueCache;
  28993. private static _baseCache;
  28994. /**
  28995. * Instantiates an effect.
  28996. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28997. * @param baseName Name of the effect.
  28998. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28999. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29000. * @param samplers List of sampler variables that will be passed to the shader.
  29001. * @param engine Engine to be used to render the effect
  29002. * @param defines Define statements to be added to the shader.
  29003. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29004. * @param onCompiled Callback that will be called when the shader is compiled.
  29005. * @param onError Callback that will be called if an error occurs during shader compilation.
  29006. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29007. */
  29008. 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);
  29009. /**
  29010. * Unique key for this effect
  29011. */
  29012. readonly key: string;
  29013. /**
  29014. * If the effect has been compiled and prepared.
  29015. * @returns if the effect is compiled and prepared.
  29016. */
  29017. isReady(): boolean;
  29018. /**
  29019. * The engine the effect was initialized with.
  29020. * @returns the engine.
  29021. */
  29022. getEngine(): Engine;
  29023. /**
  29024. * The compiled webGL program for the effect
  29025. * @returns the webGL program.
  29026. */
  29027. getProgram(): WebGLProgram;
  29028. /**
  29029. * The set of names of attribute variables for the shader.
  29030. * @returns An array of attribute names.
  29031. */
  29032. getAttributesNames(): string[];
  29033. /**
  29034. * Returns the attribute at the given index.
  29035. * @param index The index of the attribute.
  29036. * @returns The location of the attribute.
  29037. */
  29038. getAttributeLocation(index: number): number;
  29039. /**
  29040. * Returns the attribute based on the name of the variable.
  29041. * @param name of the attribute to look up.
  29042. * @returns the attribute location.
  29043. */
  29044. getAttributeLocationByName(name: string): number;
  29045. /**
  29046. * The number of attributes.
  29047. * @returns the numnber of attributes.
  29048. */
  29049. getAttributesCount(): number;
  29050. /**
  29051. * Gets the index of a uniform variable.
  29052. * @param uniformName of the uniform to look up.
  29053. * @returns the index.
  29054. */
  29055. getUniformIndex(uniformName: string): number;
  29056. /**
  29057. * Returns the attribute based on the name of the variable.
  29058. * @param uniformName of the uniform to look up.
  29059. * @returns the location of the uniform.
  29060. */
  29061. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29062. /**
  29063. * Returns an array of sampler variable names
  29064. * @returns The array of sampler variable neames.
  29065. */
  29066. getSamplers(): string[];
  29067. /**
  29068. * The error from the last compilation.
  29069. * @returns the error string.
  29070. */
  29071. getCompilationError(): string;
  29072. /**
  29073. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29074. * @param func The callback to be used.
  29075. */
  29076. executeWhenCompiled(func: (effect: Effect) => void): void;
  29077. private _checkIsReady;
  29078. /** @hidden */
  29079. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29080. /** @hidden */
  29081. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29082. /** @hidden */
  29083. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29084. private _processShaderConversion;
  29085. private _processIncludes;
  29086. private _processPrecision;
  29087. /**
  29088. * Recompiles the webGL program
  29089. * @param vertexSourceCode The source code for the vertex shader.
  29090. * @param fragmentSourceCode The source code for the fragment shader.
  29091. * @param onCompiled Callback called when completed.
  29092. * @param onError Callback called on error.
  29093. * @hidden
  29094. */
  29095. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  29096. /**
  29097. * Gets the uniform locations of the the specified variable names
  29098. * @param names THe names of the variables to lookup.
  29099. * @returns Array of locations in the same order as variable names.
  29100. */
  29101. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  29102. /**
  29103. * Prepares the effect
  29104. * @hidden
  29105. */
  29106. _prepareEffect(): void;
  29107. /**
  29108. * Checks if the effect is supported. (Must be called after compilation)
  29109. */
  29110. readonly isSupported: boolean;
  29111. /**
  29112. * Binds a texture to the engine to be used as output of the shader.
  29113. * @param channel Name of the output variable.
  29114. * @param texture Texture to bind.
  29115. * @hidden
  29116. */
  29117. _bindTexture(channel: string, texture: InternalTexture): void;
  29118. /**
  29119. * Sets a texture on the engine to be used in the shader.
  29120. * @param channel Name of the sampler variable.
  29121. * @param texture Texture to set.
  29122. */
  29123. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29124. /**
  29125. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29126. * @param channel Name of the sampler variable.
  29127. * @param texture Texture to set.
  29128. */
  29129. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29130. /**
  29131. * Sets an array of textures on the engine to be used in the shader.
  29132. * @param channel Name of the variable.
  29133. * @param textures Textures to set.
  29134. */
  29135. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29136. /**
  29137. * 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)
  29138. * @param channel Name of the sampler variable.
  29139. * @param postProcess Post process to get the input texture from.
  29140. */
  29141. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29142. /**
  29143. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29144. * 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)
  29145. * @param channel Name of the sampler variable.
  29146. * @param postProcess Post process to get the output texture from.
  29147. */
  29148. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29149. /** @hidden */
  29150. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29151. /** @hidden */
  29152. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29153. /** @hidden */
  29154. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29155. /** @hidden */
  29156. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29157. /**
  29158. * Binds a buffer to a uniform.
  29159. * @param buffer Buffer to bind.
  29160. * @param name Name of the uniform variable to bind to.
  29161. */
  29162. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  29163. /**
  29164. * Binds block to a uniform.
  29165. * @param blockName Name of the block to bind.
  29166. * @param index Index to bind.
  29167. */
  29168. bindUniformBlock(blockName: string, index: number): void;
  29169. /**
  29170. * Sets an interger value on a uniform variable.
  29171. * @param uniformName Name of the variable.
  29172. * @param value Value to be set.
  29173. * @returns this effect.
  29174. */
  29175. setInt(uniformName: string, value: number): Effect;
  29176. /**
  29177. * Sets an int array on a uniform variable.
  29178. * @param uniformName Name of the variable.
  29179. * @param array array to be set.
  29180. * @returns this effect.
  29181. */
  29182. setIntArray(uniformName: string, array: Int32Array): Effect;
  29183. /**
  29184. * 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)
  29185. * @param uniformName Name of the variable.
  29186. * @param array array to be set.
  29187. * @returns this effect.
  29188. */
  29189. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29190. /**
  29191. * 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)
  29192. * @param uniformName Name of the variable.
  29193. * @param array array to be set.
  29194. * @returns this effect.
  29195. */
  29196. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29197. /**
  29198. * 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)
  29199. * @param uniformName Name of the variable.
  29200. * @param array array to be set.
  29201. * @returns this effect.
  29202. */
  29203. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29204. /**
  29205. * Sets an float array on a uniform variable.
  29206. * @param uniformName Name of the variable.
  29207. * @param array array to be set.
  29208. * @returns this effect.
  29209. */
  29210. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29211. /**
  29212. * 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)
  29213. * @param uniformName Name of the variable.
  29214. * @param array array to be set.
  29215. * @returns this effect.
  29216. */
  29217. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29218. /**
  29219. * 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)
  29220. * @param uniformName Name of the variable.
  29221. * @param array array to be set.
  29222. * @returns this effect.
  29223. */
  29224. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29225. /**
  29226. * 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)
  29227. * @param uniformName Name of the variable.
  29228. * @param array array to be set.
  29229. * @returns this effect.
  29230. */
  29231. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29232. /**
  29233. * Sets an array on a uniform variable.
  29234. * @param uniformName Name of the variable.
  29235. * @param array array to be set.
  29236. * @returns this effect.
  29237. */
  29238. setArray(uniformName: string, array: number[]): Effect;
  29239. /**
  29240. * 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)
  29241. * @param uniformName Name of the variable.
  29242. * @param array array to be set.
  29243. * @returns this effect.
  29244. */
  29245. setArray2(uniformName: string, array: number[]): Effect;
  29246. /**
  29247. * 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)
  29248. * @param uniformName Name of the variable.
  29249. * @param array array to be set.
  29250. * @returns this effect.
  29251. */
  29252. setArray3(uniformName: string, array: number[]): Effect;
  29253. /**
  29254. * 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)
  29255. * @param uniformName Name of the variable.
  29256. * @param array array to be set.
  29257. * @returns this effect.
  29258. */
  29259. setArray4(uniformName: string, array: number[]): Effect;
  29260. /**
  29261. * Sets matrices on a uniform variable.
  29262. * @param uniformName Name of the variable.
  29263. * @param matrices matrices to be set.
  29264. * @returns this effect.
  29265. */
  29266. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29267. /**
  29268. * Sets matrix on a uniform variable.
  29269. * @param uniformName Name of the variable.
  29270. * @param matrix matrix to be set.
  29271. * @returns this effect.
  29272. */
  29273. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29274. /**
  29275. * 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)
  29276. * @param uniformName Name of the variable.
  29277. * @param matrix matrix to be set.
  29278. * @returns this effect.
  29279. */
  29280. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29281. /**
  29282. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29283. * @param uniformName Name of the variable.
  29284. * @param matrix matrix to be set.
  29285. * @returns this effect.
  29286. */
  29287. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29288. /**
  29289. * Sets a float on a uniform variable.
  29290. * @param uniformName Name of the variable.
  29291. * @param value value to be set.
  29292. * @returns this effect.
  29293. */
  29294. setFloat(uniformName: string, value: number): Effect;
  29295. /**
  29296. * Sets a boolean on a uniform variable.
  29297. * @param uniformName Name of the variable.
  29298. * @param bool value to be set.
  29299. * @returns this effect.
  29300. */
  29301. setBool(uniformName: string, bool: boolean): Effect;
  29302. /**
  29303. * Sets a Vector2 on a uniform variable.
  29304. * @param uniformName Name of the variable.
  29305. * @param vector2 vector2 to be set.
  29306. * @returns this effect.
  29307. */
  29308. setVector2(uniformName: string, vector2: Vector2): Effect;
  29309. /**
  29310. * Sets a float2 on a uniform variable.
  29311. * @param uniformName Name of the variable.
  29312. * @param x First float in float2.
  29313. * @param y Second float in float2.
  29314. * @returns this effect.
  29315. */
  29316. setFloat2(uniformName: string, x: number, y: number): Effect;
  29317. /**
  29318. * Sets a Vector3 on a uniform variable.
  29319. * @param uniformName Name of the variable.
  29320. * @param vector3 Value to be set.
  29321. * @returns this effect.
  29322. */
  29323. setVector3(uniformName: string, vector3: Vector3): Effect;
  29324. /**
  29325. * Sets a float3 on a uniform variable.
  29326. * @param uniformName Name of the variable.
  29327. * @param x First float in float3.
  29328. * @param y Second float in float3.
  29329. * @param z Third float in float3.
  29330. * @returns this effect.
  29331. */
  29332. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29333. /**
  29334. * Sets a Vector4 on a uniform variable.
  29335. * @param uniformName Name of the variable.
  29336. * @param vector4 Value to be set.
  29337. * @returns this effect.
  29338. */
  29339. setVector4(uniformName: string, vector4: Vector4): Effect;
  29340. /**
  29341. * Sets a float4 on a uniform variable.
  29342. * @param uniformName Name of the variable.
  29343. * @param x First float in float4.
  29344. * @param y Second float in float4.
  29345. * @param z Third float in float4.
  29346. * @param w Fourth float in float4.
  29347. * @returns this effect.
  29348. */
  29349. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29350. /**
  29351. * Sets a Color3 on a uniform variable.
  29352. * @param uniformName Name of the variable.
  29353. * @param color3 Value to be set.
  29354. * @returns this effect.
  29355. */
  29356. setColor3(uniformName: string, color3: Color3): Effect;
  29357. /**
  29358. * Sets a Color4 on a uniform variable.
  29359. * @param uniformName Name of the variable.
  29360. * @param color3 Value to be set.
  29361. * @param alpha Alpha value to be set.
  29362. * @returns this effect.
  29363. */
  29364. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29365. /**
  29366. * Sets a Color4 on a uniform variable
  29367. * @param uniformName defines the name of the variable
  29368. * @param color4 defines the value to be set
  29369. * @returns this effect.
  29370. */
  29371. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29372. /**
  29373. * This function will add a new shader to the shader store
  29374. * @param name the name of the shader
  29375. * @param pixelShader optional pixel shader content
  29376. * @param vertexShader optional vertex shader content
  29377. */
  29378. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29379. /**
  29380. * Store of each shader (The can be looked up using effect.key)
  29381. */
  29382. static ShadersStore: {
  29383. [key: string]: string;
  29384. };
  29385. /**
  29386. * Store of each included file for a shader (The can be looked up using effect.key)
  29387. */
  29388. static IncludesShadersStore: {
  29389. [key: string]: string;
  29390. };
  29391. /**
  29392. * Resets the cache of effects.
  29393. */
  29394. static ResetCache(): void;
  29395. }
  29396. }
  29397. declare module "babylonjs/Materials/colorCurves" {
  29398. import { Effect } from "babylonjs/Materials/effect";
  29399. /**
  29400. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29401. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29402. * 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;
  29403. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29404. */
  29405. export class ColorCurves {
  29406. private _dirty;
  29407. private _tempColor;
  29408. private _globalCurve;
  29409. private _highlightsCurve;
  29410. private _midtonesCurve;
  29411. private _shadowsCurve;
  29412. private _positiveCurve;
  29413. private _negativeCurve;
  29414. private _globalHue;
  29415. private _globalDensity;
  29416. private _globalSaturation;
  29417. private _globalExposure;
  29418. /**
  29419. * Gets the global Hue value.
  29420. * 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).
  29421. */
  29422. /**
  29423. * Sets the global Hue value.
  29424. * 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).
  29425. */
  29426. globalHue: number;
  29427. /**
  29428. * Gets the global Density value.
  29429. * 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.
  29430. * Values less than zero provide a filter of opposite hue.
  29431. */
  29432. /**
  29433. * Sets the global Density value.
  29434. * 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.
  29435. * Values less than zero provide a filter of opposite hue.
  29436. */
  29437. globalDensity: number;
  29438. /**
  29439. * Gets the global Saturation value.
  29440. * 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.
  29441. */
  29442. /**
  29443. * Sets the global Saturation value.
  29444. * 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.
  29445. */
  29446. globalSaturation: number;
  29447. /**
  29448. * Gets the global Exposure value.
  29449. * 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.
  29450. */
  29451. /**
  29452. * Sets the global Exposure value.
  29453. * 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.
  29454. */
  29455. globalExposure: number;
  29456. private _highlightsHue;
  29457. private _highlightsDensity;
  29458. private _highlightsSaturation;
  29459. private _highlightsExposure;
  29460. /**
  29461. * Gets the highlights Hue value.
  29462. * 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).
  29463. */
  29464. /**
  29465. * Sets the highlights Hue value.
  29466. * 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).
  29467. */
  29468. highlightsHue: number;
  29469. /**
  29470. * Gets the highlights Density value.
  29471. * 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.
  29472. * Values less than zero provide a filter of opposite hue.
  29473. */
  29474. /**
  29475. * Sets the highlights Density value.
  29476. * 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.
  29477. * Values less than zero provide a filter of opposite hue.
  29478. */
  29479. highlightsDensity: number;
  29480. /**
  29481. * Gets the highlights Saturation value.
  29482. * 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.
  29483. */
  29484. /**
  29485. * Sets the highlights Saturation value.
  29486. * 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.
  29487. */
  29488. highlightsSaturation: number;
  29489. /**
  29490. * Gets the highlights Exposure value.
  29491. * 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.
  29492. */
  29493. /**
  29494. * Sets the highlights Exposure value.
  29495. * 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.
  29496. */
  29497. highlightsExposure: number;
  29498. private _midtonesHue;
  29499. private _midtonesDensity;
  29500. private _midtonesSaturation;
  29501. private _midtonesExposure;
  29502. /**
  29503. * Gets the midtones Hue value.
  29504. * 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).
  29505. */
  29506. /**
  29507. * Sets the midtones Hue value.
  29508. * 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).
  29509. */
  29510. midtonesHue: number;
  29511. /**
  29512. * Gets the midtones Density value.
  29513. * 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.
  29514. * Values less than zero provide a filter of opposite hue.
  29515. */
  29516. /**
  29517. * Sets the midtones Density value.
  29518. * 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.
  29519. * Values less than zero provide a filter of opposite hue.
  29520. */
  29521. midtonesDensity: number;
  29522. /**
  29523. * Gets the midtones Saturation value.
  29524. * 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.
  29525. */
  29526. /**
  29527. * Sets the midtones Saturation value.
  29528. * 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.
  29529. */
  29530. midtonesSaturation: number;
  29531. /**
  29532. * Gets the midtones Exposure value.
  29533. * 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.
  29534. */
  29535. /**
  29536. * Sets the midtones Exposure value.
  29537. * 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.
  29538. */
  29539. midtonesExposure: number;
  29540. private _shadowsHue;
  29541. private _shadowsDensity;
  29542. private _shadowsSaturation;
  29543. private _shadowsExposure;
  29544. /**
  29545. * Gets the shadows Hue value.
  29546. * 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).
  29547. */
  29548. /**
  29549. * Sets the shadows Hue value.
  29550. * 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).
  29551. */
  29552. shadowsHue: number;
  29553. /**
  29554. * Gets the shadows Density value.
  29555. * 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.
  29556. * Values less than zero provide a filter of opposite hue.
  29557. */
  29558. /**
  29559. * Sets the shadows Density value.
  29560. * 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.
  29561. * Values less than zero provide a filter of opposite hue.
  29562. */
  29563. shadowsDensity: number;
  29564. /**
  29565. * Gets the shadows Saturation value.
  29566. * 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.
  29567. */
  29568. /**
  29569. * Sets the shadows Saturation value.
  29570. * 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.
  29571. */
  29572. shadowsSaturation: number;
  29573. /**
  29574. * Gets the shadows Exposure value.
  29575. * 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.
  29576. */
  29577. /**
  29578. * Sets the shadows Exposure value.
  29579. * 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.
  29580. */
  29581. shadowsExposure: number;
  29582. /**
  29583. * Returns the class name
  29584. * @returns The class name
  29585. */
  29586. getClassName(): string;
  29587. /**
  29588. * Binds the color curves to the shader.
  29589. * @param colorCurves The color curve to bind
  29590. * @param effect The effect to bind to
  29591. * @param positiveUniform The positive uniform shader parameter
  29592. * @param neutralUniform The neutral uniform shader parameter
  29593. * @param negativeUniform The negative uniform shader parameter
  29594. */
  29595. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29596. /**
  29597. * Prepare the list of uniforms associated with the ColorCurves effects.
  29598. * @param uniformsList The list of uniforms used in the effect
  29599. */
  29600. static PrepareUniforms(uniformsList: string[]): void;
  29601. /**
  29602. * Returns color grading data based on a hue, density, saturation and exposure value.
  29603. * @param filterHue The hue of the color filter.
  29604. * @param filterDensity The density of the color filter.
  29605. * @param saturation The saturation.
  29606. * @param exposure The exposure.
  29607. * @param result The result data container.
  29608. */
  29609. private getColorGradingDataToRef;
  29610. /**
  29611. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29612. * @param value The input slider value in range [-100,100].
  29613. * @returns Adjusted value.
  29614. */
  29615. private static applyColorGradingSliderNonlinear;
  29616. /**
  29617. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29618. * @param hue The hue (H) input.
  29619. * @param saturation The saturation (S) input.
  29620. * @param brightness The brightness (B) input.
  29621. * @result An RGBA color represented as Vector4.
  29622. */
  29623. private static fromHSBToRef;
  29624. /**
  29625. * Returns a value clamped between min and max
  29626. * @param value The value to clamp
  29627. * @param min The minimum of value
  29628. * @param max The maximum of value
  29629. * @returns The clamped value.
  29630. */
  29631. private static clamp;
  29632. /**
  29633. * Clones the current color curve instance.
  29634. * @return The cloned curves
  29635. */
  29636. clone(): ColorCurves;
  29637. /**
  29638. * Serializes the current color curve instance to a json representation.
  29639. * @return a JSON representation
  29640. */
  29641. serialize(): any;
  29642. /**
  29643. * Parses the color curve from a json representation.
  29644. * @param source the JSON source to parse
  29645. * @return The parsed curves
  29646. */
  29647. static Parse(source: any): ColorCurves;
  29648. }
  29649. }
  29650. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  29651. import { Observable } from "babylonjs/Misc/observable";
  29652. import { Nullable } from "babylonjs/types";
  29653. import { Color4 } from "babylonjs/Maths/math";
  29654. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  29655. import { Effect } from "babylonjs/Materials/effect";
  29656. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29657. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  29658. /**
  29659. * Interface to follow in your material defines to integrate easily the
  29660. * Image proccessing functions.
  29661. * @hidden
  29662. */
  29663. export interface IImageProcessingConfigurationDefines {
  29664. IMAGEPROCESSING: boolean;
  29665. VIGNETTE: boolean;
  29666. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29667. VIGNETTEBLENDMODEOPAQUE: boolean;
  29668. TONEMAPPING: boolean;
  29669. TONEMAPPING_ACES: boolean;
  29670. CONTRAST: boolean;
  29671. EXPOSURE: boolean;
  29672. COLORCURVES: boolean;
  29673. COLORGRADING: boolean;
  29674. COLORGRADING3D: boolean;
  29675. SAMPLER3DGREENDEPTH: boolean;
  29676. SAMPLER3DBGRMAP: boolean;
  29677. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29678. }
  29679. /**
  29680. * @hidden
  29681. */
  29682. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29683. IMAGEPROCESSING: boolean;
  29684. VIGNETTE: boolean;
  29685. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29686. VIGNETTEBLENDMODEOPAQUE: boolean;
  29687. TONEMAPPING: boolean;
  29688. TONEMAPPING_ACES: boolean;
  29689. CONTRAST: boolean;
  29690. COLORCURVES: boolean;
  29691. COLORGRADING: boolean;
  29692. COLORGRADING3D: boolean;
  29693. SAMPLER3DGREENDEPTH: boolean;
  29694. SAMPLER3DBGRMAP: boolean;
  29695. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29696. EXPOSURE: boolean;
  29697. constructor();
  29698. }
  29699. /**
  29700. * This groups together the common properties used for image processing either in direct forward pass
  29701. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29702. * or not.
  29703. */
  29704. export class ImageProcessingConfiguration {
  29705. /**
  29706. * Default tone mapping applied in BabylonJS.
  29707. */
  29708. static readonly TONEMAPPING_STANDARD: number;
  29709. /**
  29710. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29711. * to other engines rendering to increase portability.
  29712. */
  29713. static readonly TONEMAPPING_ACES: number;
  29714. /**
  29715. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29716. */
  29717. colorCurves: Nullable<ColorCurves>;
  29718. private _colorCurvesEnabled;
  29719. /**
  29720. * Gets wether the color curves effect is enabled.
  29721. */
  29722. /**
  29723. * Sets wether the color curves effect is enabled.
  29724. */
  29725. colorCurvesEnabled: boolean;
  29726. private _colorGradingTexture;
  29727. /**
  29728. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29729. */
  29730. /**
  29731. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29732. */
  29733. colorGradingTexture: Nullable<BaseTexture>;
  29734. private _colorGradingEnabled;
  29735. /**
  29736. * Gets wether the color grading effect is enabled.
  29737. */
  29738. /**
  29739. * Sets wether the color grading effect is enabled.
  29740. */
  29741. colorGradingEnabled: boolean;
  29742. private _colorGradingWithGreenDepth;
  29743. /**
  29744. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29745. */
  29746. /**
  29747. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29748. */
  29749. colorGradingWithGreenDepth: boolean;
  29750. private _colorGradingBGR;
  29751. /**
  29752. * Gets wether the color grading texture contains BGR values.
  29753. */
  29754. /**
  29755. * Sets wether the color grading texture contains BGR values.
  29756. */
  29757. colorGradingBGR: boolean;
  29758. /** @hidden */
  29759. _exposure: number;
  29760. /**
  29761. * Gets the Exposure used in the effect.
  29762. */
  29763. /**
  29764. * Sets the Exposure used in the effect.
  29765. */
  29766. exposure: number;
  29767. private _toneMappingEnabled;
  29768. /**
  29769. * Gets wether the tone mapping effect is enabled.
  29770. */
  29771. /**
  29772. * Sets wether the tone mapping effect is enabled.
  29773. */
  29774. toneMappingEnabled: boolean;
  29775. private _toneMappingType;
  29776. /**
  29777. * Gets the type of tone mapping effect.
  29778. */
  29779. /**
  29780. * Sets the type of tone mapping effect used in BabylonJS.
  29781. */
  29782. toneMappingType: number;
  29783. protected _contrast: number;
  29784. /**
  29785. * Gets the contrast used in the effect.
  29786. */
  29787. /**
  29788. * Sets the contrast used in the effect.
  29789. */
  29790. contrast: number;
  29791. /**
  29792. * Vignette stretch size.
  29793. */
  29794. vignetteStretch: number;
  29795. /**
  29796. * Vignette centre X Offset.
  29797. */
  29798. vignetteCentreX: number;
  29799. /**
  29800. * Vignette centre Y Offset.
  29801. */
  29802. vignetteCentreY: number;
  29803. /**
  29804. * Vignette weight or intensity of the vignette effect.
  29805. */
  29806. vignetteWeight: number;
  29807. /**
  29808. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29809. * if vignetteEnabled is set to true.
  29810. */
  29811. vignetteColor: Color4;
  29812. /**
  29813. * Camera field of view used by the Vignette effect.
  29814. */
  29815. vignetteCameraFov: number;
  29816. private _vignetteBlendMode;
  29817. /**
  29818. * Gets the vignette blend mode allowing different kind of effect.
  29819. */
  29820. /**
  29821. * Sets the vignette blend mode allowing different kind of effect.
  29822. */
  29823. vignetteBlendMode: number;
  29824. private _vignetteEnabled;
  29825. /**
  29826. * Gets wether the vignette effect is enabled.
  29827. */
  29828. /**
  29829. * Sets wether the vignette effect is enabled.
  29830. */
  29831. vignetteEnabled: boolean;
  29832. private _applyByPostProcess;
  29833. /**
  29834. * Gets wether the image processing is applied through a post process or not.
  29835. */
  29836. /**
  29837. * Sets wether the image processing is applied through a post process or not.
  29838. */
  29839. applyByPostProcess: boolean;
  29840. private _isEnabled;
  29841. /**
  29842. * Gets wether the image processing is enabled or not.
  29843. */
  29844. /**
  29845. * Sets wether the image processing is enabled or not.
  29846. */
  29847. isEnabled: boolean;
  29848. /**
  29849. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  29850. */
  29851. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  29852. /**
  29853. * Method called each time the image processing information changes requires to recompile the effect.
  29854. */
  29855. protected _updateParameters(): void;
  29856. /**
  29857. * Gets the current class name.
  29858. * @return "ImageProcessingConfiguration"
  29859. */
  29860. getClassName(): string;
  29861. /**
  29862. * Prepare the list of uniforms associated with the Image Processing effects.
  29863. * @param uniforms The list of uniforms used in the effect
  29864. * @param defines the list of defines currently in use
  29865. */
  29866. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  29867. /**
  29868. * Prepare the list of samplers associated with the Image Processing effects.
  29869. * @param samplersList The list of uniforms used in the effect
  29870. * @param defines the list of defines currently in use
  29871. */
  29872. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  29873. /**
  29874. * Prepare the list of defines associated to the shader.
  29875. * @param defines the list of defines to complete
  29876. * @param forPostProcess Define if we are currently in post process mode or not
  29877. */
  29878. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  29879. /**
  29880. * Returns true if all the image processing information are ready.
  29881. * @returns True if ready, otherwise, false
  29882. */
  29883. isReady(): boolean;
  29884. /**
  29885. * Binds the image processing to the shader.
  29886. * @param effect The effect to bind to
  29887. * @param aspectRatio Define the current aspect ratio of the effect
  29888. */
  29889. bind(effect: Effect, aspectRatio?: number): void;
  29890. /**
  29891. * Clones the current image processing instance.
  29892. * @return The cloned image processing
  29893. */
  29894. clone(): ImageProcessingConfiguration;
  29895. /**
  29896. * Serializes the current image processing instance to a json representation.
  29897. * @return a JSON representation
  29898. */
  29899. serialize(): any;
  29900. /**
  29901. * Parses the image processing from a json representation.
  29902. * @param source the JSON source to parse
  29903. * @return The parsed image processing
  29904. */
  29905. static Parse(source: any): ImageProcessingConfiguration;
  29906. private static _VIGNETTEMODE_MULTIPLY;
  29907. private static _VIGNETTEMODE_OPAQUE;
  29908. /**
  29909. * Used to apply the vignette as a mix with the pixel color.
  29910. */
  29911. static readonly VIGNETTEMODE_MULTIPLY: number;
  29912. /**
  29913. * Used to apply the vignette as a replacement of the pixel color.
  29914. */
  29915. static readonly VIGNETTEMODE_OPAQUE: number;
  29916. }
  29917. }
  29918. declare module "babylonjs/Materials/fresnelParameters" {
  29919. import { Color3 } from "babylonjs/Maths/math";
  29920. /**
  29921. * This represents all the required information to add a fresnel effect on a material:
  29922. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29923. */
  29924. export class FresnelParameters {
  29925. private _isEnabled;
  29926. /**
  29927. * Define if the fresnel effect is enable or not.
  29928. */
  29929. isEnabled: boolean;
  29930. /**
  29931. * Define the color used on edges (grazing angle)
  29932. */
  29933. leftColor: Color3;
  29934. /**
  29935. * Define the color used on center
  29936. */
  29937. rightColor: Color3;
  29938. /**
  29939. * Define bias applied to computed fresnel term
  29940. */
  29941. bias: number;
  29942. /**
  29943. * Defined the power exponent applied to fresnel term
  29944. */
  29945. power: number;
  29946. /**
  29947. * Clones the current fresnel and its valuues
  29948. * @returns a clone fresnel configuration
  29949. */
  29950. clone(): FresnelParameters;
  29951. /**
  29952. * Serializes the current fresnel parameters to a JSON representation.
  29953. * @return the JSON serialization
  29954. */
  29955. serialize(): any;
  29956. /**
  29957. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29958. * @param parsedFresnelParameters Define the JSON representation
  29959. * @returns the parsed parameters
  29960. */
  29961. static Parse(parsedFresnelParameters: any): FresnelParameters;
  29962. }
  29963. }
  29964. declare module "babylonjs/Misc/decorators" {
  29965. import { Nullable } from "babylonjs/types";
  29966. import { Scene } from "babylonjs/scene";
  29967. import { IAnimatable } from "babylonjs/Misc/tools";
  29968. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29969. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29970. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29971. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29972. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29973. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29974. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29975. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29976. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29977. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29978. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29979. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29980. /**
  29981. * Decorator used to define property that can be serialized as reference to a camera
  29982. * @param sourceName defines the name of the property to decorate
  29983. */
  29984. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29985. /**
  29986. * Class used to help serialization objects
  29987. */
  29988. export class SerializationHelper {
  29989. /** hidden */
  29990. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  29991. /** hidden */
  29992. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  29993. /** hidden */
  29994. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  29995. /** hidden */
  29996. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  29997. /**
  29998. * Appends the serialized animations from the source animations
  29999. * @param source Source containing the animations
  30000. * @param destination Target to store the animations
  30001. */
  30002. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30003. /**
  30004. * Static function used to serialized a specific entity
  30005. * @param entity defines the entity to serialize
  30006. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30007. * @returns a JSON compatible object representing the serialization of the entity
  30008. */
  30009. static Serialize<T>(entity: T, serializationObject?: any): any;
  30010. /**
  30011. * Creates a new entity from a serialization data object
  30012. * @param creationFunction defines a function used to instanciated the new entity
  30013. * @param source defines the source serialization data
  30014. * @param scene defines the hosting scene
  30015. * @param rootUrl defines the root url for resources
  30016. * @returns a new entity
  30017. */
  30018. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30019. /**
  30020. * Clones an object
  30021. * @param creationFunction defines the function used to instanciate the new object
  30022. * @param source defines the source object
  30023. * @returns the cloned object
  30024. */
  30025. static Clone<T>(creationFunction: () => T, source: T): T;
  30026. /**
  30027. * Instanciates a new object based on a source one (some data will be shared between both object)
  30028. * @param creationFunction defines the function used to instanciate the new object
  30029. * @param source defines the source object
  30030. * @returns the new object
  30031. */
  30032. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30033. }
  30034. }
  30035. declare module "babylonjs/Cameras/camera" {
  30036. import { SmartArray } from "babylonjs/Misc/smartArray";
  30037. import { Observable } from "babylonjs/Misc/observable";
  30038. import { Nullable } from "babylonjs/types";
  30039. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30040. import { Scene } from "babylonjs/scene";
  30041. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  30042. import { Node } from "babylonjs/node";
  30043. import { Mesh } from "babylonjs/Meshes/mesh";
  30044. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30045. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30046. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30047. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30048. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30049. import { Ray } from "babylonjs/Culling/ray";
  30050. /**
  30051. * This is the base class of all the camera used in the application.
  30052. * @see http://doc.babylonjs.com/features/cameras
  30053. */
  30054. export class Camera extends Node {
  30055. /** @hidden */
  30056. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30057. /**
  30058. * This is the default projection mode used by the cameras.
  30059. * It helps recreating a feeling of perspective and better appreciate depth.
  30060. * This is the best way to simulate real life cameras.
  30061. */
  30062. static readonly PERSPECTIVE_CAMERA: number;
  30063. /**
  30064. * This helps creating camera with an orthographic mode.
  30065. * 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.
  30066. */
  30067. static readonly ORTHOGRAPHIC_CAMERA: number;
  30068. /**
  30069. * This is the default FOV mode for perspective cameras.
  30070. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30071. */
  30072. static readonly FOVMODE_VERTICAL_FIXED: number;
  30073. /**
  30074. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30075. */
  30076. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30077. /**
  30078. * This specifies ther is no need for a camera rig.
  30079. * Basically only one eye is rendered corresponding to the camera.
  30080. */
  30081. static readonly RIG_MODE_NONE: number;
  30082. /**
  30083. * Simulates a camera Rig with one blue eye and one red eye.
  30084. * This can be use with 3d blue and red glasses.
  30085. */
  30086. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30087. /**
  30088. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30089. */
  30090. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30091. /**
  30092. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30093. */
  30094. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30095. /**
  30096. * Defines that both eyes of the camera will be rendered over under each other.
  30097. */
  30098. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30099. /**
  30100. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30101. */
  30102. static readonly RIG_MODE_VR: number;
  30103. /**
  30104. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30105. */
  30106. static readonly RIG_MODE_WEBVR: number;
  30107. /**
  30108. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30109. */
  30110. static readonly RIG_MODE_CUSTOM: number;
  30111. /**
  30112. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30113. */
  30114. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30115. /**
  30116. * @hidden
  30117. * Might be removed once multiview will be a thing
  30118. */
  30119. static UseAlternateWebVRRendering: boolean;
  30120. /**
  30121. * Define the input manager associated with the camera.
  30122. */
  30123. inputs: CameraInputsManager<Camera>;
  30124. /** @hidden */
  30125. _position: Vector3;
  30126. /**
  30127. * Define the current local position of the camera in the scene
  30128. */
  30129. position: Vector3;
  30130. /**
  30131. * The vector the camera should consider as up.
  30132. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30133. */
  30134. upVector: Vector3;
  30135. /**
  30136. * Define the current limit on the left side for an orthographic camera
  30137. * In scene unit
  30138. */
  30139. orthoLeft: Nullable<number>;
  30140. /**
  30141. * Define the current limit on the right side for an orthographic camera
  30142. * In scene unit
  30143. */
  30144. orthoRight: Nullable<number>;
  30145. /**
  30146. * Define the current limit on the bottom side for an orthographic camera
  30147. * In scene unit
  30148. */
  30149. orthoBottom: Nullable<number>;
  30150. /**
  30151. * Define the current limit on the top side for an orthographic camera
  30152. * In scene unit
  30153. */
  30154. orthoTop: Nullable<number>;
  30155. /**
  30156. * Field Of View is set in Radians. (default is 0.8)
  30157. */
  30158. fov: number;
  30159. /**
  30160. * Define the minimum distance the camera can see from.
  30161. * This is important to note that the depth buffer are not infinite and the closer it starts
  30162. * the more your scene might encounter depth fighting issue.
  30163. */
  30164. minZ: number;
  30165. /**
  30166. * Define the maximum distance the camera can see to.
  30167. * This is important to note that the depth buffer are not infinite and the further it end
  30168. * the more your scene might encounter depth fighting issue.
  30169. */
  30170. maxZ: number;
  30171. /**
  30172. * Define the default inertia of the camera.
  30173. * This helps giving a smooth feeling to the camera movement.
  30174. */
  30175. inertia: number;
  30176. /**
  30177. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30178. */
  30179. mode: number;
  30180. /**
  30181. * Define wether the camera is intermediate.
  30182. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30183. */
  30184. isIntermediate: boolean;
  30185. /**
  30186. * Define the viewport of the camera.
  30187. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30188. */
  30189. viewport: Viewport;
  30190. /**
  30191. * Restricts the camera to viewing objects with the same layerMask.
  30192. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30193. */
  30194. layerMask: number;
  30195. /**
  30196. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30197. */
  30198. fovMode: number;
  30199. /**
  30200. * Rig mode of the camera.
  30201. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30202. * This is normally controlled byt the camera themselves as internal use.
  30203. */
  30204. cameraRigMode: number;
  30205. /**
  30206. * Defines the distance between both "eyes" in case of a RIG
  30207. */
  30208. interaxialDistance: number;
  30209. /**
  30210. * Defines if stereoscopic rendering is done side by side or over under.
  30211. */
  30212. isStereoscopicSideBySide: boolean;
  30213. /**
  30214. * 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
  30215. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30216. * else in the scene.
  30217. */
  30218. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30219. /**
  30220. * When set, the camera will render to this render target instead of the default canvas
  30221. */
  30222. outputRenderTarget: Nullable<RenderTargetTexture>;
  30223. /**
  30224. * Observable triggered when the camera view matrix has changed.
  30225. */
  30226. onViewMatrixChangedObservable: Observable<Camera>;
  30227. /**
  30228. * Observable triggered when the camera Projection matrix has changed.
  30229. */
  30230. onProjectionMatrixChangedObservable: Observable<Camera>;
  30231. /**
  30232. * Observable triggered when the inputs have been processed.
  30233. */
  30234. onAfterCheckInputsObservable: Observable<Camera>;
  30235. /**
  30236. * Observable triggered when reset has been called and applied to the camera.
  30237. */
  30238. onRestoreStateObservable: Observable<Camera>;
  30239. /** @hidden */
  30240. _cameraRigParams: any;
  30241. /** @hidden */
  30242. _rigCameras: Camera[];
  30243. /** @hidden */
  30244. _rigPostProcess: Nullable<PostProcess>;
  30245. protected _webvrViewMatrix: Matrix;
  30246. /** @hidden */
  30247. _skipRendering: boolean;
  30248. /** @hidden */
  30249. _alternateCamera: Camera;
  30250. /** @hidden */
  30251. _projectionMatrix: Matrix;
  30252. /** @hidden */
  30253. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30254. /** @hidden */
  30255. _activeMeshes: SmartArray<AbstractMesh>;
  30256. protected _globalPosition: Vector3;
  30257. /** hidden */
  30258. _computedViewMatrix: Matrix;
  30259. private _doNotComputeProjectionMatrix;
  30260. private _transformMatrix;
  30261. private _frustumPlanes;
  30262. private _refreshFrustumPlanes;
  30263. private _storedFov;
  30264. private _stateStored;
  30265. /**
  30266. * Instantiates a new camera object.
  30267. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30268. * @see http://doc.babylonjs.com/features/cameras
  30269. * @param name Defines the name of the camera in the scene
  30270. * @param position Defines the position of the camera
  30271. * @param scene Defines the scene the camera belongs too
  30272. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30273. */
  30274. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30275. /**
  30276. * Store current camera state (fov, position, etc..)
  30277. * @returns the camera
  30278. */
  30279. storeState(): Camera;
  30280. /**
  30281. * Restores the camera state values if it has been stored. You must call storeState() first
  30282. */
  30283. protected _restoreStateValues(): boolean;
  30284. /**
  30285. * Restored camera state. You must call storeState() first.
  30286. * @returns true if restored and false otherwise
  30287. */
  30288. restoreState(): boolean;
  30289. /**
  30290. * Gets the class name of the camera.
  30291. * @returns the class name
  30292. */
  30293. getClassName(): string;
  30294. /** @hidden */
  30295. readonly _isCamera: boolean;
  30296. /**
  30297. * Gets a string representation of the camera useful for debug purpose.
  30298. * @param fullDetails Defines that a more verboe level of logging is required
  30299. * @returns the string representation
  30300. */
  30301. toString(fullDetails?: boolean): string;
  30302. /**
  30303. * Gets the current world space position of the camera.
  30304. */
  30305. readonly globalPosition: Vector3;
  30306. /**
  30307. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30308. * @returns the active meshe list
  30309. */
  30310. getActiveMeshes(): SmartArray<AbstractMesh>;
  30311. /**
  30312. * Check wether a mesh is part of the current active mesh list of the camera
  30313. * @param mesh Defines the mesh to check
  30314. * @returns true if active, false otherwise
  30315. */
  30316. isActiveMesh(mesh: Mesh): boolean;
  30317. /**
  30318. * Is this camera ready to be used/rendered
  30319. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30320. * @return true if the camera is ready
  30321. */
  30322. isReady(completeCheck?: boolean): boolean;
  30323. /** @hidden */
  30324. _initCache(): void;
  30325. /** @hidden */
  30326. _updateCache(ignoreParentClass?: boolean): void;
  30327. /** @hidden */
  30328. _isSynchronized(): boolean;
  30329. /** @hidden */
  30330. _isSynchronizedViewMatrix(): boolean;
  30331. /** @hidden */
  30332. _isSynchronizedProjectionMatrix(): boolean;
  30333. /**
  30334. * Attach the input controls to a specific dom element to get the input from.
  30335. * @param element Defines the element the controls should be listened from
  30336. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30337. */
  30338. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30339. /**
  30340. * Detach the current controls from the specified dom element.
  30341. * @param element Defines the element to stop listening the inputs from
  30342. */
  30343. detachControl(element: HTMLElement): void;
  30344. /**
  30345. * Update the camera state according to the different inputs gathered during the frame.
  30346. */
  30347. update(): void;
  30348. /** @hidden */
  30349. _checkInputs(): void;
  30350. /** @hidden */
  30351. readonly rigCameras: Camera[];
  30352. /**
  30353. * Gets the post process used by the rig cameras
  30354. */
  30355. readonly rigPostProcess: Nullable<PostProcess>;
  30356. /**
  30357. * Internal, gets the first post proces.
  30358. * @returns the first post process to be run on this camera.
  30359. */
  30360. _getFirstPostProcess(): Nullable<PostProcess>;
  30361. private _cascadePostProcessesToRigCams;
  30362. /**
  30363. * Attach a post process to the camera.
  30364. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30365. * @param postProcess The post process to attach to the camera
  30366. * @param insertAt The position of the post process in case several of them are in use in the scene
  30367. * @returns the position the post process has been inserted at
  30368. */
  30369. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30370. /**
  30371. * Detach a post process to the camera.
  30372. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30373. * @param postProcess The post process to detach from the camera
  30374. */
  30375. detachPostProcess(postProcess: PostProcess): void;
  30376. /**
  30377. * Gets the current world matrix of the camera
  30378. */
  30379. getWorldMatrix(): Matrix;
  30380. /** @hidden */
  30381. _getViewMatrix(): Matrix;
  30382. /**
  30383. * Gets the current view matrix of the camera.
  30384. * @param force forces the camera to recompute the matrix without looking at the cached state
  30385. * @returns the view matrix
  30386. */
  30387. getViewMatrix(force?: boolean): Matrix;
  30388. /**
  30389. * Freeze the projection matrix.
  30390. * It will prevent the cache check of the camera projection compute and can speed up perf
  30391. * if no parameter of the camera are meant to change
  30392. * @param projection Defines manually a projection if necessary
  30393. */
  30394. freezeProjectionMatrix(projection?: Matrix): void;
  30395. /**
  30396. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30397. */
  30398. unfreezeProjectionMatrix(): void;
  30399. /**
  30400. * Gets the current projection matrix of the camera.
  30401. * @param force forces the camera to recompute the matrix without looking at the cached state
  30402. * @returns the projection matrix
  30403. */
  30404. getProjectionMatrix(force?: boolean): Matrix;
  30405. /**
  30406. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30407. * @returns a Matrix
  30408. */
  30409. getTransformationMatrix(): Matrix;
  30410. private _updateFrustumPlanes;
  30411. /**
  30412. * Checks if a cullable object (mesh...) is in the camera frustum
  30413. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30414. * @param target The object to check
  30415. * @returns true if the object is in frustum otherwise false
  30416. */
  30417. isInFrustum(target: ICullable): boolean;
  30418. /**
  30419. * Checks if a cullable object (mesh...) is in the camera frustum
  30420. * Unlike isInFrustum this cheks the full bounding box
  30421. * @param target The object to check
  30422. * @returns true if the object is in frustum otherwise false
  30423. */
  30424. isCompletelyInFrustum(target: ICullable): boolean;
  30425. /**
  30426. * Gets a ray in the forward direction from the camera.
  30427. * @param length Defines the length of the ray to create
  30428. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30429. * @param origin Defines the start point of the ray which defaults to the camera position
  30430. * @returns the forward ray
  30431. */
  30432. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30433. /**
  30434. * Releases resources associated with this node.
  30435. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30436. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30437. */
  30438. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30439. /**
  30440. * Gets the left camera of a rig setup in case of Rigged Camera
  30441. */
  30442. readonly leftCamera: Nullable<FreeCamera>;
  30443. /**
  30444. * Gets the right camera of a rig setup in case of Rigged Camera
  30445. */
  30446. readonly rightCamera: Nullable<FreeCamera>;
  30447. /**
  30448. * Gets the left camera target of a rig setup in case of Rigged Camera
  30449. * @returns the target position
  30450. */
  30451. getLeftTarget(): Nullable<Vector3>;
  30452. /**
  30453. * Gets the right camera target of a rig setup in case of Rigged Camera
  30454. * @returns the target position
  30455. */
  30456. getRightTarget(): Nullable<Vector3>;
  30457. /**
  30458. * @hidden
  30459. */
  30460. setCameraRigMode(mode: number, rigParams: any): void;
  30461. /** @hidden */
  30462. static _setStereoscopicRigMode(camera: Camera): void;
  30463. /** @hidden */
  30464. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30465. /** @hidden */
  30466. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30467. /** @hidden */
  30468. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30469. /** @hidden */
  30470. _getVRProjectionMatrix(): Matrix;
  30471. protected _updateCameraRotationMatrix(): void;
  30472. protected _updateWebVRCameraRotationMatrix(): void;
  30473. /**
  30474. * This function MUST be overwritten by the different WebVR cameras available.
  30475. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30476. * @hidden
  30477. */
  30478. _getWebVRProjectionMatrix(): Matrix;
  30479. /**
  30480. * This function MUST be overwritten by the different WebVR cameras available.
  30481. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30482. * @hidden
  30483. */
  30484. _getWebVRViewMatrix(): Matrix;
  30485. /** @hidden */
  30486. setCameraRigParameter(name: string, value: any): void;
  30487. /**
  30488. * needs to be overridden by children so sub has required properties to be copied
  30489. * @hidden
  30490. */
  30491. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30492. /**
  30493. * May need to be overridden by children
  30494. * @hidden
  30495. */
  30496. _updateRigCameras(): void;
  30497. /** @hidden */
  30498. _setupInputs(): void;
  30499. /**
  30500. * Serialiaze the camera setup to a json represention
  30501. * @returns the JSON representation
  30502. */
  30503. serialize(): any;
  30504. /**
  30505. * Clones the current camera.
  30506. * @param name The cloned camera name
  30507. * @returns the cloned camera
  30508. */
  30509. clone(name: string): Camera;
  30510. /**
  30511. * Gets the direction of the camera relative to a given local axis.
  30512. * @param localAxis Defines the reference axis to provide a relative direction.
  30513. * @return the direction
  30514. */
  30515. getDirection(localAxis: Vector3): Vector3;
  30516. /**
  30517. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30518. * @param localAxis Defines the reference axis to provide a relative direction.
  30519. * @param result Defines the vector to store the result in
  30520. */
  30521. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30522. /**
  30523. * Gets a camera constructor for a given camera type
  30524. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30525. * @param name The name of the camera the result will be able to instantiate
  30526. * @param scene The scene the result will construct the camera in
  30527. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30528. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30529. * @returns a factory method to construc the camera
  30530. */
  30531. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30532. /**
  30533. * Compute the world matrix of the camera.
  30534. * @returns the camera workd matrix
  30535. */
  30536. computeWorldMatrix(): Matrix;
  30537. /**
  30538. * Parse a JSON and creates the camera from the parsed information
  30539. * @param parsedCamera The JSON to parse
  30540. * @param scene The scene to instantiate the camera in
  30541. * @returns the newly constructed camera
  30542. */
  30543. static Parse(parsedCamera: any, scene: Scene): Camera;
  30544. }
  30545. }
  30546. declare module "babylonjs/Misc/tools" {
  30547. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  30548. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  30549. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30550. import { Observable } from "babylonjs/Misc/observable";
  30551. import { DomManagement } from "babylonjs/Misc/domManagement";
  30552. import { Camera } from "babylonjs/Cameras/camera";
  30553. import { Engine } from "babylonjs/Engines/engine";
  30554. import { Animation } from "babylonjs/Animations/animation";
  30555. /**
  30556. * Interface for any object that can request an animation frame
  30557. */
  30558. export interface ICustomAnimationFrameRequester {
  30559. /**
  30560. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30561. */
  30562. renderFunction?: Function;
  30563. /**
  30564. * Called to request the next frame to render to
  30565. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30566. */
  30567. requestAnimationFrame: Function;
  30568. /**
  30569. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30570. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30571. */
  30572. requestID?: number;
  30573. }
  30574. /**
  30575. * Interface containing an array of animations
  30576. */
  30577. export interface IAnimatable {
  30578. /**
  30579. * Array of animations
  30580. */
  30581. animations: Array<Animation>;
  30582. }
  30583. /** Interface used by value gradients (color, factor, ...) */
  30584. export interface IValueGradient {
  30585. /**
  30586. * Gets or sets the gradient value (between 0 and 1)
  30587. */
  30588. gradient: number;
  30589. }
  30590. /** Class used to store color4 gradient */
  30591. export class ColorGradient implements IValueGradient {
  30592. /**
  30593. * Gets or sets the gradient value (between 0 and 1)
  30594. */
  30595. gradient: number;
  30596. /**
  30597. * Gets or sets first associated color
  30598. */
  30599. color1: Color4;
  30600. /**
  30601. * Gets or sets second associated color
  30602. */
  30603. color2?: Color4;
  30604. /**
  30605. * Will get a color picked randomly between color1 and color2.
  30606. * If color2 is undefined then color1 will be used
  30607. * @param result defines the target Color4 to store the result in
  30608. */
  30609. getColorToRef(result: Color4): void;
  30610. }
  30611. /** Class used to store color 3 gradient */
  30612. export class Color3Gradient implements IValueGradient {
  30613. /**
  30614. * Gets or sets the gradient value (between 0 and 1)
  30615. */
  30616. gradient: number;
  30617. /**
  30618. * Gets or sets the associated color
  30619. */
  30620. color: Color3;
  30621. }
  30622. /** Class used to store factor gradient */
  30623. export class FactorGradient implements IValueGradient {
  30624. /**
  30625. * Gets or sets the gradient value (between 0 and 1)
  30626. */
  30627. gradient: number;
  30628. /**
  30629. * Gets or sets first associated factor
  30630. */
  30631. factor1: number;
  30632. /**
  30633. * Gets or sets second associated factor
  30634. */
  30635. factor2?: number;
  30636. /**
  30637. * Will get a number picked randomly between factor1 and factor2.
  30638. * If factor2 is undefined then factor1 will be used
  30639. * @returns the picked number
  30640. */
  30641. getFactor(): number;
  30642. }
  30643. /**
  30644. * @ignore
  30645. * Application error to support additional information when loading a file
  30646. */
  30647. export class LoadFileError extends Error {
  30648. /** defines the optional XHR request */
  30649. request?: XMLHttpRequest | undefined;
  30650. private static _setPrototypeOf;
  30651. /**
  30652. * Creates a new LoadFileError
  30653. * @param message defines the message of the error
  30654. * @param request defines the optional XHR request
  30655. */
  30656. constructor(message: string,
  30657. /** defines the optional XHR request */
  30658. request?: XMLHttpRequest | undefined);
  30659. }
  30660. /**
  30661. * Class used to define a retry strategy when error happens while loading assets
  30662. */
  30663. export class RetryStrategy {
  30664. /**
  30665. * Function used to defines an exponential back off strategy
  30666. * @param maxRetries defines the maximum number of retries (3 by default)
  30667. * @param baseInterval defines the interval between retries
  30668. * @returns the strategy function to use
  30669. */
  30670. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  30671. }
  30672. /**
  30673. * File request interface
  30674. */
  30675. export interface IFileRequest {
  30676. /**
  30677. * Raised when the request is complete (success or error).
  30678. */
  30679. onCompleteObservable: Observable<IFileRequest>;
  30680. /**
  30681. * Aborts the request for a file.
  30682. */
  30683. abort: () => void;
  30684. }
  30685. /**
  30686. * Class containing a set of static utilities functions
  30687. */
  30688. export class Tools {
  30689. /**
  30690. * Gets or sets the base URL to use to load assets
  30691. */
  30692. static BaseUrl: string;
  30693. /**
  30694. * Enable/Disable Custom HTTP Request Headers globally.
  30695. * default = false
  30696. * @see CustomRequestHeaders
  30697. */
  30698. static UseCustomRequestHeaders: boolean;
  30699. /**
  30700. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30701. * i.e. when loading files, where the server/service expects an Authorization header.
  30702. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  30703. */
  30704. static CustomRequestHeaders: {
  30705. [key: string]: string;
  30706. };
  30707. /**
  30708. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30709. */
  30710. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  30711. /**
  30712. * Default behaviour for cors in the application.
  30713. * It can be a string if the expected behavior is identical in the entire app.
  30714. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30715. */
  30716. static CorsBehavior: string | ((url: string | string[]) => string);
  30717. /**
  30718. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30719. * @ignorenaming
  30720. */
  30721. static UseFallbackTexture: boolean;
  30722. /**
  30723. * Use this object to register external classes like custom textures or material
  30724. * to allow the laoders to instantiate them
  30725. */
  30726. static RegisteredExternalClasses: {
  30727. [key: string]: Object;
  30728. };
  30729. /**
  30730. * Texture content used if a texture cannot loaded
  30731. * @ignorenaming
  30732. */
  30733. static fallbackTexture: string;
  30734. /**
  30735. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30736. * @param u defines the coordinate on X axis
  30737. * @param v defines the coordinate on Y axis
  30738. * @param width defines the width of the source data
  30739. * @param height defines the height of the source data
  30740. * @param pixels defines the source byte array
  30741. * @param color defines the output color
  30742. */
  30743. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30744. /**
  30745. * Interpolates between a and b via alpha
  30746. * @param a The lower value (returned when alpha = 0)
  30747. * @param b The upper value (returned when alpha = 1)
  30748. * @param alpha The interpolation-factor
  30749. * @return The mixed value
  30750. */
  30751. static Mix(a: number, b: number, alpha: number): number;
  30752. /**
  30753. * Tries to instantiate a new object from a given class name
  30754. * @param className defines the class name to instantiate
  30755. * @returns the new object or null if the system was not able to do the instantiation
  30756. */
  30757. static Instantiate(className: string): any;
  30758. /**
  30759. * Provides a slice function that will work even on IE
  30760. * @param data defines the array to slice
  30761. * @param start defines the start of the data (optional)
  30762. * @param end defines the end of the data (optional)
  30763. * @returns the new sliced array
  30764. */
  30765. static Slice<T>(data: T, start?: number, end?: number): T;
  30766. /**
  30767. * Polyfill for setImmediate
  30768. * @param action defines the action to execute after the current execution block
  30769. */
  30770. static SetImmediate(action: () => void): void;
  30771. /**
  30772. * Function indicating if a number is an exponent of 2
  30773. * @param value defines the value to test
  30774. * @returns true if the value is an exponent of 2
  30775. */
  30776. static IsExponentOfTwo(value: number): boolean;
  30777. private static _tmpFloatArray;
  30778. /**
  30779. * Returns the nearest 32-bit single precision float representation of a Number
  30780. * @param value A Number. If the parameter is of a different type, it will get converted
  30781. * to a number or to NaN if it cannot be converted
  30782. * @returns number
  30783. */
  30784. static FloatRound(value: number): number;
  30785. /**
  30786. * Find the next highest power of two.
  30787. * @param x Number to start search from.
  30788. * @return Next highest power of two.
  30789. */
  30790. static CeilingPOT(x: number): number;
  30791. /**
  30792. * Find the next lowest power of two.
  30793. * @param x Number to start search from.
  30794. * @return Next lowest power of two.
  30795. */
  30796. static FloorPOT(x: number): number;
  30797. /**
  30798. * Find the nearest power of two.
  30799. * @param x Number to start search from.
  30800. * @return Next nearest power of two.
  30801. */
  30802. static NearestPOT(x: number): number;
  30803. /**
  30804. * Get the closest exponent of two
  30805. * @param value defines the value to approximate
  30806. * @param max defines the maximum value to return
  30807. * @param mode defines how to define the closest value
  30808. * @returns closest exponent of two of the given value
  30809. */
  30810. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30811. /**
  30812. * Extracts the filename from a path
  30813. * @param path defines the path to use
  30814. * @returns the filename
  30815. */
  30816. static GetFilename(path: string): string;
  30817. /**
  30818. * Extracts the "folder" part of a path (everything before the filename).
  30819. * @param uri The URI to extract the info from
  30820. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30821. * @returns The "folder" part of the path
  30822. */
  30823. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30824. /**
  30825. * Extracts text content from a DOM element hierarchy
  30826. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  30827. */
  30828. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  30829. /**
  30830. * Convert an angle in radians to degrees
  30831. * @param angle defines the angle to convert
  30832. * @returns the angle in degrees
  30833. */
  30834. static ToDegrees(angle: number): number;
  30835. /**
  30836. * Convert an angle in degrees to radians
  30837. * @param angle defines the angle to convert
  30838. * @returns the angle in radians
  30839. */
  30840. static ToRadians(angle: number): number;
  30841. /**
  30842. * Encode a buffer to a base64 string
  30843. * @param buffer defines the buffer to encode
  30844. * @returns the encoded string
  30845. */
  30846. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30847. /**
  30848. * Extracts minimum and maximum values from a list of indexed positions
  30849. * @param positions defines the positions to use
  30850. * @param indices defines the indices to the positions
  30851. * @param indexStart defines the start index
  30852. * @param indexCount defines the end index
  30853. * @param bias defines bias value to add to the result
  30854. * @return minimum and maximum values
  30855. */
  30856. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30857. minimum: Vector3;
  30858. maximum: Vector3;
  30859. };
  30860. /**
  30861. * Extracts minimum and maximum values from a list of positions
  30862. * @param positions defines the positions to use
  30863. * @param start defines the start index in the positions array
  30864. * @param count defines the number of positions to handle
  30865. * @param bias defines bias value to add to the result
  30866. * @param stride defines the stride size to use (distance between two positions in the positions array)
  30867. * @return minimum and maximum values
  30868. */
  30869. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30870. minimum: Vector3;
  30871. maximum: Vector3;
  30872. };
  30873. /**
  30874. * Returns an array if obj is not an array
  30875. * @param obj defines the object to evaluate as an array
  30876. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  30877. * @returns either obj directly if obj is an array or a new array containing obj
  30878. */
  30879. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30880. /**
  30881. * Gets the pointer prefix to use
  30882. * @returns "pointer" if touch is enabled. Else returns "mouse"
  30883. */
  30884. static GetPointerPrefix(): string;
  30885. /**
  30886. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30887. * @param func - the function to be called
  30888. * @param requester - the object that will request the next frame. Falls back to window.
  30889. * @returns frame number
  30890. */
  30891. static QueueNewFrame(func: () => void, requester?: any): number;
  30892. /**
  30893. * Ask the browser to promote the current element to fullscreen rendering mode
  30894. * @param element defines the DOM element to promote
  30895. */
  30896. static RequestFullscreen(element: HTMLElement): void;
  30897. /**
  30898. * Asks the browser to exit fullscreen mode
  30899. */
  30900. static ExitFullscreen(): void;
  30901. /**
  30902. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  30903. * @param url define the url we are trying
  30904. * @param element define the dom element where to configure the cors policy
  30905. */
  30906. static SetCorsBehavior(url: string | string[], element: {
  30907. crossOrigin: string | null;
  30908. }): void;
  30909. /**
  30910. * Removes unwanted characters from an url
  30911. * @param url defines the url to clean
  30912. * @returns the cleaned url
  30913. */
  30914. static CleanUrl(url: string): string;
  30915. /**
  30916. * Gets or sets a function used to pre-process url before using them to load assets
  30917. */
  30918. static PreprocessUrl: (url: string) => string;
  30919. /**
  30920. * Loads an image as an HTMLImageElement.
  30921. * @param input url string, ArrayBuffer, or Blob to load
  30922. * @param onLoad callback called when the image successfully loads
  30923. * @param onError callback called when the image fails to load
  30924. * @param offlineProvider offline provider for caching
  30925. * @returns the HTMLImageElement of the loaded image
  30926. */
  30927. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  30928. /**
  30929. * Loads a file
  30930. * @param url url string, ArrayBuffer, or Blob to load
  30931. * @param onSuccess callback called when the file successfully loads
  30932. * @param onProgress callback called while file is loading (if the server supports this mode)
  30933. * @param offlineProvider defines the offline provider for caching
  30934. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  30935. * @param onError callback called when the file fails to load
  30936. * @returns a file request object
  30937. */
  30938. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  30939. /**
  30940. * Load a script (identified by an url). When the url returns, the
  30941. * content of this file is added into a new script element, attached to the DOM (body element)
  30942. * @param scriptUrl defines the url of the script to laod
  30943. * @param onSuccess defines the callback called when the script is loaded
  30944. * @param onError defines the callback to call if an error occurs
  30945. */
  30946. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  30947. /**
  30948. * Loads a file from a blob
  30949. * @param fileToLoad defines the blob to use
  30950. * @param callback defines the callback to call when data is loaded
  30951. * @param progressCallback defines the callback to call during loading process
  30952. * @returns a file request object
  30953. */
  30954. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  30955. /**
  30956. * Loads a file
  30957. * @param fileToLoad defines the file to load
  30958. * @param callback defines the callback to call when data is loaded
  30959. * @param progressCallBack defines the callback to call during loading process
  30960. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  30961. * @returns a file request object
  30962. */
  30963. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  30964. /**
  30965. * Creates a data url from a given string content
  30966. * @param content defines the content to convert
  30967. * @returns the new data url link
  30968. */
  30969. static FileAsURL(content: string): string;
  30970. /**
  30971. * Format the given number to a specific decimal format
  30972. * @param value defines the number to format
  30973. * @param decimals defines the number of decimals to use
  30974. * @returns the formatted string
  30975. */
  30976. static Format(value: number, decimals?: number): string;
  30977. /**
  30978. * Checks if a given vector is inside a specific range
  30979. * @param v defines the vector to test
  30980. * @param min defines the minimum range
  30981. * @param max defines the maximum range
  30982. */
  30983. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  30984. /**
  30985. * Tries to copy an object by duplicating every property
  30986. * @param source defines the source object
  30987. * @param destination defines the target object
  30988. * @param doNotCopyList defines a list of properties to avoid
  30989. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  30990. */
  30991. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  30992. /**
  30993. * Gets a boolean indicating if the given object has no own property
  30994. * @param obj defines the object to test
  30995. * @returns true if object has no own property
  30996. */
  30997. static IsEmpty(obj: any): boolean;
  30998. /**
  30999. * Function used to register events at window level
  31000. * @param events defines the events to register
  31001. */
  31002. static RegisterTopRootEvents(events: {
  31003. name: string;
  31004. handler: Nullable<(e: FocusEvent) => any>;
  31005. }[]): void;
  31006. /**
  31007. * Function used to unregister events from window level
  31008. * @param events defines the events to unregister
  31009. */
  31010. static UnregisterTopRootEvents(events: {
  31011. name: string;
  31012. handler: Nullable<(e: FocusEvent) => any>;
  31013. }[]): void;
  31014. /**
  31015. * Dumps the current bound framebuffer
  31016. * @param width defines the rendering width
  31017. * @param height defines the rendering height
  31018. * @param engine defines the hosting engine
  31019. * @param successCallback defines the callback triggered once the data are available
  31020. * @param mimeType defines the mime type of the result
  31021. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31022. */
  31023. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31024. /**
  31025. * Converts the canvas data to blob.
  31026. * This acts as a polyfill for browsers not supporting the to blob function.
  31027. * @param canvas Defines the canvas to extract the data from
  31028. * @param successCallback Defines the callback triggered once the data are available
  31029. * @param mimeType Defines the mime type of the result
  31030. */
  31031. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31032. /**
  31033. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31034. * @param successCallback defines the callback triggered once the data are available
  31035. * @param mimeType defines the mime type of the result
  31036. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31037. */
  31038. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31039. /**
  31040. * Downloads a blob in the browser
  31041. * @param blob defines the blob to download
  31042. * @param fileName defines the name of the downloaded file
  31043. */
  31044. static Download(blob: Blob, fileName: string): void;
  31045. /**
  31046. * Captures a screenshot of the current rendering
  31047. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31048. * @param engine defines the rendering engine
  31049. * @param camera defines the source camera
  31050. * @param size This parameter can be set to a single number or to an object with the
  31051. * following (optional) properties: precision, width, height. If a single number is passed,
  31052. * it will be used for both width and height. If an object is passed, the screenshot size
  31053. * will be derived from the parameters. The precision property is a multiplier allowing
  31054. * rendering at a higher or lower resolution
  31055. * @param successCallback defines the callback receives a single parameter which contains the
  31056. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31057. * src parameter of an <img> to display it
  31058. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31059. * Check your browser for supported MIME types
  31060. */
  31061. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31062. /**
  31063. * Generates an image screenshot from the specified camera.
  31064. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31065. * @param engine The engine to use for rendering
  31066. * @param camera The camera to use for rendering
  31067. * @param size This parameter can be set to a single number or to an object with the
  31068. * following (optional) properties: precision, width, height. If a single number is passed,
  31069. * it will be used for both width and height. If an object is passed, the screenshot size
  31070. * will be derived from the parameters. The precision property is a multiplier allowing
  31071. * rendering at a higher or lower resolution
  31072. * @param successCallback The callback receives a single parameter which contains the
  31073. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31074. * src parameter of an <img> to display it
  31075. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31076. * Check your browser for supported MIME types
  31077. * @param samples Texture samples (default: 1)
  31078. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31079. * @param fileName A name for for the downloaded file.
  31080. */
  31081. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31082. /**
  31083. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31084. * Be aware Math.random() could cause collisions, but:
  31085. * "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"
  31086. * @returns a pseudo random id
  31087. */
  31088. static RandomId(): string;
  31089. /**
  31090. * Test if the given uri is a base64 string
  31091. * @param uri The uri to test
  31092. * @return True if the uri is a base64 string or false otherwise
  31093. */
  31094. static IsBase64(uri: string): boolean;
  31095. /**
  31096. * Decode the given base64 uri.
  31097. * @param uri The uri to decode
  31098. * @return The decoded base64 data.
  31099. */
  31100. static DecodeBase64(uri: string): ArrayBuffer;
  31101. /**
  31102. * No log
  31103. */
  31104. static readonly NoneLogLevel: number;
  31105. /**
  31106. * Only message logs
  31107. */
  31108. static readonly MessageLogLevel: number;
  31109. /**
  31110. * Only warning logs
  31111. */
  31112. static readonly WarningLogLevel: number;
  31113. /**
  31114. * Only error logs
  31115. */
  31116. static readonly ErrorLogLevel: number;
  31117. /**
  31118. * All logs
  31119. */
  31120. static readonly AllLogLevel: number;
  31121. /**
  31122. * Gets a value indicating the number of loading errors
  31123. * @ignorenaming
  31124. */
  31125. static readonly errorsCount: number;
  31126. /**
  31127. * Callback called when a new log is added
  31128. */
  31129. static OnNewCacheEntry: (entry: string) => void;
  31130. /**
  31131. * Log a message to the console
  31132. * @param message defines the message to log
  31133. */
  31134. static Log(message: string): void;
  31135. /**
  31136. * Write a warning message to the console
  31137. * @param message defines the message to log
  31138. */
  31139. static Warn(message: string): void;
  31140. /**
  31141. * Write an error message to the console
  31142. * @param message defines the message to log
  31143. */
  31144. static Error(message: string): void;
  31145. /**
  31146. * Gets current log cache (list of logs)
  31147. */
  31148. static readonly LogCache: string;
  31149. /**
  31150. * Clears the log cache
  31151. */
  31152. static ClearLogCache(): void;
  31153. /**
  31154. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31155. */
  31156. static LogLevels: number;
  31157. /**
  31158. * Checks if the loaded document was accessed via `file:`-Protocol.
  31159. * @returns boolean
  31160. */
  31161. static IsFileURL(): boolean;
  31162. /**
  31163. * Checks if the window object exists
  31164. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31165. */
  31166. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31167. /**
  31168. * No performance log
  31169. */
  31170. static readonly PerformanceNoneLogLevel: number;
  31171. /**
  31172. * Use user marks to log performance
  31173. */
  31174. static readonly PerformanceUserMarkLogLevel: number;
  31175. /**
  31176. * Log performance to the console
  31177. */
  31178. static readonly PerformanceConsoleLogLevel: number;
  31179. private static _performance;
  31180. /**
  31181. * Sets the current performance log level
  31182. */
  31183. static PerformanceLogLevel: number;
  31184. private static _StartPerformanceCounterDisabled;
  31185. private static _EndPerformanceCounterDisabled;
  31186. private static _StartUserMark;
  31187. private static _EndUserMark;
  31188. private static _StartPerformanceConsole;
  31189. private static _EndPerformanceConsole;
  31190. /**
  31191. * Injects the @see CustomRequestHeaders into the given request
  31192. * @param request the request that should be used for injection
  31193. */
  31194. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  31195. /**
  31196. * Starts a performance counter
  31197. */
  31198. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31199. /**
  31200. * Ends a specific performance coutner
  31201. */
  31202. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31203. /**
  31204. * Gets either window.performance.now() if supported or Date.now() else
  31205. */
  31206. static readonly Now: number;
  31207. /**
  31208. * This method will return the name of the class used to create the instance of the given object.
  31209. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31210. * @param object the object to get the class name from
  31211. * @param isType defines if the object is actually a type
  31212. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31213. */
  31214. static GetClassName(object: any, isType?: boolean): string;
  31215. /**
  31216. * Gets the first element of an array satisfying a given predicate
  31217. * @param array defines the array to browse
  31218. * @param predicate defines the predicate to use
  31219. * @returns null if not found or the element
  31220. */
  31221. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31222. /**
  31223. * This method will return the name of the full name of the class, including its owning module (if any).
  31224. * 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).
  31225. * @param object the object to get the class name from
  31226. * @param isType defines if the object is actually a type
  31227. * @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.
  31228. * @ignorenaming
  31229. */
  31230. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31231. /**
  31232. * Returns a promise that resolves after the given amount of time.
  31233. * @param delay Number of milliseconds to delay
  31234. * @returns Promise that resolves after the given amount of time
  31235. */
  31236. static DelayAsync(delay: number): Promise<void>;
  31237. /**
  31238. * Gets the current gradient from an array of IValueGradient
  31239. * @param ratio defines the current ratio to get
  31240. * @param gradients defines the array of IValueGradient
  31241. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31242. */
  31243. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31244. }
  31245. /**
  31246. * This class is used to track a performance counter which is number based.
  31247. * The user has access to many properties which give statistics of different nature.
  31248. *
  31249. * The implementer can track two kinds of Performance Counter: time and count.
  31250. * 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.
  31251. * 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.
  31252. */
  31253. export class PerfCounter {
  31254. /**
  31255. * Gets or sets a global boolean to turn on and off all the counters
  31256. */
  31257. static Enabled: boolean;
  31258. /**
  31259. * Returns the smallest value ever
  31260. */
  31261. readonly min: number;
  31262. /**
  31263. * Returns the biggest value ever
  31264. */
  31265. readonly max: number;
  31266. /**
  31267. * Returns the average value since the performance counter is running
  31268. */
  31269. readonly average: number;
  31270. /**
  31271. * Returns the average value of the last second the counter was monitored
  31272. */
  31273. readonly lastSecAverage: number;
  31274. /**
  31275. * Returns the current value
  31276. */
  31277. readonly current: number;
  31278. /**
  31279. * Gets the accumulated total
  31280. */
  31281. readonly total: number;
  31282. /**
  31283. * Gets the total value count
  31284. */
  31285. readonly count: number;
  31286. /**
  31287. * Creates a new counter
  31288. */
  31289. constructor();
  31290. /**
  31291. * Call this method to start monitoring a new frame.
  31292. * 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.
  31293. */
  31294. fetchNewFrame(): void;
  31295. /**
  31296. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31297. * @param newCount the count value to add to the monitored count
  31298. * @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.
  31299. */
  31300. addCount(newCount: number, fetchResult: boolean): void;
  31301. /**
  31302. * Start monitoring this performance counter
  31303. */
  31304. beginMonitoring(): void;
  31305. /**
  31306. * Compute the time lapsed since the previous beginMonitoring() call.
  31307. * @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
  31308. */
  31309. endMonitoring(newFrame?: boolean): void;
  31310. private _fetchResult;
  31311. private _startMonitoringTime;
  31312. private _min;
  31313. private _max;
  31314. private _average;
  31315. private _current;
  31316. private _totalValueCount;
  31317. private _totalAccumulated;
  31318. private _lastSecAverage;
  31319. private _lastSecAccumulated;
  31320. private _lastSecTime;
  31321. private _lastSecValueCount;
  31322. }
  31323. /**
  31324. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31325. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31326. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31327. * @param name The name of the class, case should be preserved
  31328. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31329. */
  31330. export function className(name: string, module?: string): (target: Object) => void;
  31331. /**
  31332. * An implementation of a loop for asynchronous functions.
  31333. */
  31334. export class AsyncLoop {
  31335. /**
  31336. * Defines the number of iterations for the loop
  31337. */
  31338. iterations: number;
  31339. /**
  31340. * Defines the current index of the loop.
  31341. */
  31342. index: number;
  31343. private _done;
  31344. private _fn;
  31345. private _successCallback;
  31346. /**
  31347. * Constructor.
  31348. * @param iterations the number of iterations.
  31349. * @param func the function to run each iteration
  31350. * @param successCallback the callback that will be called upon succesful execution
  31351. * @param offset starting offset.
  31352. */
  31353. constructor(
  31354. /**
  31355. * Defines the number of iterations for the loop
  31356. */
  31357. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31358. /**
  31359. * Execute the next iteration. Must be called after the last iteration was finished.
  31360. */
  31361. executeNext(): void;
  31362. /**
  31363. * Break the loop and run the success callback.
  31364. */
  31365. breakLoop(): void;
  31366. /**
  31367. * Create and run an async loop.
  31368. * @param iterations the number of iterations.
  31369. * @param fn the function to run each iteration
  31370. * @param successCallback the callback that will be called upon succesful execution
  31371. * @param offset starting offset.
  31372. * @returns the created async loop object
  31373. */
  31374. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31375. /**
  31376. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31377. * @param iterations total number of iterations
  31378. * @param syncedIterations number of synchronous iterations in each async iteration.
  31379. * @param fn the function to call each iteration.
  31380. * @param callback a success call back that will be called when iterating stops.
  31381. * @param breakFunction a break condition (optional)
  31382. * @param timeout timeout settings for the setTimeout function. default - 0.
  31383. * @returns the created async loop object
  31384. */
  31385. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31386. }
  31387. }
  31388. declare module "babylonjs/Collisions/collisionCoordinator" {
  31389. import { Nullable } from "babylonjs/types";
  31390. import { Scene } from "babylonjs/scene";
  31391. import { Vector3 } from "babylonjs/Maths/math";
  31392. import { Collider } from "babylonjs/Collisions/collider";
  31393. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31394. /** @hidden */
  31395. export interface ICollisionCoordinator {
  31396. createCollider(): Collider;
  31397. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31398. init(scene: Scene): void;
  31399. }
  31400. /** @hidden */
  31401. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31402. private _scene;
  31403. private _scaledPosition;
  31404. private _scaledVelocity;
  31405. private _finalPosition;
  31406. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31407. createCollider(): Collider;
  31408. init(scene: Scene): void;
  31409. private _collideWithWorld;
  31410. }
  31411. }
  31412. declare module "babylonjs/Animations/animationGroup" {
  31413. import { Animatable } from "babylonjs/Animations/animatable";
  31414. import { Animation } from "babylonjs/Animations/animation";
  31415. import { Scene, IDisposable } from "babylonjs/scene";
  31416. import { Observable } from "babylonjs/Misc/observable";
  31417. import { Nullable } from "babylonjs/types";
  31418. /**
  31419. * This class defines the direct association between an animation and a target
  31420. */
  31421. export class TargetedAnimation {
  31422. /**
  31423. * Animation to perform
  31424. */
  31425. animation: Animation;
  31426. /**
  31427. * Target to animate
  31428. */
  31429. target: any;
  31430. }
  31431. /**
  31432. * Use this class to create coordinated animations on multiple targets
  31433. */
  31434. export class AnimationGroup implements IDisposable {
  31435. /** The name of the animation group */
  31436. name: string;
  31437. private _scene;
  31438. private _targetedAnimations;
  31439. private _animatables;
  31440. private _from;
  31441. private _to;
  31442. private _isStarted;
  31443. private _isPaused;
  31444. private _speedRatio;
  31445. /**
  31446. * Gets or sets the unique id of the node
  31447. */
  31448. uniqueId: number;
  31449. /**
  31450. * This observable will notify when one animation have ended
  31451. */
  31452. onAnimationEndObservable: Observable<TargetedAnimation>;
  31453. /**
  31454. * Observer raised when one animation loops
  31455. */
  31456. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31457. /**
  31458. * This observable will notify when all animations have ended.
  31459. */
  31460. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31461. /**
  31462. * This observable will notify when all animations have paused.
  31463. */
  31464. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31465. /**
  31466. * This observable will notify when all animations are playing.
  31467. */
  31468. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31469. /**
  31470. * Gets the first frame
  31471. */
  31472. readonly from: number;
  31473. /**
  31474. * Gets the last frame
  31475. */
  31476. readonly to: number;
  31477. /**
  31478. * Define if the animations are started
  31479. */
  31480. readonly isStarted: boolean;
  31481. /**
  31482. * Gets a value indicating that the current group is playing
  31483. */
  31484. readonly isPlaying: boolean;
  31485. /**
  31486. * Gets or sets the speed ratio to use for all animations
  31487. */
  31488. /**
  31489. * Gets or sets the speed ratio to use for all animations
  31490. */
  31491. speedRatio: number;
  31492. /**
  31493. * Gets the targeted animations for this animation group
  31494. */
  31495. readonly targetedAnimations: Array<TargetedAnimation>;
  31496. /**
  31497. * returning the list of animatables controlled by this animation group.
  31498. */
  31499. readonly animatables: Array<Animatable>;
  31500. /**
  31501. * Instantiates a new Animation Group.
  31502. * This helps managing several animations at once.
  31503. * @see http://doc.babylonjs.com/how_to/group
  31504. * @param name Defines the name of the group
  31505. * @param scene Defines the scene the group belongs to
  31506. */
  31507. constructor(
  31508. /** The name of the animation group */
  31509. name: string, scene?: Nullable<Scene>);
  31510. /**
  31511. * Add an animation (with its target) in the group
  31512. * @param animation defines the animation we want to add
  31513. * @param target defines the target of the animation
  31514. * @returns the TargetedAnimation object
  31515. */
  31516. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31517. /**
  31518. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31519. * It can add constant keys at begin or end
  31520. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31521. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31522. * @returns the animation group
  31523. */
  31524. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31525. /**
  31526. * Start all animations on given targets
  31527. * @param loop defines if animations must loop
  31528. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31529. * @param from defines the from key (optional)
  31530. * @param to defines the to key (optional)
  31531. * @returns the current animation group
  31532. */
  31533. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31534. /**
  31535. * Pause all animations
  31536. * @returns the animation group
  31537. */
  31538. pause(): AnimationGroup;
  31539. /**
  31540. * Play all animations to initial state
  31541. * This function will start() the animations if they were not started or will restart() them if they were paused
  31542. * @param loop defines if animations must loop
  31543. * @returns the animation group
  31544. */
  31545. play(loop?: boolean): AnimationGroup;
  31546. /**
  31547. * Reset all animations to initial state
  31548. * @returns the animation group
  31549. */
  31550. reset(): AnimationGroup;
  31551. /**
  31552. * Restart animations from key 0
  31553. * @returns the animation group
  31554. */
  31555. restart(): AnimationGroup;
  31556. /**
  31557. * Stop all animations
  31558. * @returns the animation group
  31559. */
  31560. stop(): AnimationGroup;
  31561. /**
  31562. * Set animation weight for all animatables
  31563. * @param weight defines the weight to use
  31564. * @return the animationGroup
  31565. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31566. */
  31567. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31568. /**
  31569. * Synchronize and normalize all animatables with a source animatable
  31570. * @param root defines the root animatable to synchronize with
  31571. * @return the animationGroup
  31572. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31573. */
  31574. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31575. /**
  31576. * Goes to a specific frame in this animation group
  31577. * @param frame the frame number to go to
  31578. * @return the animationGroup
  31579. */
  31580. goToFrame(frame: number): AnimationGroup;
  31581. /**
  31582. * Dispose all associated resources
  31583. */
  31584. dispose(): void;
  31585. private _checkAnimationGroupEnded;
  31586. /**
  31587. * Clone the current animation group and returns a copy
  31588. * @param newName defines the name of the new group
  31589. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31590. * @returns the new aniamtion group
  31591. */
  31592. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31593. /**
  31594. * Returns a new AnimationGroup object parsed from the source provided.
  31595. * @param parsedAnimationGroup defines the source
  31596. * @param scene defines the scene that will receive the animationGroup
  31597. * @returns a new AnimationGroup
  31598. */
  31599. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31600. /**
  31601. * Returns the string "AnimationGroup"
  31602. * @returns "AnimationGroup"
  31603. */
  31604. getClassName(): string;
  31605. /**
  31606. * Creates a detailled string about the object
  31607. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31608. * @returns a string representing the object
  31609. */
  31610. toString(fullDetails?: boolean): string;
  31611. }
  31612. }
  31613. declare module "babylonjs/scene" {
  31614. import { Nullable } from "babylonjs/types";
  31615. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  31616. import { Observable } from "babylonjs/Misc/observable";
  31617. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  31618. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  31619. import { Geometry } from "babylonjs/Meshes/geometry";
  31620. import { TransformNode } from "babylonjs/Meshes/transformNode";
  31621. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31622. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31623. import { Mesh } from "babylonjs/Meshes/mesh";
  31624. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  31625. import { Bone } from "babylonjs/Bones/bone";
  31626. import { Skeleton } from "babylonjs/Bones/skeleton";
  31627. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  31628. import { Camera } from "babylonjs/Cameras/camera";
  31629. import { AbstractScene } from "babylonjs/abstractScene";
  31630. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31631. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31632. import { Material } from "babylonjs/Materials/material";
  31633. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  31634. import { Effect } from "babylonjs/Materials/effect";
  31635. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31636. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  31637. import { Light } from "babylonjs/Lights/light";
  31638. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  31639. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  31640. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  31641. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  31642. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31643. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  31644. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31645. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  31646. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction } from "babylonjs/sceneComponent";
  31647. import { Engine } from "babylonjs/Engines/engine";
  31648. import { Node } from "babylonjs/node";
  31649. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  31650. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  31651. import { Ray } from "babylonjs/Culling/ray";
  31652. import { Animation } from "babylonjs/Animations/animation";
  31653. import { Animatable } from "babylonjs/Animations/animatable";
  31654. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  31655. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  31656. import { Collider } from "babylonjs/Collisions/collider";
  31657. /**
  31658. * Define an interface for all classes that will hold resources
  31659. */
  31660. export interface IDisposable {
  31661. /**
  31662. * Releases all held resources
  31663. */
  31664. dispose(): void;
  31665. }
  31666. /** Interface defining initialization parameters for Scene class */
  31667. export interface SceneOptions {
  31668. /**
  31669. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31670. * It will improve performance when the number of geometries becomes important.
  31671. */
  31672. useGeometryUniqueIdsMap?: boolean;
  31673. /**
  31674. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31675. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31676. */
  31677. useMaterialMeshMap?: boolean;
  31678. /**
  31679. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31680. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31681. */
  31682. useClonedMeshhMap?: boolean;
  31683. }
  31684. /**
  31685. * Represents a scene to be rendered by the engine.
  31686. * @see http://doc.babylonjs.com/features/scene
  31687. */
  31688. export class Scene extends AbstractScene implements IAnimatable {
  31689. private static _uniqueIdCounter;
  31690. /** The fog is deactivated */
  31691. static readonly FOGMODE_NONE: number;
  31692. /** The fog density is following an exponential function */
  31693. static readonly FOGMODE_EXP: number;
  31694. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31695. static readonly FOGMODE_EXP2: number;
  31696. /** The fog density is following a linear function. */
  31697. static readonly FOGMODE_LINEAR: number;
  31698. /**
  31699. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31700. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31701. */
  31702. static MinDeltaTime: number;
  31703. /**
  31704. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31705. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31706. */
  31707. static MaxDeltaTime: number;
  31708. /**
  31709. * Factory used to create the default material.
  31710. * @param name The name of the material to create
  31711. * @param scene The scene to create the material for
  31712. * @returns The default material
  31713. */
  31714. static DefaultMaterialFactory(scene: Scene): Material;
  31715. /**
  31716. * Factory used to create the a collision coordinator.
  31717. * @returns The collision coordinator
  31718. */
  31719. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  31720. /** @hidden */
  31721. readonly _isScene: boolean;
  31722. /**
  31723. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  31724. */
  31725. autoClear: boolean;
  31726. /**
  31727. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  31728. */
  31729. autoClearDepthAndStencil: boolean;
  31730. /**
  31731. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  31732. */
  31733. clearColor: Color4;
  31734. /**
  31735. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  31736. */
  31737. ambientColor: Color3;
  31738. /** @hidden */
  31739. _environmentBRDFTexture: BaseTexture;
  31740. /** @hidden */
  31741. protected _environmentTexture: Nullable<BaseTexture>;
  31742. /**
  31743. * Texture used in all pbr material as the reflection texture.
  31744. * As in the majority of the scene they are the same (exception for multi room and so on),
  31745. * this is easier to reference from here than from all the materials.
  31746. */
  31747. /**
  31748. * Texture used in all pbr material as the reflection texture.
  31749. * As in the majority of the scene they are the same (exception for multi room and so on),
  31750. * this is easier to set here than in all the materials.
  31751. */
  31752. environmentTexture: Nullable<BaseTexture>;
  31753. /** @hidden */
  31754. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31755. /**
  31756. * Default image processing configuration used either in the rendering
  31757. * Forward main pass or through the imageProcessingPostProcess if present.
  31758. * As in the majority of the scene they are the same (exception for multi camera),
  31759. * this is easier to reference from here than from all the materials and post process.
  31760. *
  31761. * No setter as we it is a shared configuration, you can set the values instead.
  31762. */
  31763. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  31764. private _forceWireframe;
  31765. /**
  31766. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  31767. */
  31768. forceWireframe: boolean;
  31769. private _forcePointsCloud;
  31770. /**
  31771. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  31772. */
  31773. forcePointsCloud: boolean;
  31774. /**
  31775. * Gets or sets the active clipplane 1
  31776. */
  31777. clipPlane: Nullable<Plane>;
  31778. /**
  31779. * Gets or sets the active clipplane 2
  31780. */
  31781. clipPlane2: Nullable<Plane>;
  31782. /**
  31783. * Gets or sets the active clipplane 3
  31784. */
  31785. clipPlane3: Nullable<Plane>;
  31786. /**
  31787. * Gets or sets the active clipplane 4
  31788. */
  31789. clipPlane4: Nullable<Plane>;
  31790. /**
  31791. * Gets or sets a boolean indicating if animations are enabled
  31792. */
  31793. animationsEnabled: boolean;
  31794. private _animationPropertiesOverride;
  31795. /**
  31796. * Gets or sets the animation properties override
  31797. */
  31798. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  31799. /**
  31800. * Gets or sets a boolean indicating if a constant deltatime has to be used
  31801. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  31802. */
  31803. useConstantAnimationDeltaTime: boolean;
  31804. /**
  31805. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  31806. * Please note that it requires to run a ray cast through the scene on every frame
  31807. */
  31808. constantlyUpdateMeshUnderPointer: boolean;
  31809. /**
  31810. * Defines the HTML cursor to use when hovering over interactive elements
  31811. */
  31812. hoverCursor: string;
  31813. /**
  31814. * Defines the HTML default cursor to use (empty by default)
  31815. */
  31816. defaultCursor: string;
  31817. /**
  31818. * This is used to call preventDefault() on pointer down
  31819. * in order to block unwanted artifacts like system double clicks
  31820. */
  31821. preventDefaultOnPointerDown: boolean;
  31822. /**
  31823. * This is used to call preventDefault() on pointer up
  31824. * in order to block unwanted artifacts like system double clicks
  31825. */
  31826. preventDefaultOnPointerUp: boolean;
  31827. /**
  31828. * Gets or sets user defined metadata
  31829. */
  31830. metadata: any;
  31831. /**
  31832. * For internal use only. Please do not use.
  31833. */
  31834. reservedDataStore: any;
  31835. /**
  31836. * Gets the name of the plugin used to load this scene (null by default)
  31837. */
  31838. loadingPluginName: string;
  31839. /**
  31840. * Use this array to add regular expressions used to disable offline support for specific urls
  31841. */
  31842. disableOfflineSupportExceptionRules: RegExp[];
  31843. /**
  31844. * An event triggered when the scene is disposed.
  31845. */
  31846. onDisposeObservable: Observable<Scene>;
  31847. private _onDisposeObserver;
  31848. /** Sets a function to be executed when this scene is disposed. */
  31849. onDispose: () => void;
  31850. /**
  31851. * An event triggered before rendering the scene (right after animations and physics)
  31852. */
  31853. onBeforeRenderObservable: Observable<Scene>;
  31854. private _onBeforeRenderObserver;
  31855. /** Sets a function to be executed before rendering this scene */
  31856. beforeRender: Nullable<() => void>;
  31857. /**
  31858. * An event triggered after rendering the scene
  31859. */
  31860. onAfterRenderObservable: Observable<Scene>;
  31861. private _onAfterRenderObserver;
  31862. /** Sets a function to be executed after rendering this scene */
  31863. afterRender: Nullable<() => void>;
  31864. /**
  31865. * An event triggered before animating the scene
  31866. */
  31867. onBeforeAnimationsObservable: Observable<Scene>;
  31868. /**
  31869. * An event triggered after animations processing
  31870. */
  31871. onAfterAnimationsObservable: Observable<Scene>;
  31872. /**
  31873. * An event triggered before draw calls are ready to be sent
  31874. */
  31875. onBeforeDrawPhaseObservable: Observable<Scene>;
  31876. /**
  31877. * An event triggered after draw calls have been sent
  31878. */
  31879. onAfterDrawPhaseObservable: Observable<Scene>;
  31880. /**
  31881. * An event triggered when the scene is ready
  31882. */
  31883. onReadyObservable: Observable<Scene>;
  31884. /**
  31885. * An event triggered before rendering a camera
  31886. */
  31887. onBeforeCameraRenderObservable: Observable<Camera>;
  31888. private _onBeforeCameraRenderObserver;
  31889. /** Sets a function to be executed before rendering a camera*/
  31890. beforeCameraRender: () => void;
  31891. /**
  31892. * An event triggered after rendering a camera
  31893. */
  31894. onAfterCameraRenderObservable: Observable<Camera>;
  31895. private _onAfterCameraRenderObserver;
  31896. /** Sets a function to be executed after rendering a camera*/
  31897. afterCameraRender: () => void;
  31898. /**
  31899. * An event triggered when active meshes evaluation is about to start
  31900. */
  31901. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  31902. /**
  31903. * An event triggered when active meshes evaluation is done
  31904. */
  31905. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  31906. /**
  31907. * An event triggered when particles rendering is about to start
  31908. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31909. */
  31910. onBeforeParticlesRenderingObservable: Observable<Scene>;
  31911. /**
  31912. * An event triggered when particles rendering is done
  31913. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31914. */
  31915. onAfterParticlesRenderingObservable: Observable<Scene>;
  31916. /**
  31917. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  31918. */
  31919. onDataLoadedObservable: Observable<Scene>;
  31920. /**
  31921. * An event triggered when a camera is created
  31922. */
  31923. onNewCameraAddedObservable: Observable<Camera>;
  31924. /**
  31925. * An event triggered when a camera is removed
  31926. */
  31927. onCameraRemovedObservable: Observable<Camera>;
  31928. /**
  31929. * An event triggered when a light is created
  31930. */
  31931. onNewLightAddedObservable: Observable<Light>;
  31932. /**
  31933. * An event triggered when a light is removed
  31934. */
  31935. onLightRemovedObservable: Observable<Light>;
  31936. /**
  31937. * An event triggered when a geometry is created
  31938. */
  31939. onNewGeometryAddedObservable: Observable<Geometry>;
  31940. /**
  31941. * An event triggered when a geometry is removed
  31942. */
  31943. onGeometryRemovedObservable: Observable<Geometry>;
  31944. /**
  31945. * An event triggered when a transform node is created
  31946. */
  31947. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  31948. /**
  31949. * An event triggered when a transform node is removed
  31950. */
  31951. onTransformNodeRemovedObservable: Observable<TransformNode>;
  31952. /**
  31953. * An event triggered when a mesh is created
  31954. */
  31955. onNewMeshAddedObservable: Observable<AbstractMesh>;
  31956. /**
  31957. * An event triggered when a mesh is removed
  31958. */
  31959. onMeshRemovedObservable: Observable<AbstractMesh>;
  31960. /**
  31961. * An event triggered when a material is created
  31962. */
  31963. onNewMaterialAddedObservable: Observable<Material>;
  31964. /**
  31965. * An event triggered when a material is removed
  31966. */
  31967. onMaterialRemovedObservable: Observable<Material>;
  31968. /**
  31969. * An event triggered when a texture is created
  31970. */
  31971. onNewTextureAddedObservable: Observable<BaseTexture>;
  31972. /**
  31973. * An event triggered when a texture is removed
  31974. */
  31975. onTextureRemovedObservable: Observable<BaseTexture>;
  31976. /**
  31977. * An event triggered when render targets are about to be rendered
  31978. * Can happen multiple times per frame.
  31979. */
  31980. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  31981. /**
  31982. * An event triggered when render targets were rendered.
  31983. * Can happen multiple times per frame.
  31984. */
  31985. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  31986. /**
  31987. * An event triggered before calculating deterministic simulation step
  31988. */
  31989. onBeforeStepObservable: Observable<Scene>;
  31990. /**
  31991. * An event triggered after calculating deterministic simulation step
  31992. */
  31993. onAfterStepObservable: Observable<Scene>;
  31994. /**
  31995. * An event triggered when the activeCamera property is updated
  31996. */
  31997. onActiveCameraChanged: Observable<Scene>;
  31998. /**
  31999. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32000. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32001. * 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)
  32002. */
  32003. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32004. /**
  32005. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32006. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32007. * 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)
  32008. */
  32009. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32010. /**
  32011. * This Observable will when a mesh has been imported into the scene.
  32012. */
  32013. onMeshImportedObservable: Observable<AbstractMesh>;
  32014. /** @hidden */
  32015. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32016. /**
  32017. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32018. */
  32019. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32020. /**
  32021. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32022. */
  32023. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32024. /**
  32025. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32026. */
  32027. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32028. private _onPointerMove;
  32029. private _onPointerDown;
  32030. private _onPointerUp;
  32031. /** Callback called when a pointer move is detected */
  32032. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32033. /** Callback called when a pointer down is detected */
  32034. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32035. /** Callback called when a pointer up is detected */
  32036. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32037. /** Callback called when a pointer pick is detected */
  32038. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32039. /**
  32040. * 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).
  32041. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32042. */
  32043. onPrePointerObservable: Observable<PointerInfoPre>;
  32044. /**
  32045. * Observable event triggered each time an input event is received from the rendering canvas
  32046. */
  32047. onPointerObservable: Observable<PointerInfo>;
  32048. /**
  32049. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32050. */
  32051. readonly unTranslatedPointer: Vector2;
  32052. /** The distance in pixel that you have to move to prevent some events */
  32053. static DragMovementThreshold: number;
  32054. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32055. static LongPressDelay: number;
  32056. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32057. static DoubleClickDelay: number;
  32058. /** If you need to check double click without raising a single click at first click, enable this flag */
  32059. static ExclusiveDoubleClickMode: boolean;
  32060. private _initClickEvent;
  32061. private _initActionManager;
  32062. private _delayedSimpleClick;
  32063. private _delayedSimpleClickTimeout;
  32064. private _previousDelayedSimpleClickTimeout;
  32065. private _meshPickProceed;
  32066. private _previousButtonPressed;
  32067. private _currentPickResult;
  32068. private _previousPickResult;
  32069. private _totalPointersPressed;
  32070. private _doubleClickOccured;
  32071. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32072. cameraToUseForPointers: Nullable<Camera>;
  32073. private _pointerX;
  32074. private _pointerY;
  32075. private _unTranslatedPointerX;
  32076. private _unTranslatedPointerY;
  32077. private _startingPointerPosition;
  32078. private _previousStartingPointerPosition;
  32079. private _startingPointerTime;
  32080. private _previousStartingPointerTime;
  32081. private _pointerCaptures;
  32082. private _timeAccumulator;
  32083. private _currentStepId;
  32084. private _currentInternalStep;
  32085. /** @hidden */
  32086. _mirroredCameraPosition: Nullable<Vector3>;
  32087. /**
  32088. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32089. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32090. */
  32091. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32092. /**
  32093. * Observable event triggered each time an keyboard event is received from the hosting window
  32094. */
  32095. onKeyboardObservable: Observable<KeyboardInfo>;
  32096. private _onKeyDown;
  32097. private _onKeyUp;
  32098. private _onCanvasFocusObserver;
  32099. private _onCanvasBlurObserver;
  32100. private _useRightHandedSystem;
  32101. /**
  32102. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32103. */
  32104. useRightHandedSystem: boolean;
  32105. /**
  32106. * Sets the step Id used by deterministic lock step
  32107. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32108. * @param newStepId defines the step Id
  32109. */
  32110. setStepId(newStepId: number): void;
  32111. /**
  32112. * Gets the step Id used by deterministic lock step
  32113. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32114. * @returns the step Id
  32115. */
  32116. getStepId(): number;
  32117. /**
  32118. * Gets the internal step used by deterministic lock step
  32119. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32120. * @returns the internal step
  32121. */
  32122. getInternalStep(): number;
  32123. private _fogEnabled;
  32124. /**
  32125. * Gets or sets a boolean indicating if fog is enabled on this scene
  32126. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32127. * (Default is true)
  32128. */
  32129. fogEnabled: boolean;
  32130. private _fogMode;
  32131. /**
  32132. * Gets or sets the fog mode to use
  32133. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32134. * | mode | value |
  32135. * | --- | --- |
  32136. * | FOGMODE_NONE | 0 |
  32137. * | FOGMODE_EXP | 1 |
  32138. * | FOGMODE_EXP2 | 2 |
  32139. * | FOGMODE_LINEAR | 3 |
  32140. */
  32141. fogMode: number;
  32142. /**
  32143. * Gets or sets the fog color to use
  32144. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32145. * (Default is Color3(0.2, 0.2, 0.3))
  32146. */
  32147. fogColor: Color3;
  32148. /**
  32149. * Gets or sets the fog density to use
  32150. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32151. * (Default is 0.1)
  32152. */
  32153. fogDensity: number;
  32154. /**
  32155. * Gets or sets the fog start distance to use
  32156. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32157. * (Default is 0)
  32158. */
  32159. fogStart: number;
  32160. /**
  32161. * Gets or sets the fog end distance to use
  32162. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32163. * (Default is 1000)
  32164. */
  32165. fogEnd: number;
  32166. private _shadowsEnabled;
  32167. /**
  32168. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32169. */
  32170. shadowsEnabled: boolean;
  32171. private _lightsEnabled;
  32172. /**
  32173. * Gets or sets a boolean indicating if lights are enabled on this scene
  32174. */
  32175. lightsEnabled: boolean;
  32176. /** All of the active cameras added to this scene. */
  32177. activeCameras: Camera[];
  32178. private _activeCamera;
  32179. /** Gets or sets the current active camera */
  32180. activeCamera: Nullable<Camera>;
  32181. private _defaultMaterial;
  32182. /** The default material used on meshes when no material is affected */
  32183. /** The default material used on meshes when no material is affected */
  32184. defaultMaterial: Material;
  32185. private _texturesEnabled;
  32186. /**
  32187. * Gets or sets a boolean indicating if textures are enabled on this scene
  32188. */
  32189. texturesEnabled: boolean;
  32190. /**
  32191. * Gets or sets a boolean indicating if particles are enabled on this scene
  32192. */
  32193. particlesEnabled: boolean;
  32194. /**
  32195. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32196. */
  32197. spritesEnabled: boolean;
  32198. private _skeletonsEnabled;
  32199. /**
  32200. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32201. */
  32202. skeletonsEnabled: boolean;
  32203. /**
  32204. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32205. */
  32206. lensFlaresEnabled: boolean;
  32207. /**
  32208. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32209. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32210. */
  32211. collisionsEnabled: boolean;
  32212. private _collisionCoordinator;
  32213. /** @hidden */
  32214. readonly collisionCoordinator: ICollisionCoordinator;
  32215. /**
  32216. * Defines the gravity applied to this scene (used only for collisions)
  32217. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32218. */
  32219. gravity: Vector3;
  32220. /**
  32221. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32222. */
  32223. postProcessesEnabled: boolean;
  32224. /**
  32225. * The list of postprocesses added to the scene
  32226. */
  32227. postProcesses: PostProcess[];
  32228. /**
  32229. * Gets the current postprocess manager
  32230. */
  32231. postProcessManager: PostProcessManager;
  32232. /**
  32233. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32234. */
  32235. renderTargetsEnabled: boolean;
  32236. /**
  32237. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32238. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32239. */
  32240. dumpNextRenderTargets: boolean;
  32241. /**
  32242. * The list of user defined render targets added to the scene
  32243. */
  32244. customRenderTargets: RenderTargetTexture[];
  32245. /**
  32246. * Defines if texture loading must be delayed
  32247. * If true, textures will only be loaded when they need to be rendered
  32248. */
  32249. useDelayedTextureLoading: boolean;
  32250. /**
  32251. * Gets the list of meshes imported to the scene through SceneLoader
  32252. */
  32253. importedMeshesFiles: String[];
  32254. /**
  32255. * Gets or sets a boolean indicating if probes are enabled on this scene
  32256. */
  32257. probesEnabled: boolean;
  32258. /**
  32259. * Gets or sets the current offline provider to use to store scene data
  32260. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32261. */
  32262. offlineProvider: IOfflineProvider;
  32263. /**
  32264. * Gets or sets the action manager associated with the scene
  32265. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32266. */
  32267. actionManager: AbstractActionManager;
  32268. private _meshesForIntersections;
  32269. /**
  32270. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32271. */
  32272. proceduralTexturesEnabled: boolean;
  32273. private _engine;
  32274. private _totalVertices;
  32275. /** @hidden */
  32276. _activeIndices: PerfCounter;
  32277. /** @hidden */
  32278. _activeParticles: PerfCounter;
  32279. /** @hidden */
  32280. _activeBones: PerfCounter;
  32281. private _animationRatio;
  32282. /** @hidden */
  32283. _animationTimeLast: number;
  32284. /** @hidden */
  32285. _animationTime: number;
  32286. /**
  32287. * Gets or sets a general scale for animation speed
  32288. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32289. */
  32290. animationTimeScale: number;
  32291. /** @hidden */
  32292. _cachedMaterial: Nullable<Material>;
  32293. /** @hidden */
  32294. _cachedEffect: Nullable<Effect>;
  32295. /** @hidden */
  32296. _cachedVisibility: Nullable<number>;
  32297. private _renderId;
  32298. private _frameId;
  32299. private _executeWhenReadyTimeoutId;
  32300. private _intermediateRendering;
  32301. private _viewUpdateFlag;
  32302. private _projectionUpdateFlag;
  32303. private _alternateViewUpdateFlag;
  32304. private _alternateProjectionUpdateFlag;
  32305. /** @hidden */
  32306. _toBeDisposed: Nullable<IDisposable>[];
  32307. private _activeRequests;
  32308. /** @hidden */
  32309. _pendingData: any[];
  32310. private _isDisposed;
  32311. /**
  32312. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32313. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32314. */
  32315. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32316. private _activeMeshes;
  32317. private _processedMaterials;
  32318. private _renderTargets;
  32319. /** @hidden */
  32320. _activeParticleSystems: SmartArray<IParticleSystem>;
  32321. private _activeSkeletons;
  32322. private _softwareSkinnedMeshes;
  32323. private _renderingManager;
  32324. /** @hidden */
  32325. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  32326. private _transformMatrix;
  32327. private _sceneUbo;
  32328. private _alternateSceneUbo;
  32329. private _viewMatrix;
  32330. private _projectionMatrix;
  32331. private _alternateViewMatrix;
  32332. private _alternateProjectionMatrix;
  32333. private _alternateTransformMatrix;
  32334. private _useAlternateCameraConfiguration;
  32335. private _alternateRendering;
  32336. private _wheelEventName;
  32337. /** @hidden */
  32338. _forcedViewPosition: Nullable<Vector3>;
  32339. /** @hidden */
  32340. readonly _isAlternateRenderingEnabled: boolean;
  32341. private _frustumPlanes;
  32342. /**
  32343. * Gets the list of frustum planes (built from the active camera)
  32344. */
  32345. readonly frustumPlanes: Plane[];
  32346. /**
  32347. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32348. * This is useful if there are more lights that the maximum simulteanous authorized
  32349. */
  32350. requireLightSorting: boolean;
  32351. /** @hidden */
  32352. readonly useMaterialMeshMap: boolean;
  32353. /** @hidden */
  32354. readonly useClonedMeshhMap: boolean;
  32355. private _pointerOverMesh;
  32356. private _pickedDownMesh;
  32357. private _pickedUpMesh;
  32358. private _externalData;
  32359. private _uid;
  32360. /**
  32361. * @hidden
  32362. * Backing store of defined scene components.
  32363. */
  32364. _components: ISceneComponent[];
  32365. /**
  32366. * @hidden
  32367. * Backing store of defined scene components.
  32368. */
  32369. _serializableComponents: ISceneSerializableComponent[];
  32370. /**
  32371. * List of components to register on the next registration step.
  32372. */
  32373. private _transientComponents;
  32374. /**
  32375. * Registers the transient components if needed.
  32376. */
  32377. private _registerTransientComponents;
  32378. /**
  32379. * @hidden
  32380. * Add a component to the scene.
  32381. * Note that the ccomponent could be registered on th next frame if this is called after
  32382. * the register component stage.
  32383. * @param component Defines the component to add to the scene
  32384. */
  32385. _addComponent(component: ISceneComponent): void;
  32386. /**
  32387. * @hidden
  32388. * Gets a component from the scene.
  32389. * @param name defines the name of the component to retrieve
  32390. * @returns the component or null if not present
  32391. */
  32392. _getComponent(name: string): Nullable<ISceneComponent>;
  32393. /**
  32394. * @hidden
  32395. * Defines the actions happening before camera updates.
  32396. */
  32397. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32398. /**
  32399. * @hidden
  32400. * Defines the actions happening before clear the canvas.
  32401. */
  32402. _beforeClearStage: Stage<SimpleStageAction>;
  32403. /**
  32404. * @hidden
  32405. * Defines the actions when collecting render targets for the frame.
  32406. */
  32407. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32408. /**
  32409. * @hidden
  32410. * Defines the actions happening for one camera in the frame.
  32411. */
  32412. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32413. /**
  32414. * @hidden
  32415. * Defines the actions happening during the per mesh ready checks.
  32416. */
  32417. _isReadyForMeshStage: Stage<MeshStageAction>;
  32418. /**
  32419. * @hidden
  32420. * Defines the actions happening before evaluate active mesh checks.
  32421. */
  32422. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32423. /**
  32424. * @hidden
  32425. * Defines the actions happening during the evaluate sub mesh checks.
  32426. */
  32427. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32428. /**
  32429. * @hidden
  32430. * Defines the actions happening during the active mesh stage.
  32431. */
  32432. _activeMeshStage: Stage<ActiveMeshStageAction>;
  32433. /**
  32434. * @hidden
  32435. * Defines the actions happening during the per camera render target step.
  32436. */
  32437. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  32438. /**
  32439. * @hidden
  32440. * Defines the actions happening just before the active camera is drawing.
  32441. */
  32442. _beforeCameraDrawStage: Stage<CameraStageAction>;
  32443. /**
  32444. * @hidden
  32445. * Defines the actions happening just before a render target is drawing.
  32446. */
  32447. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32448. /**
  32449. * @hidden
  32450. * Defines the actions happening just before a rendering group is drawing.
  32451. */
  32452. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32453. /**
  32454. * @hidden
  32455. * Defines the actions happening just before a mesh is drawing.
  32456. */
  32457. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32458. /**
  32459. * @hidden
  32460. * Defines the actions happening just after a mesh has been drawn.
  32461. */
  32462. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32463. /**
  32464. * @hidden
  32465. * Defines the actions happening just after a rendering group has been drawn.
  32466. */
  32467. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32468. /**
  32469. * @hidden
  32470. * Defines the actions happening just after the active camera has been drawn.
  32471. */
  32472. _afterCameraDrawStage: Stage<CameraStageAction>;
  32473. /**
  32474. * @hidden
  32475. * Defines the actions happening just after a render target has been drawn.
  32476. */
  32477. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32478. /**
  32479. * @hidden
  32480. * Defines the actions happening just after rendering all cameras and computing intersections.
  32481. */
  32482. _afterRenderStage: Stage<SimpleStageAction>;
  32483. /**
  32484. * @hidden
  32485. * Defines the actions happening when a pointer move event happens.
  32486. */
  32487. _pointerMoveStage: Stage<PointerMoveStageAction>;
  32488. /**
  32489. * @hidden
  32490. * Defines the actions happening when a pointer down event happens.
  32491. */
  32492. _pointerDownStage: Stage<PointerUpDownStageAction>;
  32493. /**
  32494. * @hidden
  32495. * Defines the actions happening when a pointer up event happens.
  32496. */
  32497. _pointerUpStage: Stage<PointerUpDownStageAction>;
  32498. /**
  32499. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32500. */
  32501. private geometriesByUniqueId;
  32502. /**
  32503. * Creates a new Scene
  32504. * @param engine defines the engine to use to render this scene
  32505. * @param options defines the scene options
  32506. */
  32507. constructor(engine: Engine, options?: SceneOptions);
  32508. private _defaultMeshCandidates;
  32509. /**
  32510. * @hidden
  32511. */
  32512. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32513. private _defaultSubMeshCandidates;
  32514. /**
  32515. * @hidden
  32516. */
  32517. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32518. /**
  32519. * Sets the default candidate providers for the scene.
  32520. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32521. * and getCollidingSubMeshCandidates to their default function
  32522. */
  32523. setDefaultCandidateProviders(): void;
  32524. /**
  32525. * Gets the mesh that is currently under the pointer
  32526. */
  32527. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32528. /**
  32529. * Gets or sets the current on-screen X position of the pointer
  32530. */
  32531. pointerX: number;
  32532. /**
  32533. * Gets or sets the current on-screen Y position of the pointer
  32534. */
  32535. pointerY: number;
  32536. /**
  32537. * Gets the cached material (ie. the latest rendered one)
  32538. * @returns the cached material
  32539. */
  32540. getCachedMaterial(): Nullable<Material>;
  32541. /**
  32542. * Gets the cached effect (ie. the latest rendered one)
  32543. * @returns the cached effect
  32544. */
  32545. getCachedEffect(): Nullable<Effect>;
  32546. /**
  32547. * Gets the cached visibility state (ie. the latest rendered one)
  32548. * @returns the cached visibility state
  32549. */
  32550. getCachedVisibility(): Nullable<number>;
  32551. /**
  32552. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32553. * @param material defines the current material
  32554. * @param effect defines the current effect
  32555. * @param visibility defines the current visibility state
  32556. * @returns true if one parameter is not cached
  32557. */
  32558. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32559. /**
  32560. * Gets the engine associated with the scene
  32561. * @returns an Engine
  32562. */
  32563. getEngine(): Engine;
  32564. /**
  32565. * Gets the total number of vertices rendered per frame
  32566. * @returns the total number of vertices rendered per frame
  32567. */
  32568. getTotalVertices(): number;
  32569. /**
  32570. * Gets the performance counter for total vertices
  32571. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32572. */
  32573. readonly totalVerticesPerfCounter: PerfCounter;
  32574. /**
  32575. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32576. * @returns the total number of active indices rendered per frame
  32577. */
  32578. getActiveIndices(): number;
  32579. /**
  32580. * Gets the performance counter for active indices
  32581. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32582. */
  32583. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32584. /**
  32585. * Gets the total number of active particles rendered per frame
  32586. * @returns the total number of active particles rendered per frame
  32587. */
  32588. getActiveParticles(): number;
  32589. /**
  32590. * Gets the performance counter for active particles
  32591. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32592. */
  32593. readonly activeParticlesPerfCounter: PerfCounter;
  32594. /**
  32595. * Gets the total number of active bones rendered per frame
  32596. * @returns the total number of active bones rendered per frame
  32597. */
  32598. getActiveBones(): number;
  32599. /**
  32600. * Gets the performance counter for active bones
  32601. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32602. */
  32603. readonly activeBonesPerfCounter: PerfCounter;
  32604. /**
  32605. * Gets the array of active meshes
  32606. * @returns an array of AbstractMesh
  32607. */
  32608. getActiveMeshes(): SmartArray<AbstractMesh>;
  32609. /**
  32610. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32611. * @returns a number
  32612. */
  32613. getAnimationRatio(): number;
  32614. /**
  32615. * Gets an unique Id for the current render phase
  32616. * @returns a number
  32617. */
  32618. getRenderId(): number;
  32619. /**
  32620. * Gets an unique Id for the current frame
  32621. * @returns a number
  32622. */
  32623. getFrameId(): number;
  32624. /** Call this function if you want to manually increment the render Id*/
  32625. incrementRenderId(): void;
  32626. private _updatePointerPosition;
  32627. private _createUbo;
  32628. private _createAlternateUbo;
  32629. private _setRayOnPointerInfo;
  32630. /**
  32631. * Use this method to simulate a pointer move on a mesh
  32632. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32633. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32634. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32635. * @returns the current scene
  32636. */
  32637. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32638. private _processPointerMove;
  32639. private _checkPrePointerObservable;
  32640. /**
  32641. * Use this method to simulate a pointer down on a mesh
  32642. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32643. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32644. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32645. * @returns the current scene
  32646. */
  32647. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32648. private _processPointerDown;
  32649. /**
  32650. * Use this method to simulate a pointer up on a mesh
  32651. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32652. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32653. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32654. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32655. * @returns the current scene
  32656. */
  32657. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32658. private _processPointerUp;
  32659. /**
  32660. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32661. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32662. * @returns true if the pointer was captured
  32663. */
  32664. isPointerCaptured(pointerId?: number): boolean;
  32665. /** @hidden */
  32666. _isPointerSwiping(): boolean;
  32667. /**
  32668. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32669. * @param attachUp defines if you want to attach events to pointerup
  32670. * @param attachDown defines if you want to attach events to pointerdown
  32671. * @param attachMove defines if you want to attach events to pointermove
  32672. */
  32673. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32674. /** Detaches all event handlers*/
  32675. detachControl(): void;
  32676. /**
  32677. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32678. * Delay loaded resources are not taking in account
  32679. * @return true if all required resources are ready
  32680. */
  32681. isReady(): boolean;
  32682. /** Resets all cached information relative to material (including effect and visibility) */
  32683. resetCachedMaterial(): void;
  32684. /**
  32685. * Registers a function to be called before every frame render
  32686. * @param func defines the function to register
  32687. */
  32688. registerBeforeRender(func: () => void): void;
  32689. /**
  32690. * Unregisters a function called before every frame render
  32691. * @param func defines the function to unregister
  32692. */
  32693. unregisterBeforeRender(func: () => void): void;
  32694. /**
  32695. * Registers a function to be called after every frame render
  32696. * @param func defines the function to register
  32697. */
  32698. registerAfterRender(func: () => void): void;
  32699. /**
  32700. * Unregisters a function called after every frame render
  32701. * @param func defines the function to unregister
  32702. */
  32703. unregisterAfterRender(func: () => void): void;
  32704. private _executeOnceBeforeRender;
  32705. /**
  32706. * The provided function will run before render once and will be disposed afterwards.
  32707. * A timeout delay can be provided so that the function will be executed in N ms.
  32708. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32709. * @param func The function to be executed.
  32710. * @param timeout optional delay in ms
  32711. */
  32712. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32713. /** @hidden */
  32714. _addPendingData(data: any): void;
  32715. /** @hidden */
  32716. _removePendingData(data: any): void;
  32717. /**
  32718. * Returns the number of items waiting to be loaded
  32719. * @returns the number of items waiting to be loaded
  32720. */
  32721. getWaitingItemsCount(): number;
  32722. /**
  32723. * Returns a boolean indicating if the scene is still loading data
  32724. */
  32725. readonly isLoading: boolean;
  32726. /**
  32727. * Registers a function to be executed when the scene is ready
  32728. * @param {Function} func - the function to be executed
  32729. */
  32730. executeWhenReady(func: () => void): void;
  32731. /**
  32732. * Returns a promise that resolves when the scene is ready
  32733. * @returns A promise that resolves when the scene is ready
  32734. */
  32735. whenReadyAsync(): Promise<void>;
  32736. /** @hidden */
  32737. _checkIsReady(): void;
  32738. /**
  32739. * Gets all animatable attached to the scene
  32740. */
  32741. readonly animatables: Animatable[];
  32742. /**
  32743. * Resets the last animation time frame.
  32744. * Useful to override when animations start running when loading a scene for the first time.
  32745. */
  32746. resetLastAnimationTimeFrame(): void;
  32747. /** @hidden */
  32748. _switchToAlternateCameraConfiguration(active: boolean): void;
  32749. /**
  32750. * Gets the current view matrix
  32751. * @returns a Matrix
  32752. */
  32753. getViewMatrix(): Matrix;
  32754. /**
  32755. * Gets the current projection matrix
  32756. * @returns a Matrix
  32757. */
  32758. getProjectionMatrix(): Matrix;
  32759. /**
  32760. * Gets the current transform matrix
  32761. * @returns a Matrix made of View * Projection
  32762. */
  32763. getTransformMatrix(): Matrix;
  32764. /**
  32765. * Sets the current transform matrix
  32766. * @param view defines the View matrix to use
  32767. * @param projection defines the Projection matrix to use
  32768. */
  32769. setTransformMatrix(view: Matrix, projection: Matrix): void;
  32770. /** @hidden */
  32771. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  32772. /**
  32773. * Gets the uniform buffer used to store scene data
  32774. * @returns a UniformBuffer
  32775. */
  32776. getSceneUniformBuffer(): UniformBuffer;
  32777. /**
  32778. * Gets an unique (relatively to the current scene) Id
  32779. * @returns an unique number for the scene
  32780. */
  32781. getUniqueId(): number;
  32782. /**
  32783. * Add a mesh to the list of scene's meshes
  32784. * @param newMesh defines the mesh to add
  32785. * @param recursive if all child meshes should also be added to the scene
  32786. */
  32787. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  32788. /**
  32789. * Remove a mesh for the list of scene's meshes
  32790. * @param toRemove defines the mesh to remove
  32791. * @param recursive if all child meshes should also be removed from the scene
  32792. * @returns the index where the mesh was in the mesh list
  32793. */
  32794. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  32795. /**
  32796. * Add a transform node to the list of scene's transform nodes
  32797. * @param newTransformNode defines the transform node to add
  32798. */
  32799. addTransformNode(newTransformNode: TransformNode): void;
  32800. /**
  32801. * Remove a transform node for the list of scene's transform nodes
  32802. * @param toRemove defines the transform node to remove
  32803. * @returns the index where the transform node was in the transform node list
  32804. */
  32805. removeTransformNode(toRemove: TransformNode): number;
  32806. /**
  32807. * Remove a skeleton for the list of scene's skeletons
  32808. * @param toRemove defines the skeleton to remove
  32809. * @returns the index where the skeleton was in the skeleton list
  32810. */
  32811. removeSkeleton(toRemove: Skeleton): number;
  32812. /**
  32813. * Remove a morph target for the list of scene's morph targets
  32814. * @param toRemove defines the morph target to remove
  32815. * @returns the index where the morph target was in the morph target list
  32816. */
  32817. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  32818. /**
  32819. * Remove a light for the list of scene's lights
  32820. * @param toRemove defines the light to remove
  32821. * @returns the index where the light was in the light list
  32822. */
  32823. removeLight(toRemove: Light): number;
  32824. /**
  32825. * Remove a camera for the list of scene's cameras
  32826. * @param toRemove defines the camera to remove
  32827. * @returns the index where the camera was in the camera list
  32828. */
  32829. removeCamera(toRemove: Camera): number;
  32830. /**
  32831. * Remove a particle system for the list of scene's particle systems
  32832. * @param toRemove defines the particle system to remove
  32833. * @returns the index where the particle system was in the particle system list
  32834. */
  32835. removeParticleSystem(toRemove: IParticleSystem): number;
  32836. /**
  32837. * Remove a animation for the list of scene's animations
  32838. * @param toRemove defines the animation to remove
  32839. * @returns the index where the animation was in the animation list
  32840. */
  32841. removeAnimation(toRemove: Animation): number;
  32842. /**
  32843. * Removes the given animation group from this scene.
  32844. * @param toRemove The animation group to remove
  32845. * @returns The index of the removed animation group
  32846. */
  32847. removeAnimationGroup(toRemove: AnimationGroup): number;
  32848. /**
  32849. * Removes the given multi-material from this scene.
  32850. * @param toRemove The multi-material to remove
  32851. * @returns The index of the removed multi-material
  32852. */
  32853. removeMultiMaterial(toRemove: MultiMaterial): number;
  32854. /**
  32855. * Removes the given material from this scene.
  32856. * @param toRemove The material to remove
  32857. * @returns The index of the removed material
  32858. */
  32859. removeMaterial(toRemove: Material): number;
  32860. /**
  32861. * Removes the given action manager from this scene.
  32862. * @param toRemove The action manager to remove
  32863. * @returns The index of the removed action manager
  32864. */
  32865. removeActionManager(toRemove: AbstractActionManager): number;
  32866. /**
  32867. * Removes the given texture from this scene.
  32868. * @param toRemove The texture to remove
  32869. * @returns The index of the removed texture
  32870. */
  32871. removeTexture(toRemove: BaseTexture): number;
  32872. /**
  32873. * Adds the given light to this scene
  32874. * @param newLight The light to add
  32875. */
  32876. addLight(newLight: Light): void;
  32877. /**
  32878. * Sorts the list list based on light priorities
  32879. */
  32880. sortLightsByPriority(): void;
  32881. /**
  32882. * Adds the given camera to this scene
  32883. * @param newCamera The camera to add
  32884. */
  32885. addCamera(newCamera: Camera): void;
  32886. /**
  32887. * Adds the given skeleton to this scene
  32888. * @param newSkeleton The skeleton to add
  32889. */
  32890. addSkeleton(newSkeleton: Skeleton): void;
  32891. /**
  32892. * Adds the given particle system to this scene
  32893. * @param newParticleSystem The particle system to add
  32894. */
  32895. addParticleSystem(newParticleSystem: IParticleSystem): void;
  32896. /**
  32897. * Adds the given animation to this scene
  32898. * @param newAnimation The animation to add
  32899. */
  32900. addAnimation(newAnimation: Animation): void;
  32901. /**
  32902. * Adds the given animation group to this scene.
  32903. * @param newAnimationGroup The animation group to add
  32904. */
  32905. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  32906. /**
  32907. * Adds the given multi-material to this scene
  32908. * @param newMultiMaterial The multi-material to add
  32909. */
  32910. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  32911. /**
  32912. * Adds the given material to this scene
  32913. * @param newMaterial The material to add
  32914. */
  32915. addMaterial(newMaterial: Material): void;
  32916. /**
  32917. * Adds the given morph target to this scene
  32918. * @param newMorphTargetManager The morph target to add
  32919. */
  32920. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  32921. /**
  32922. * Adds the given geometry to this scene
  32923. * @param newGeometry The geometry to add
  32924. */
  32925. addGeometry(newGeometry: Geometry): void;
  32926. /**
  32927. * Adds the given action manager to this scene
  32928. * @param newActionManager The action manager to add
  32929. */
  32930. addActionManager(newActionManager: AbstractActionManager): void;
  32931. /**
  32932. * Adds the given texture to this scene.
  32933. * @param newTexture The texture to add
  32934. */
  32935. addTexture(newTexture: BaseTexture): void;
  32936. /**
  32937. * Switch active camera
  32938. * @param newCamera defines the new active camera
  32939. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  32940. */
  32941. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  32942. /**
  32943. * sets the active camera of the scene using its ID
  32944. * @param id defines the camera's ID
  32945. * @return the new active camera or null if none found.
  32946. */
  32947. setActiveCameraByID(id: string): Nullable<Camera>;
  32948. /**
  32949. * sets the active camera of the scene using its name
  32950. * @param name defines the camera's name
  32951. * @returns the new active camera or null if none found.
  32952. */
  32953. setActiveCameraByName(name: string): Nullable<Camera>;
  32954. /**
  32955. * get an animation group using its name
  32956. * @param name defines the material's name
  32957. * @return the animation group or null if none found.
  32958. */
  32959. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  32960. /**
  32961. * get a material using its id
  32962. * @param id defines the material's ID
  32963. * @return the material or null if none found.
  32964. */
  32965. getMaterialByID(id: string): Nullable<Material>;
  32966. /**
  32967. * Gets a material using its name
  32968. * @param name defines the material's name
  32969. * @return the material or null if none found.
  32970. */
  32971. getMaterialByName(name: string): Nullable<Material>;
  32972. /**
  32973. * Gets a camera using its id
  32974. * @param id defines the id to look for
  32975. * @returns the camera or null if not found
  32976. */
  32977. getCameraByID(id: string): Nullable<Camera>;
  32978. /**
  32979. * Gets a camera using its unique id
  32980. * @param uniqueId defines the unique id to look for
  32981. * @returns the camera or null if not found
  32982. */
  32983. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  32984. /**
  32985. * Gets a camera using its name
  32986. * @param name defines the camera's name
  32987. * @return the camera or null if none found.
  32988. */
  32989. getCameraByName(name: string): Nullable<Camera>;
  32990. /**
  32991. * Gets a bone using its id
  32992. * @param id defines the bone's id
  32993. * @return the bone or null if not found
  32994. */
  32995. getBoneByID(id: string): Nullable<Bone>;
  32996. /**
  32997. * Gets a bone using its id
  32998. * @param name defines the bone's name
  32999. * @return the bone or null if not found
  33000. */
  33001. getBoneByName(name: string): Nullable<Bone>;
  33002. /**
  33003. * Gets a light node using its name
  33004. * @param name defines the the light's name
  33005. * @return the light or null if none found.
  33006. */
  33007. getLightByName(name: string): Nullable<Light>;
  33008. /**
  33009. * Gets a light node using its id
  33010. * @param id defines the light's id
  33011. * @return the light or null if none found.
  33012. */
  33013. getLightByID(id: string): Nullable<Light>;
  33014. /**
  33015. * Gets a light node using its scene-generated unique ID
  33016. * @param uniqueId defines the light's unique id
  33017. * @return the light or null if none found.
  33018. */
  33019. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33020. /**
  33021. * Gets a particle system by id
  33022. * @param id defines the particle system id
  33023. * @return the corresponding system or null if none found
  33024. */
  33025. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33026. /**
  33027. * Gets a geometry using its ID
  33028. * @param id defines the geometry's id
  33029. * @return the geometry or null if none found.
  33030. */
  33031. getGeometryByID(id: string): Nullable<Geometry>;
  33032. private _getGeometryByUniqueID;
  33033. /**
  33034. * Add a new geometry to this scene
  33035. * @param geometry defines the geometry to be added to the scene.
  33036. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33037. * @return a boolean defining if the geometry was added or not
  33038. */
  33039. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33040. /**
  33041. * Removes an existing geometry
  33042. * @param geometry defines the geometry to be removed from the scene
  33043. * @return a boolean defining if the geometry was removed or not
  33044. */
  33045. removeGeometry(geometry: Geometry): boolean;
  33046. /**
  33047. * Gets the list of geometries attached to the scene
  33048. * @returns an array of Geometry
  33049. */
  33050. getGeometries(): Geometry[];
  33051. /**
  33052. * Gets the first added mesh found of a given ID
  33053. * @param id defines the id to search for
  33054. * @return the mesh found or null if not found at all
  33055. */
  33056. getMeshByID(id: string): Nullable<AbstractMesh>;
  33057. /**
  33058. * Gets a list of meshes using their id
  33059. * @param id defines the id to search for
  33060. * @returns a list of meshes
  33061. */
  33062. getMeshesByID(id: string): Array<AbstractMesh>;
  33063. /**
  33064. * Gets the first added transform node found of a given ID
  33065. * @param id defines the id to search for
  33066. * @return the found transform node or null if not found at all.
  33067. */
  33068. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33069. /**
  33070. * Gets a list of transform nodes using their id
  33071. * @param id defines the id to search for
  33072. * @returns a list of transform nodes
  33073. */
  33074. getTransformNodesByID(id: string): Array<TransformNode>;
  33075. /**
  33076. * Gets a mesh with its auto-generated unique id
  33077. * @param uniqueId defines the unique id to search for
  33078. * @return the found mesh or null if not found at all.
  33079. */
  33080. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33081. /**
  33082. * Gets a the last added mesh using a given id
  33083. * @param id defines the id to search for
  33084. * @return the found mesh or null if not found at all.
  33085. */
  33086. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33087. /**
  33088. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33089. * @param id defines the id to search for
  33090. * @return the found node or null if not found at all
  33091. */
  33092. getLastEntryByID(id: string): Nullable<Node>;
  33093. /**
  33094. * Gets a node (Mesh, Camera, Light) using a given id
  33095. * @param id defines the id to search for
  33096. * @return the found node or null if not found at all
  33097. */
  33098. getNodeByID(id: string): Nullable<Node>;
  33099. /**
  33100. * Gets a node (Mesh, Camera, Light) using a given name
  33101. * @param name defines the name to search for
  33102. * @return the found node or null if not found at all.
  33103. */
  33104. getNodeByName(name: string): Nullable<Node>;
  33105. /**
  33106. * Gets a mesh using a given name
  33107. * @param name defines the name to search for
  33108. * @return the found mesh or null if not found at all.
  33109. */
  33110. getMeshByName(name: string): Nullable<AbstractMesh>;
  33111. /**
  33112. * Gets a transform node using a given name
  33113. * @param name defines the name to search for
  33114. * @return the found transform node or null if not found at all.
  33115. */
  33116. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33117. /**
  33118. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33119. * @param id defines the id to search for
  33120. * @return the found skeleton or null if not found at all.
  33121. */
  33122. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33123. /**
  33124. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33125. * @param id defines the id to search for
  33126. * @return the found skeleton or null if not found at all.
  33127. */
  33128. getSkeletonById(id: string): Nullable<Skeleton>;
  33129. /**
  33130. * Gets a skeleton using a given name
  33131. * @param name defines the name to search for
  33132. * @return the found skeleton or null if not found at all.
  33133. */
  33134. getSkeletonByName(name: string): Nullable<Skeleton>;
  33135. /**
  33136. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33137. * @param id defines the id to search for
  33138. * @return the found morph target manager or null if not found at all.
  33139. */
  33140. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33141. /**
  33142. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33143. * @param id defines the id to search for
  33144. * @return the found morph target or null if not found at all.
  33145. */
  33146. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33147. /**
  33148. * Gets a boolean indicating if the given mesh is active
  33149. * @param mesh defines the mesh to look for
  33150. * @returns true if the mesh is in the active list
  33151. */
  33152. isActiveMesh(mesh: AbstractMesh): boolean;
  33153. /**
  33154. * Return a unique id as a string which can serve as an identifier for the scene
  33155. */
  33156. readonly uid: string;
  33157. /**
  33158. * Add an externaly attached data from its key.
  33159. * This method call will fail and return false, if such key already exists.
  33160. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33161. * @param key the unique key that identifies the data
  33162. * @param data the data object to associate to the key for this Engine instance
  33163. * @return true if no such key were already present and the data was added successfully, false otherwise
  33164. */
  33165. addExternalData<T>(key: string, data: T): boolean;
  33166. /**
  33167. * Get an externaly attached data from its key
  33168. * @param key the unique key that identifies the data
  33169. * @return the associated data, if present (can be null), or undefined if not present
  33170. */
  33171. getExternalData<T>(key: string): Nullable<T>;
  33172. /**
  33173. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33174. * @param key the unique key that identifies the data
  33175. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33176. * @return the associated data, can be null if the factory returned null.
  33177. */
  33178. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33179. /**
  33180. * Remove an externaly attached data from the Engine instance
  33181. * @param key the unique key that identifies the data
  33182. * @return true if the data was successfully removed, false if it doesn't exist
  33183. */
  33184. removeExternalData(key: string): boolean;
  33185. private _evaluateSubMesh;
  33186. /**
  33187. * Clear the processed materials smart array preventing retention point in material dispose.
  33188. */
  33189. freeProcessedMaterials(): void;
  33190. private _preventFreeActiveMeshesAndRenderingGroups;
  33191. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33192. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33193. * when disposing several meshes in a row or a hierarchy of meshes.
  33194. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33195. */
  33196. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33197. /**
  33198. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33199. */
  33200. freeActiveMeshes(): void;
  33201. /**
  33202. * Clear the info related to rendering groups preventing retention points during dispose.
  33203. */
  33204. freeRenderingGroups(): void;
  33205. /** @hidden */
  33206. _isInIntermediateRendering(): boolean;
  33207. /**
  33208. * Lambda returning the list of potentially active meshes.
  33209. */
  33210. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33211. /**
  33212. * Lambda returning the list of potentially active sub meshes.
  33213. */
  33214. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33215. /**
  33216. * Lambda returning the list of potentially intersecting sub meshes.
  33217. */
  33218. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33219. /**
  33220. * Lambda returning the list of potentially colliding sub meshes.
  33221. */
  33222. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33223. private _activeMeshesFrozen;
  33224. /**
  33225. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33226. * @returns the current scene
  33227. */
  33228. freezeActiveMeshes(): Scene;
  33229. /**
  33230. * Use this function to restart evaluating active meshes on every frame
  33231. * @returns the current scene
  33232. */
  33233. unfreezeActiveMeshes(): Scene;
  33234. private _evaluateActiveMeshes;
  33235. private _activeMesh;
  33236. /**
  33237. * Update the transform matrix to update from the current active camera
  33238. * @param force defines a boolean used to force the update even if cache is up to date
  33239. */
  33240. updateTransformMatrix(force?: boolean): void;
  33241. /**
  33242. * 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)
  33243. * @param alternateCamera defines the camera to use
  33244. */
  33245. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  33246. /** @hidden */
  33247. _allowPostProcessClearColor: boolean;
  33248. private _renderForCamera;
  33249. private _processSubCameras;
  33250. private _checkIntersections;
  33251. /** @hidden */
  33252. _advancePhysicsEngineStep(step: number): void;
  33253. /**
  33254. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33255. */
  33256. getDeterministicFrameTime: () => number;
  33257. /** @hidden */
  33258. _animate(): void;
  33259. /**
  33260. * Render the scene
  33261. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33262. */
  33263. render(updateCameras?: boolean): void;
  33264. /**
  33265. * Freeze all materials
  33266. * A frozen material will not be updatable but should be faster to render
  33267. */
  33268. freezeMaterials(): void;
  33269. /**
  33270. * Unfreeze all materials
  33271. * A frozen material will not be updatable but should be faster to render
  33272. */
  33273. unfreezeMaterials(): void;
  33274. /**
  33275. * Releases all held ressources
  33276. */
  33277. dispose(): void;
  33278. /**
  33279. * Gets if the scene is already disposed
  33280. */
  33281. readonly isDisposed: boolean;
  33282. /**
  33283. * Call this function to reduce memory footprint of the scene.
  33284. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33285. */
  33286. clearCachedVertexData(): void;
  33287. /**
  33288. * This function will remove the local cached buffer data from texture.
  33289. * It will save memory but will prevent the texture from being rebuilt
  33290. */
  33291. cleanCachedTextureBuffer(): void;
  33292. /**
  33293. * Get the world extend vectors with an optional filter
  33294. *
  33295. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33296. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33297. */
  33298. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33299. min: Vector3;
  33300. max: Vector3;
  33301. };
  33302. /**
  33303. * Creates a ray that can be used to pick in the scene
  33304. * @param x defines the x coordinate of the origin (on-screen)
  33305. * @param y defines the y coordinate of the origin (on-screen)
  33306. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33307. * @param camera defines the camera to use for the picking
  33308. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33309. * @returns a Ray
  33310. */
  33311. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33312. /**
  33313. * Creates a ray that can be used to pick in the scene
  33314. * @param x defines the x coordinate of the origin (on-screen)
  33315. * @param y defines the y coordinate of the origin (on-screen)
  33316. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33317. * @param result defines the ray where to store the picking ray
  33318. * @param camera defines the camera to use for the picking
  33319. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33320. * @returns the current scene
  33321. */
  33322. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33323. /**
  33324. * Creates a ray that can be used to pick in the scene
  33325. * @param x defines the x coordinate of the origin (on-screen)
  33326. * @param y defines the y coordinate of the origin (on-screen)
  33327. * @param camera defines the camera to use for the picking
  33328. * @returns a Ray
  33329. */
  33330. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33331. /**
  33332. * Creates a ray that can be used to pick in the scene
  33333. * @param x defines the x coordinate of the origin (on-screen)
  33334. * @param y defines the y coordinate of the origin (on-screen)
  33335. * @param result defines the ray where to store the picking ray
  33336. * @param camera defines the camera to use for the picking
  33337. * @returns the current scene
  33338. */
  33339. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33340. /** Launch a ray to try to pick a mesh in the scene
  33341. * @param x position on screen
  33342. * @param y position on screen
  33343. * @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
  33344. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33345. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33346. * @returns a PickingInfo
  33347. */
  33348. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  33349. /** Use the given ray to pick a mesh in the scene
  33350. * @param ray The ray to use to pick meshes
  33351. * @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
  33352. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33353. * @returns a PickingInfo
  33354. */
  33355. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  33356. /**
  33357. * Launch a ray to try to pick a mesh in the scene
  33358. * @param x X position on screen
  33359. * @param y Y position on screen
  33360. * @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
  33361. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33362. * @returns an array of PickingInfo
  33363. */
  33364. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  33365. /**
  33366. * Launch a ray to try to pick a mesh in the scene
  33367. * @param ray Ray to use
  33368. * @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
  33369. * @returns an array of PickingInfo
  33370. */
  33371. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  33372. /**
  33373. * Force the value of meshUnderPointer
  33374. * @param mesh defines the mesh to use
  33375. */
  33376. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33377. /**
  33378. * Gets the mesh under the pointer
  33379. * @returns a Mesh or null if no mesh is under the pointer
  33380. */
  33381. getPointerOverMesh(): Nullable<AbstractMesh>;
  33382. /** @hidden */
  33383. _rebuildGeometries(): void;
  33384. /** @hidden */
  33385. _rebuildTextures(): void;
  33386. private _getByTags;
  33387. /**
  33388. * Get a list of meshes by tags
  33389. * @param tagsQuery defines the tags query to use
  33390. * @param forEach defines a predicate used to filter results
  33391. * @returns an array of Mesh
  33392. */
  33393. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33394. /**
  33395. * Get a list of cameras by tags
  33396. * @param tagsQuery defines the tags query to use
  33397. * @param forEach defines a predicate used to filter results
  33398. * @returns an array of Camera
  33399. */
  33400. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33401. /**
  33402. * Get a list of lights by tags
  33403. * @param tagsQuery defines the tags query to use
  33404. * @param forEach defines a predicate used to filter results
  33405. * @returns an array of Light
  33406. */
  33407. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33408. /**
  33409. * Get a list of materials by tags
  33410. * @param tagsQuery defines the tags query to use
  33411. * @param forEach defines a predicate used to filter results
  33412. * @returns an array of Material
  33413. */
  33414. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33415. /**
  33416. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33417. * This allowed control for front to back rendering or reversly depending of the special needs.
  33418. *
  33419. * @param renderingGroupId The rendering group id corresponding to its index
  33420. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33421. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33422. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33423. */
  33424. 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;
  33425. /**
  33426. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33427. *
  33428. * @param renderingGroupId The rendering group id corresponding to its index
  33429. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33430. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33431. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33432. */
  33433. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33434. /**
  33435. * Gets the current auto clear configuration for one rendering group of the rendering
  33436. * manager.
  33437. * @param index the rendering group index to get the information for
  33438. * @returns The auto clear setup for the requested rendering group
  33439. */
  33440. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33441. private _blockMaterialDirtyMechanism;
  33442. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33443. blockMaterialDirtyMechanism: boolean;
  33444. /**
  33445. * Will flag all materials as dirty to trigger new shader compilation
  33446. * @param flag defines the flag used to specify which material part must be marked as dirty
  33447. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33448. */
  33449. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33450. /** @hidden */
  33451. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  33452. /** @hidden */
  33453. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33454. }
  33455. }
  33456. declare module "babylonjs/assetContainer" {
  33457. import { AbstractScene } from "babylonjs/abstractScene";
  33458. import { Scene } from "babylonjs/scene";
  33459. import { Mesh } from "babylonjs/Meshes/mesh";
  33460. /**
  33461. * Set of assets to keep when moving a scene into an asset container.
  33462. */
  33463. export class KeepAssets extends AbstractScene {
  33464. }
  33465. /**
  33466. * Container with a set of assets that can be added or removed from a scene.
  33467. */
  33468. export class AssetContainer extends AbstractScene {
  33469. /**
  33470. * The scene the AssetContainer belongs to.
  33471. */
  33472. scene: Scene;
  33473. /**
  33474. * Instantiates an AssetContainer.
  33475. * @param scene The scene the AssetContainer belongs to.
  33476. */
  33477. constructor(scene: Scene);
  33478. /**
  33479. * Adds all the assets from the container to the scene.
  33480. */
  33481. addAllToScene(): void;
  33482. /**
  33483. * Removes all the assets in the container from the scene
  33484. */
  33485. removeAllFromScene(): void;
  33486. /**
  33487. * Disposes all the assets in the container
  33488. */
  33489. dispose(): void;
  33490. private _moveAssets;
  33491. /**
  33492. * Removes all the assets contained in the scene and adds them to the container.
  33493. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33494. */
  33495. moveAllFromScene(keepAssets?: KeepAssets): void;
  33496. /**
  33497. * 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.
  33498. * @returns the root mesh
  33499. */
  33500. createRootMesh(): Mesh;
  33501. }
  33502. }
  33503. declare module "babylonjs/abstractScene" {
  33504. import { Scene } from "babylonjs/scene";
  33505. import { Nullable } from "babylonjs/types";
  33506. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33507. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33508. import { Geometry } from "babylonjs/Meshes/geometry";
  33509. import { Skeleton } from "babylonjs/Bones/skeleton";
  33510. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33511. import { AssetContainer } from "babylonjs/assetContainer";
  33512. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33513. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33514. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33515. import { Material } from "babylonjs/Materials/material";
  33516. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33517. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33518. import { Camera } from "babylonjs/Cameras/camera";
  33519. import { Light } from "babylonjs/Lights/light";
  33520. import { Node } from "babylonjs/node";
  33521. import { Animation } from "babylonjs/Animations/animation";
  33522. /**
  33523. * Defines how the parser contract is defined.
  33524. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33525. */
  33526. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33527. /**
  33528. * Defines how the individual parser contract is defined.
  33529. * These parser can parse an individual asset
  33530. */
  33531. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33532. /**
  33533. * Base class of the scene acting as a container for the different elements composing a scene.
  33534. * This class is dynamically extended by the different components of the scene increasing
  33535. * flexibility and reducing coupling
  33536. */
  33537. export abstract class AbstractScene {
  33538. /**
  33539. * Stores the list of available parsers in the application.
  33540. */
  33541. private static _BabylonFileParsers;
  33542. /**
  33543. * Stores the list of available individual parsers in the application.
  33544. */
  33545. private static _IndividualBabylonFileParsers;
  33546. /**
  33547. * Adds a parser in the list of available ones
  33548. * @param name Defines the name of the parser
  33549. * @param parser Defines the parser to add
  33550. */
  33551. static AddParser(name: string, parser: BabylonFileParser): void;
  33552. /**
  33553. * Gets a general parser from the list of avaialble ones
  33554. * @param name Defines the name of the parser
  33555. * @returns the requested parser or null
  33556. */
  33557. static GetParser(name: string): Nullable<BabylonFileParser>;
  33558. /**
  33559. * Adds n individual parser in the list of available ones
  33560. * @param name Defines the name of the parser
  33561. * @param parser Defines the parser to add
  33562. */
  33563. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33564. /**
  33565. * Gets an individual parser from the list of avaialble ones
  33566. * @param name Defines the name of the parser
  33567. * @returns the requested parser or null
  33568. */
  33569. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33570. /**
  33571. * Parser json data and populate both a scene and its associated container object
  33572. * @param jsonData Defines the data to parse
  33573. * @param scene Defines the scene to parse the data for
  33574. * @param container Defines the container attached to the parsing sequence
  33575. * @param rootUrl Defines the root url of the data
  33576. */
  33577. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33578. /**
  33579. * Gets the list of root nodes (ie. nodes with no parent)
  33580. */
  33581. rootNodes: Node[];
  33582. /** All of the cameras added to this scene
  33583. * @see http://doc.babylonjs.com/babylon101/cameras
  33584. */
  33585. cameras: Camera[];
  33586. /**
  33587. * All of the lights added to this scene
  33588. * @see http://doc.babylonjs.com/babylon101/lights
  33589. */
  33590. lights: Light[];
  33591. /**
  33592. * All of the (abstract) meshes added to this scene
  33593. */
  33594. meshes: AbstractMesh[];
  33595. /**
  33596. * The list of skeletons added to the scene
  33597. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33598. */
  33599. skeletons: Skeleton[];
  33600. /**
  33601. * All of the particle systems added to this scene
  33602. * @see http://doc.babylonjs.com/babylon101/particles
  33603. */
  33604. particleSystems: IParticleSystem[];
  33605. /**
  33606. * Gets a list of Animations associated with the scene
  33607. */
  33608. animations: Animation[];
  33609. /**
  33610. * All of the animation groups added to this scene
  33611. * @see http://doc.babylonjs.com/how_to/group
  33612. */
  33613. animationGroups: AnimationGroup[];
  33614. /**
  33615. * All of the multi-materials added to this scene
  33616. * @see http://doc.babylonjs.com/how_to/multi_materials
  33617. */
  33618. multiMaterials: MultiMaterial[];
  33619. /**
  33620. * All of the materials added to this scene
  33621. * In the context of a Scene, it is not supposed to be modified manually.
  33622. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33623. * Note also that the order of the Material wihin the array is not significant and might change.
  33624. * @see http://doc.babylonjs.com/babylon101/materials
  33625. */
  33626. materials: Material[];
  33627. /**
  33628. * The list of morph target managers added to the scene
  33629. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33630. */
  33631. morphTargetManagers: MorphTargetManager[];
  33632. /**
  33633. * The list of geometries used in the scene.
  33634. */
  33635. geometries: Geometry[];
  33636. /**
  33637. * All of the tranform nodes added to this scene
  33638. * In the context of a Scene, it is not supposed to be modified manually.
  33639. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33640. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33641. * @see http://doc.babylonjs.com/how_to/transformnode
  33642. */
  33643. transformNodes: TransformNode[];
  33644. /**
  33645. * ActionManagers available on the scene.
  33646. */
  33647. actionManagers: AbstractActionManager[];
  33648. /**
  33649. * Textures to keep.
  33650. */
  33651. textures: BaseTexture[];
  33652. }
  33653. }
  33654. declare module "babylonjs/Audio/sound" {
  33655. import { Observable } from "babylonjs/Misc/observable";
  33656. import { Vector3 } from "babylonjs/Maths/math";
  33657. import { Nullable } from "babylonjs/types";
  33658. import { Scene } from "babylonjs/scene";
  33659. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33660. /**
  33661. * Defines a sound that can be played in the application.
  33662. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33663. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33664. */
  33665. export class Sound {
  33666. /**
  33667. * The name of the sound in the scene.
  33668. */
  33669. name: string;
  33670. /**
  33671. * Does the sound autoplay once loaded.
  33672. */
  33673. autoplay: boolean;
  33674. /**
  33675. * Does the sound loop after it finishes playing once.
  33676. */
  33677. loop: boolean;
  33678. /**
  33679. * Does the sound use a custom attenuation curve to simulate the falloff
  33680. * happening when the source gets further away from the camera.
  33681. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33682. */
  33683. useCustomAttenuation: boolean;
  33684. /**
  33685. * The sound track id this sound belongs to.
  33686. */
  33687. soundTrackId: number;
  33688. /**
  33689. * Is this sound currently played.
  33690. */
  33691. isPlaying: boolean;
  33692. /**
  33693. * Is this sound currently paused.
  33694. */
  33695. isPaused: boolean;
  33696. /**
  33697. * Does this sound enables spatial sound.
  33698. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33699. */
  33700. spatialSound: boolean;
  33701. /**
  33702. * Define the reference distance the sound should be heard perfectly.
  33703. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33704. */
  33705. refDistance: number;
  33706. /**
  33707. * Define the roll off factor of spatial sounds.
  33708. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33709. */
  33710. rolloffFactor: number;
  33711. /**
  33712. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33713. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33714. */
  33715. maxDistance: number;
  33716. /**
  33717. * Define the distance attenuation model the sound will follow.
  33718. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33719. */
  33720. distanceModel: string;
  33721. /**
  33722. * @hidden
  33723. * Back Compat
  33724. **/
  33725. onended: () => any;
  33726. /**
  33727. * Observable event when the current playing sound finishes.
  33728. */
  33729. onEndedObservable: Observable<Sound>;
  33730. private _panningModel;
  33731. private _playbackRate;
  33732. private _streaming;
  33733. private _startTime;
  33734. private _startOffset;
  33735. private _position;
  33736. /** @hidden */
  33737. _positionInEmitterSpace: boolean;
  33738. private _localDirection;
  33739. private _volume;
  33740. private _isReadyToPlay;
  33741. private _isDirectional;
  33742. private _readyToPlayCallback;
  33743. private _audioBuffer;
  33744. private _soundSource;
  33745. private _streamingSource;
  33746. private _soundPanner;
  33747. private _soundGain;
  33748. private _inputAudioNode;
  33749. private _outputAudioNode;
  33750. private _coneInnerAngle;
  33751. private _coneOuterAngle;
  33752. private _coneOuterGain;
  33753. private _scene;
  33754. private _connectedTransformNode;
  33755. private _customAttenuationFunction;
  33756. private _registerFunc;
  33757. private _isOutputConnected;
  33758. private _htmlAudioElement;
  33759. private _urlType;
  33760. /** @hidden */
  33761. static _SceneComponentInitialization: (scene: Scene) => void;
  33762. /**
  33763. * Create a sound and attach it to a scene
  33764. * @param name Name of your sound
  33765. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  33766. * @param scene defines the scene the sound belongs to
  33767. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  33768. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  33769. */
  33770. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  33771. /**
  33772. * Release the sound and its associated resources
  33773. */
  33774. dispose(): void;
  33775. /**
  33776. * Gets if the sounds is ready to be played or not.
  33777. * @returns true if ready, otherwise false
  33778. */
  33779. isReady(): boolean;
  33780. private _soundLoaded;
  33781. /**
  33782. * Sets the data of the sound from an audiobuffer
  33783. * @param audioBuffer The audioBuffer containing the data
  33784. */
  33785. setAudioBuffer(audioBuffer: AudioBuffer): void;
  33786. /**
  33787. * Updates the current sounds options such as maxdistance, loop...
  33788. * @param options A JSON object containing values named as the object properties
  33789. */
  33790. updateOptions(options: any): void;
  33791. private _createSpatialParameters;
  33792. private _updateSpatialParameters;
  33793. /**
  33794. * Switch the panning model to HRTF:
  33795. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33796. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33797. */
  33798. switchPanningModelToHRTF(): void;
  33799. /**
  33800. * Switch the panning model to Equal Power:
  33801. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33802. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33803. */
  33804. switchPanningModelToEqualPower(): void;
  33805. private _switchPanningModel;
  33806. /**
  33807. * Connect this sound to a sound track audio node like gain...
  33808. * @param soundTrackAudioNode the sound track audio node to connect to
  33809. */
  33810. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  33811. /**
  33812. * Transform this sound into a directional source
  33813. * @param coneInnerAngle Size of the inner cone in degree
  33814. * @param coneOuterAngle Size of the outer cone in degree
  33815. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  33816. */
  33817. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  33818. /**
  33819. * Gets or sets the inner angle for the directional cone.
  33820. */
  33821. /**
  33822. * Gets or sets the inner angle for the directional cone.
  33823. */
  33824. directionalConeInnerAngle: number;
  33825. /**
  33826. * Gets or sets the outer angle for the directional cone.
  33827. */
  33828. /**
  33829. * Gets or sets the outer angle for the directional cone.
  33830. */
  33831. directionalConeOuterAngle: number;
  33832. /**
  33833. * Sets the position of the emitter if spatial sound is enabled
  33834. * @param newPosition Defines the new posisiton
  33835. */
  33836. setPosition(newPosition: Vector3): void;
  33837. /**
  33838. * Sets the local direction of the emitter if spatial sound is enabled
  33839. * @param newLocalDirection Defines the new local direction
  33840. */
  33841. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  33842. private _updateDirection;
  33843. /** @hidden */
  33844. updateDistanceFromListener(): void;
  33845. /**
  33846. * Sets a new custom attenuation function for the sound.
  33847. * @param callback Defines the function used for the attenuation
  33848. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33849. */
  33850. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  33851. /**
  33852. * Play the sound
  33853. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  33854. * @param offset (optional) Start the sound setting it at a specific time
  33855. */
  33856. play(time?: number, offset?: number): void;
  33857. private _onended;
  33858. /**
  33859. * Stop the sound
  33860. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  33861. */
  33862. stop(time?: number): void;
  33863. /**
  33864. * Put the sound in pause
  33865. */
  33866. pause(): void;
  33867. /**
  33868. * Sets a dedicated volume for this sounds
  33869. * @param newVolume Define the new volume of the sound
  33870. * @param time Define in how long the sound should be at this value
  33871. */
  33872. setVolume(newVolume: number, time?: number): void;
  33873. /**
  33874. * Set the sound play back rate
  33875. * @param newPlaybackRate Define the playback rate the sound should be played at
  33876. */
  33877. setPlaybackRate(newPlaybackRate: number): void;
  33878. /**
  33879. * Gets the volume of the sound.
  33880. * @returns the volume of the sound
  33881. */
  33882. getVolume(): number;
  33883. /**
  33884. * Attach the sound to a dedicated mesh
  33885. * @param transformNode The transform node to connect the sound with
  33886. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33887. */
  33888. attachToMesh(transformNode: TransformNode): void;
  33889. /**
  33890. * Detach the sound from the previously attached mesh
  33891. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33892. */
  33893. detachFromMesh(): void;
  33894. private _onRegisterAfterWorldMatrixUpdate;
  33895. /**
  33896. * Clone the current sound in the scene.
  33897. * @returns the new sound clone
  33898. */
  33899. clone(): Nullable<Sound>;
  33900. /**
  33901. * Gets the current underlying audio buffer containing the data
  33902. * @returns the audio buffer
  33903. */
  33904. getAudioBuffer(): Nullable<AudioBuffer>;
  33905. /**
  33906. * Serializes the Sound in a JSON representation
  33907. * @returns the JSON representation of the sound
  33908. */
  33909. serialize(): any;
  33910. /**
  33911. * Parse a JSON representation of a sound to innstantiate in a given scene
  33912. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  33913. * @param scene Define the scene the new parsed sound should be created in
  33914. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  33915. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  33916. * @returns the newly parsed sound
  33917. */
  33918. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  33919. }
  33920. }
  33921. declare module "babylonjs/Actions/directAudioActions" {
  33922. import { Action } from "babylonjs/Actions/action";
  33923. import { Condition } from "babylonjs/Actions/condition";
  33924. import { Sound } from "babylonjs/Audio/sound";
  33925. /**
  33926. * This defines an action helpful to play a defined sound on a triggered action.
  33927. */
  33928. export class PlaySoundAction extends Action {
  33929. private _sound;
  33930. /**
  33931. * Instantiate the action
  33932. * @param triggerOptions defines the trigger options
  33933. * @param sound defines the sound to play
  33934. * @param condition defines the trigger related conditions
  33935. */
  33936. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33937. /** @hidden */
  33938. _prepare(): void;
  33939. /**
  33940. * Execute the action and play the sound.
  33941. */
  33942. execute(): void;
  33943. /**
  33944. * Serializes the actions and its related information.
  33945. * @param parent defines the object to serialize in
  33946. * @returns the serialized object
  33947. */
  33948. serialize(parent: any): any;
  33949. }
  33950. /**
  33951. * This defines an action helpful to stop a defined sound on a triggered action.
  33952. */
  33953. export class StopSoundAction extends Action {
  33954. private _sound;
  33955. /**
  33956. * Instantiate the action
  33957. * @param triggerOptions defines the trigger options
  33958. * @param sound defines the sound to stop
  33959. * @param condition defines the trigger related conditions
  33960. */
  33961. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33962. /** @hidden */
  33963. _prepare(): void;
  33964. /**
  33965. * Execute the action and stop the sound.
  33966. */
  33967. execute(): void;
  33968. /**
  33969. * Serializes the actions and its related information.
  33970. * @param parent defines the object to serialize in
  33971. * @returns the serialized object
  33972. */
  33973. serialize(parent: any): any;
  33974. }
  33975. }
  33976. declare module "babylonjs/Actions/interpolateValueAction" {
  33977. import { Action } from "babylonjs/Actions/action";
  33978. import { Condition } from "babylonjs/Actions/condition";
  33979. import { Observable } from "babylonjs/Misc/observable";
  33980. /**
  33981. * This defines an action responsible to change the value of a property
  33982. * by interpolating between its current value and the newly set one once triggered.
  33983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33984. */
  33985. export class InterpolateValueAction extends Action {
  33986. /**
  33987. * Defines the path of the property where the value should be interpolated
  33988. */
  33989. propertyPath: string;
  33990. /**
  33991. * Defines the target value at the end of the interpolation.
  33992. */
  33993. value: any;
  33994. /**
  33995. * Defines the time it will take for the property to interpolate to the value.
  33996. */
  33997. duration: number;
  33998. /**
  33999. * Defines if the other scene animations should be stopped when the action has been triggered
  34000. */
  34001. stopOtherAnimations?: boolean;
  34002. /**
  34003. * Defines a callback raised once the interpolation animation has been done.
  34004. */
  34005. onInterpolationDone?: () => void;
  34006. /**
  34007. * Observable triggered once the interpolation animation has been done.
  34008. */
  34009. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34010. private _target;
  34011. private _effectiveTarget;
  34012. private _property;
  34013. /**
  34014. * Instantiate the action
  34015. * @param triggerOptions defines the trigger options
  34016. * @param target defines the object containing the value to interpolate
  34017. * @param propertyPath defines the path to the property in the target object
  34018. * @param value defines the target value at the end of the interpolation
  34019. * @param duration deines the time it will take for the property to interpolate to the value.
  34020. * @param condition defines the trigger related conditions
  34021. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34022. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34023. */
  34024. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34025. /** @hidden */
  34026. _prepare(): void;
  34027. /**
  34028. * Execute the action starts the value interpolation.
  34029. */
  34030. execute(): void;
  34031. /**
  34032. * Serializes the actions and its related information.
  34033. * @param parent defines the object to serialize in
  34034. * @returns the serialized object
  34035. */
  34036. serialize(parent: any): any;
  34037. }
  34038. }
  34039. declare module "babylonjs/Actions/index" {
  34040. export * from "babylonjs/Actions/action";
  34041. export * from "babylonjs/Actions/actionEvent";
  34042. export * from "babylonjs/Actions/actionManager";
  34043. export * from "babylonjs/Actions/condition";
  34044. export * from "babylonjs/Actions/directActions";
  34045. export * from "babylonjs/Actions/directAudioActions";
  34046. export * from "babylonjs/Actions/interpolateValueAction";
  34047. }
  34048. declare module "babylonjs/Animations/index" {
  34049. export * from "babylonjs/Animations/animatable";
  34050. export * from "babylonjs/Animations/animation";
  34051. export * from "babylonjs/Animations/animationGroup";
  34052. export * from "babylonjs/Animations/animationPropertiesOverride";
  34053. export * from "babylonjs/Animations/easing";
  34054. export * from "babylonjs/Animations/runtimeAnimation";
  34055. export * from "babylonjs/Animations/animationEvent";
  34056. export * from "babylonjs/Animations/animationGroup";
  34057. export * from "babylonjs/Animations/animationKey";
  34058. export * from "babylonjs/Animations/animationRange";
  34059. }
  34060. declare module "babylonjs/Audio/soundTrack" {
  34061. import { Sound } from "babylonjs/Audio/sound";
  34062. import { Analyser } from "babylonjs/Audio/analyser";
  34063. import { Scene } from "babylonjs/scene";
  34064. /**
  34065. * Options allowed during the creation of a sound track.
  34066. */
  34067. export interface ISoundTrackOptions {
  34068. /**
  34069. * The volume the sound track should take during creation
  34070. */
  34071. volume?: number;
  34072. /**
  34073. * Define if the sound track is the main sound track of the scene
  34074. */
  34075. mainTrack?: boolean;
  34076. }
  34077. /**
  34078. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34079. * It will be also used in a future release to apply effects on a specific track.
  34080. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34081. */
  34082. export class SoundTrack {
  34083. /**
  34084. * The unique identifier of the sound track in the scene.
  34085. */
  34086. id: number;
  34087. /**
  34088. * The list of sounds included in the sound track.
  34089. */
  34090. soundCollection: Array<Sound>;
  34091. private _outputAudioNode;
  34092. private _scene;
  34093. private _isMainTrack;
  34094. private _connectedAnalyser;
  34095. private _options;
  34096. private _isInitialized;
  34097. /**
  34098. * Creates a new sound track.
  34099. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34100. * @param scene Define the scene the sound track belongs to
  34101. * @param options
  34102. */
  34103. constructor(scene: Scene, options?: ISoundTrackOptions);
  34104. private _initializeSoundTrackAudioGraph;
  34105. /**
  34106. * Release the sound track and its associated resources
  34107. */
  34108. dispose(): void;
  34109. /**
  34110. * Adds a sound to this sound track
  34111. * @param sound define the cound to add
  34112. * @ignoreNaming
  34113. */
  34114. AddSound(sound: Sound): void;
  34115. /**
  34116. * Removes a sound to this sound track
  34117. * @param sound define the cound to remove
  34118. * @ignoreNaming
  34119. */
  34120. RemoveSound(sound: Sound): void;
  34121. /**
  34122. * Set a global volume for the full sound track.
  34123. * @param newVolume Define the new volume of the sound track
  34124. */
  34125. setVolume(newVolume: number): void;
  34126. /**
  34127. * Switch the panning model to HRTF:
  34128. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34129. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34130. */
  34131. switchPanningModelToHRTF(): void;
  34132. /**
  34133. * Switch the panning model to Equal Power:
  34134. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34135. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34136. */
  34137. switchPanningModelToEqualPower(): void;
  34138. /**
  34139. * Connect the sound track to an audio analyser allowing some amazing
  34140. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34141. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34142. * @param analyser The analyser to connect to the engine
  34143. */
  34144. connectToAnalyser(analyser: Analyser): void;
  34145. }
  34146. }
  34147. declare module "babylonjs/Audio/audioSceneComponent" {
  34148. import { Sound } from "babylonjs/Audio/sound";
  34149. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  34150. import { Nullable } from "babylonjs/types";
  34151. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  34152. import { Scene } from "babylonjs/scene";
  34153. import { AbstractScene } from "babylonjs/abstractScene";
  34154. module "babylonjs/abstractScene" {
  34155. interface AbstractScene {
  34156. /**
  34157. * The list of sounds used in the scene.
  34158. */
  34159. sounds: Nullable<Array<Sound>>;
  34160. }
  34161. }
  34162. module "babylonjs/scene" {
  34163. interface Scene {
  34164. /**
  34165. * @hidden
  34166. * Backing field
  34167. */
  34168. _mainSoundTrack: SoundTrack;
  34169. /**
  34170. * The main sound track played by the scene.
  34171. * It cotains your primary collection of sounds.
  34172. */
  34173. mainSoundTrack: SoundTrack;
  34174. /**
  34175. * The list of sound tracks added to the scene
  34176. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34177. */
  34178. soundTracks: Nullable<Array<SoundTrack>>;
  34179. /**
  34180. * Gets a sound using a given name
  34181. * @param name defines the name to search for
  34182. * @return the found sound or null if not found at all.
  34183. */
  34184. getSoundByName(name: string): Nullable<Sound>;
  34185. /**
  34186. * Gets or sets if audio support is enabled
  34187. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34188. */
  34189. audioEnabled: boolean;
  34190. /**
  34191. * Gets or sets if audio will be output to headphones
  34192. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34193. */
  34194. headphone: boolean;
  34195. }
  34196. }
  34197. /**
  34198. * Defines the sound scene component responsible to manage any sounds
  34199. * in a given scene.
  34200. */
  34201. export class AudioSceneComponent implements ISceneSerializableComponent {
  34202. /**
  34203. * The component name helpfull to identify the component in the list of scene components.
  34204. */
  34205. readonly name: string;
  34206. /**
  34207. * The scene the component belongs to.
  34208. */
  34209. scene: Scene;
  34210. private _audioEnabled;
  34211. /**
  34212. * Gets whether audio is enabled or not.
  34213. * Please use related enable/disable method to switch state.
  34214. */
  34215. readonly audioEnabled: boolean;
  34216. private _headphone;
  34217. /**
  34218. * Gets whether audio is outputing to headphone or not.
  34219. * Please use the according Switch methods to change output.
  34220. */
  34221. readonly headphone: boolean;
  34222. /**
  34223. * Creates a new instance of the component for the given scene
  34224. * @param scene Defines the scene to register the component in
  34225. */
  34226. constructor(scene: Scene);
  34227. /**
  34228. * Registers the component in a given scene
  34229. */
  34230. register(): void;
  34231. /**
  34232. * Rebuilds the elements related to this component in case of
  34233. * context lost for instance.
  34234. */
  34235. rebuild(): void;
  34236. /**
  34237. * Serializes the component data to the specified json object
  34238. * @param serializationObject The object to serialize to
  34239. */
  34240. serialize(serializationObject: any): void;
  34241. /**
  34242. * Adds all the element from the container to the scene
  34243. * @param container the container holding the elements
  34244. */
  34245. addFromContainer(container: AbstractScene): void;
  34246. /**
  34247. * Removes all the elements in the container from the scene
  34248. * @param container contains the elements to remove
  34249. */
  34250. removeFromContainer(container: AbstractScene): void;
  34251. /**
  34252. * Disposes the component and the associated ressources.
  34253. */
  34254. dispose(): void;
  34255. /**
  34256. * Disables audio in the associated scene.
  34257. */
  34258. disableAudio(): void;
  34259. /**
  34260. * Enables audio in the associated scene.
  34261. */
  34262. enableAudio(): void;
  34263. /**
  34264. * Switch audio to headphone output.
  34265. */
  34266. switchAudioModeForHeadphones(): void;
  34267. /**
  34268. * Switch audio to normal speakers.
  34269. */
  34270. switchAudioModeForNormalSpeakers(): void;
  34271. private _afterRender;
  34272. }
  34273. }
  34274. declare module "babylonjs/Audio/weightedsound" {
  34275. import { Sound } from "babylonjs/Audio/sound";
  34276. /**
  34277. * Wraps one or more Sound objects and selects one with random weight for playback.
  34278. */
  34279. export class WeightedSound {
  34280. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34281. loop: boolean;
  34282. private _coneInnerAngle;
  34283. private _coneOuterAngle;
  34284. private _volume;
  34285. /** A Sound is currently playing. */
  34286. isPlaying: boolean;
  34287. /** A Sound is currently paused. */
  34288. isPaused: boolean;
  34289. private _sounds;
  34290. private _weights;
  34291. private _currentIndex?;
  34292. /**
  34293. * Creates a new WeightedSound from the list of sounds given.
  34294. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34295. * @param sounds Array of Sounds that will be selected from.
  34296. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34297. */
  34298. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34299. /**
  34300. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34301. */
  34302. /**
  34303. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34304. */
  34305. directionalConeInnerAngle: number;
  34306. /**
  34307. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34308. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34309. */
  34310. /**
  34311. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34312. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34313. */
  34314. directionalConeOuterAngle: number;
  34315. /**
  34316. * Playback volume.
  34317. */
  34318. /**
  34319. * Playback volume.
  34320. */
  34321. volume: number;
  34322. private _onended;
  34323. /**
  34324. * Suspend playback
  34325. */
  34326. pause(): void;
  34327. /**
  34328. * Stop playback
  34329. */
  34330. stop(): void;
  34331. /**
  34332. * Start playback.
  34333. * @param startOffset Position the clip head at a specific time in seconds.
  34334. */
  34335. play(startOffset?: number): void;
  34336. }
  34337. }
  34338. declare module "babylonjs/Audio/index" {
  34339. export * from "babylonjs/Audio/analyser";
  34340. export * from "babylonjs/Audio/audioEngine";
  34341. export * from "babylonjs/Audio/audioSceneComponent";
  34342. export * from "babylonjs/Audio/sound";
  34343. export * from "babylonjs/Audio/soundTrack";
  34344. export * from "babylonjs/Audio/weightedsound";
  34345. }
  34346. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  34347. import { Behavior } from "babylonjs/Behaviors/behavior";
  34348. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34349. import { BackEase } from "babylonjs/Animations/easing";
  34350. /**
  34351. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34352. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34353. */
  34354. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34355. /**
  34356. * Gets the name of the behavior.
  34357. */
  34358. readonly name: string;
  34359. /**
  34360. * The easing function used by animations
  34361. */
  34362. static EasingFunction: BackEase;
  34363. /**
  34364. * The easing mode used by animations
  34365. */
  34366. static EasingMode: number;
  34367. /**
  34368. * The duration of the animation, in milliseconds
  34369. */
  34370. transitionDuration: number;
  34371. /**
  34372. * Length of the distance animated by the transition when lower radius is reached
  34373. */
  34374. lowerRadiusTransitionRange: number;
  34375. /**
  34376. * Length of the distance animated by the transition when upper radius is reached
  34377. */
  34378. upperRadiusTransitionRange: number;
  34379. private _autoTransitionRange;
  34380. /**
  34381. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34382. */
  34383. /**
  34384. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34385. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34386. */
  34387. autoTransitionRange: boolean;
  34388. private _attachedCamera;
  34389. private _onAfterCheckInputsObserver;
  34390. private _onMeshTargetChangedObserver;
  34391. /**
  34392. * Initializes the behavior.
  34393. */
  34394. init(): void;
  34395. /**
  34396. * Attaches the behavior to its arc rotate camera.
  34397. * @param camera Defines the camera to attach the behavior to
  34398. */
  34399. attach(camera: ArcRotateCamera): void;
  34400. /**
  34401. * Detaches the behavior from its current arc rotate camera.
  34402. */
  34403. detach(): void;
  34404. private _radiusIsAnimating;
  34405. private _radiusBounceTransition;
  34406. private _animatables;
  34407. private _cachedWheelPrecision;
  34408. /**
  34409. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34410. * @param radiusLimit The limit to check against.
  34411. * @return Bool to indicate if at limit.
  34412. */
  34413. private _isRadiusAtLimit;
  34414. /**
  34415. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34416. * @param radiusDelta The delta by which to animate to. Can be negative.
  34417. */
  34418. private _applyBoundRadiusAnimation;
  34419. /**
  34420. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34421. */
  34422. protected _clearAnimationLocks(): void;
  34423. /**
  34424. * Stops and removes all animations that have been applied to the camera
  34425. */
  34426. stopAllAnimations(): void;
  34427. }
  34428. }
  34429. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  34430. import { Behavior } from "babylonjs/Behaviors/behavior";
  34431. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34432. import { ExponentialEase } from "babylonjs/Animations/easing";
  34433. import { Nullable } from "babylonjs/types";
  34434. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34435. import { Vector3 } from "babylonjs/Maths/math";
  34436. /**
  34437. * 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.
  34438. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34439. */
  34440. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34441. /**
  34442. * Gets the name of the behavior.
  34443. */
  34444. readonly name: string;
  34445. private _mode;
  34446. private _radiusScale;
  34447. private _positionScale;
  34448. private _defaultElevation;
  34449. private _elevationReturnTime;
  34450. private _elevationReturnWaitTime;
  34451. private _zoomStopsAnimation;
  34452. private _framingTime;
  34453. /**
  34454. * The easing function used by animations
  34455. */
  34456. static EasingFunction: ExponentialEase;
  34457. /**
  34458. * The easing mode used by animations
  34459. */
  34460. static EasingMode: number;
  34461. /**
  34462. * Sets the current mode used by the behavior
  34463. */
  34464. /**
  34465. * Gets current mode used by the behavior.
  34466. */
  34467. mode: number;
  34468. /**
  34469. * Sets the scale applied to the radius (1 by default)
  34470. */
  34471. /**
  34472. * Gets the scale applied to the radius
  34473. */
  34474. radiusScale: number;
  34475. /**
  34476. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34477. */
  34478. /**
  34479. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34480. */
  34481. positionScale: number;
  34482. /**
  34483. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34484. * behaviour is triggered, in radians.
  34485. */
  34486. /**
  34487. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34488. * behaviour is triggered, in radians.
  34489. */
  34490. defaultElevation: number;
  34491. /**
  34492. * Sets the time (in milliseconds) taken to return to the default beta position.
  34493. * Negative value indicates camera should not return to default.
  34494. */
  34495. /**
  34496. * Gets the time (in milliseconds) taken to return to the default beta position.
  34497. * Negative value indicates camera should not return to default.
  34498. */
  34499. elevationReturnTime: number;
  34500. /**
  34501. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34502. */
  34503. /**
  34504. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34505. */
  34506. elevationReturnWaitTime: number;
  34507. /**
  34508. * Sets the flag that indicates if user zooming should stop animation.
  34509. */
  34510. /**
  34511. * Gets the flag that indicates if user zooming should stop animation.
  34512. */
  34513. zoomStopsAnimation: boolean;
  34514. /**
  34515. * Sets the transition time when framing the mesh, in milliseconds
  34516. */
  34517. /**
  34518. * Gets the transition time when framing the mesh, in milliseconds
  34519. */
  34520. framingTime: number;
  34521. /**
  34522. * Define if the behavior should automatically change the configured
  34523. * camera limits and sensibilities.
  34524. */
  34525. autoCorrectCameraLimitsAndSensibility: boolean;
  34526. private _onPrePointerObservableObserver;
  34527. private _onAfterCheckInputsObserver;
  34528. private _onMeshTargetChangedObserver;
  34529. private _attachedCamera;
  34530. private _isPointerDown;
  34531. private _lastInteractionTime;
  34532. /**
  34533. * Initializes the behavior.
  34534. */
  34535. init(): void;
  34536. /**
  34537. * Attaches the behavior to its arc rotate camera.
  34538. * @param camera Defines the camera to attach the behavior to
  34539. */
  34540. attach(camera: ArcRotateCamera): void;
  34541. /**
  34542. * Detaches the behavior from its current arc rotate camera.
  34543. */
  34544. detach(): void;
  34545. private _animatables;
  34546. private _betaIsAnimating;
  34547. private _betaTransition;
  34548. private _radiusTransition;
  34549. private _vectorTransition;
  34550. /**
  34551. * Targets the given mesh and updates zoom level accordingly.
  34552. * @param mesh The mesh to target.
  34553. * @param radius Optional. If a cached radius position already exists, overrides default.
  34554. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34555. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34556. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34557. */
  34558. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34559. /**
  34560. * Targets the given mesh with its children and updates zoom level accordingly.
  34561. * @param mesh The mesh to target.
  34562. * @param radius Optional. If a cached radius position already exists, overrides default.
  34563. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34564. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34565. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34566. */
  34567. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34568. /**
  34569. * Targets the given meshes with their children and updates zoom level accordingly.
  34570. * @param meshes The mesh to target.
  34571. * @param radius Optional. If a cached radius position already exists, overrides default.
  34572. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34573. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34574. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34575. */
  34576. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34577. /**
  34578. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34579. * @param minimumWorld Determines the smaller position of the bounding box extend
  34580. * @param maximumWorld Determines the bigger position of the bounding box extend
  34581. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34582. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34583. */
  34584. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34585. /**
  34586. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34587. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34588. * frustum width.
  34589. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34590. * to fully enclose the mesh in the viewing frustum.
  34591. */
  34592. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34593. /**
  34594. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34595. * is automatically returned to its default position (expected to be above ground plane).
  34596. */
  34597. private _maintainCameraAboveGround;
  34598. /**
  34599. * Returns the frustum slope based on the canvas ratio and camera FOV
  34600. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34601. */
  34602. private _getFrustumSlope;
  34603. /**
  34604. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34605. */
  34606. private _clearAnimationLocks;
  34607. /**
  34608. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34609. */
  34610. private _applyUserInteraction;
  34611. /**
  34612. * Stops and removes all animations that have been applied to the camera
  34613. */
  34614. stopAllAnimations(): void;
  34615. /**
  34616. * Gets a value indicating if the user is moving the camera
  34617. */
  34618. readonly isUserIsMoving: boolean;
  34619. /**
  34620. * The camera can move all the way towards the mesh.
  34621. */
  34622. static IgnoreBoundsSizeMode: number;
  34623. /**
  34624. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34625. */
  34626. static FitFrustumSidesMode: number;
  34627. }
  34628. }
  34629. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  34630. import { Nullable } from "babylonjs/types";
  34631. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34632. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34633. /**
  34634. * Manage the pointers inputs to control an arc rotate camera.
  34635. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34636. */
  34637. export class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  34638. /**
  34639. * Defines the camera the input is attached to.
  34640. */
  34641. camera: ArcRotateCamera;
  34642. /**
  34643. * Defines the buttons associated with the input to handle camera move.
  34644. */
  34645. buttons: number[];
  34646. /**
  34647. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  34648. */
  34649. angularSensibilityX: number;
  34650. /**
  34651. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  34652. */
  34653. angularSensibilityY: number;
  34654. /**
  34655. * Defines the pointer pinch precision or how fast is the camera zooming.
  34656. */
  34657. pinchPrecision: number;
  34658. /**
  34659. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  34660. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34661. */
  34662. pinchDeltaPercentage: number;
  34663. /**
  34664. * Defines the pointer panning sensibility or how fast is the camera moving.
  34665. */
  34666. panningSensibility: number;
  34667. /**
  34668. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34669. */
  34670. multiTouchPanning: boolean;
  34671. /**
  34672. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  34673. */
  34674. multiTouchPanAndZoom: boolean;
  34675. /**
  34676. * Revers pinch action direction.
  34677. */
  34678. pinchInwards: boolean;
  34679. private _isPanClick;
  34680. private _pointerInput;
  34681. private _observer;
  34682. private _onMouseMove;
  34683. private _onGestureStart;
  34684. private _onGesture;
  34685. private _MSGestureHandler;
  34686. private _onLostFocus;
  34687. private _onContextMenu;
  34688. /**
  34689. * Attach the input controls to a specific dom element to get the input from.
  34690. * @param element Defines the element the controls should be listened from
  34691. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34692. */
  34693. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34694. /**
  34695. * Detach the current controls from the specified dom element.
  34696. * @param element Defines the element to stop listening the inputs from
  34697. */
  34698. detachControl(element: Nullable<HTMLElement>): void;
  34699. /**
  34700. * Gets the class name of the current intput.
  34701. * @returns the class name
  34702. */
  34703. getClassName(): string;
  34704. /**
  34705. * Get the friendly name associated with the input class.
  34706. * @returns the input friendly name
  34707. */
  34708. getSimpleName(): string;
  34709. }
  34710. }
  34711. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  34712. import { Nullable } from "babylonjs/types";
  34713. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34714. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34715. /**
  34716. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  34717. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34718. */
  34719. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  34720. /**
  34721. * Defines the camera the input is attached to.
  34722. */
  34723. camera: ArcRotateCamera;
  34724. /**
  34725. * Defines the list of key codes associated with the up action (increase alpha)
  34726. */
  34727. keysUp: number[];
  34728. /**
  34729. * Defines the list of key codes associated with the down action (decrease alpha)
  34730. */
  34731. keysDown: number[];
  34732. /**
  34733. * Defines the list of key codes associated with the left action (increase beta)
  34734. */
  34735. keysLeft: number[];
  34736. /**
  34737. * Defines the list of key codes associated with the right action (decrease beta)
  34738. */
  34739. keysRight: number[];
  34740. /**
  34741. * Defines the list of key codes associated with the reset action.
  34742. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  34743. */
  34744. keysReset: number[];
  34745. /**
  34746. * Defines the panning sensibility of the inputs.
  34747. * (How fast is the camera paning)
  34748. */
  34749. panningSensibility: number;
  34750. /**
  34751. * Defines the zooming sensibility of the inputs.
  34752. * (How fast is the camera zooming)
  34753. */
  34754. zoomingSensibility: number;
  34755. /**
  34756. * Defines wether maintaining the alt key down switch the movement mode from
  34757. * orientation to zoom.
  34758. */
  34759. useAltToZoom: boolean;
  34760. /**
  34761. * Rotation speed of the camera
  34762. */
  34763. angularSpeed: number;
  34764. private _keys;
  34765. private _ctrlPressed;
  34766. private _altPressed;
  34767. private _onCanvasBlurObserver;
  34768. private _onKeyboardObserver;
  34769. private _engine;
  34770. private _scene;
  34771. /**
  34772. * Attach the input controls to a specific dom element to get the input from.
  34773. * @param element Defines the element the controls should be listened from
  34774. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34775. */
  34776. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34777. /**
  34778. * Detach the current controls from the specified dom element.
  34779. * @param element Defines the element to stop listening the inputs from
  34780. */
  34781. detachControl(element: Nullable<HTMLElement>): void;
  34782. /**
  34783. * Update the current camera state depending on the inputs that have been used this frame.
  34784. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  34785. */
  34786. checkInputs(): void;
  34787. /**
  34788. * Gets the class name of the current intput.
  34789. * @returns the class name
  34790. */
  34791. getClassName(): string;
  34792. /**
  34793. * Get the friendly name associated with the input class.
  34794. * @returns the input friendly name
  34795. */
  34796. getSimpleName(): string;
  34797. }
  34798. }
  34799. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  34800. import { Nullable } from "babylonjs/types";
  34801. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34802. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34803. /**
  34804. * Manage the mouse wheel inputs to control an arc rotate camera.
  34805. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34806. */
  34807. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  34808. /**
  34809. * Defines the camera the input is attached to.
  34810. */
  34811. camera: ArcRotateCamera;
  34812. /**
  34813. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34814. */
  34815. wheelPrecision: number;
  34816. /**
  34817. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  34818. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  34819. */
  34820. wheelDeltaPercentage: number;
  34821. private _wheel;
  34822. private _observer;
  34823. /**
  34824. * Attach the input controls to a specific dom element to get the input from.
  34825. * @param element Defines the element the controls should be listened from
  34826. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34827. */
  34828. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34829. /**
  34830. * Detach the current controls from the specified dom element.
  34831. * @param element Defines the element to stop listening the inputs from
  34832. */
  34833. detachControl(element: Nullable<HTMLElement>): void;
  34834. /**
  34835. * Gets the class name of the current intput.
  34836. * @returns the class name
  34837. */
  34838. getClassName(): string;
  34839. /**
  34840. * Get the friendly name associated with the input class.
  34841. * @returns the input friendly name
  34842. */
  34843. getSimpleName(): string;
  34844. }
  34845. }
  34846. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  34847. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34848. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  34849. /**
  34850. * Default Inputs manager for the ArcRotateCamera.
  34851. * It groups all the default supported inputs for ease of use.
  34852. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34853. */
  34854. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  34855. /**
  34856. * Instantiates a new ArcRotateCameraInputsManager.
  34857. * @param camera Defines the camera the inputs belong to
  34858. */
  34859. constructor(camera: ArcRotateCamera);
  34860. /**
  34861. * Add mouse wheel input support to the input manager.
  34862. * @returns the current input manager
  34863. */
  34864. addMouseWheel(): ArcRotateCameraInputsManager;
  34865. /**
  34866. * Add pointers input support to the input manager.
  34867. * @returns the current input manager
  34868. */
  34869. addPointers(): ArcRotateCameraInputsManager;
  34870. /**
  34871. * Add keyboard input support to the input manager.
  34872. * @returns the current input manager
  34873. */
  34874. addKeyboard(): ArcRotateCameraInputsManager;
  34875. }
  34876. }
  34877. declare module "babylonjs/Cameras/arcRotateCamera" {
  34878. import { Observable } from "babylonjs/Misc/observable";
  34879. import { Nullable } from "babylonjs/types";
  34880. import { Scene } from "babylonjs/scene";
  34881. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  34882. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34883. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  34884. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  34885. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  34886. import { Camera } from "babylonjs/Cameras/camera";
  34887. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  34888. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  34889. import { Collider } from "babylonjs/Collisions/collider";
  34890. /**
  34891. * This represents an orbital type of camera.
  34892. *
  34893. * 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.
  34894. * 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.
  34895. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  34896. */
  34897. export class ArcRotateCamera extends TargetCamera {
  34898. /**
  34899. * Defines the rotation angle of the camera along the longitudinal axis.
  34900. */
  34901. alpha: number;
  34902. /**
  34903. * Defines the rotation angle of the camera along the latitudinal axis.
  34904. */
  34905. beta: number;
  34906. /**
  34907. * Defines the radius of the camera from it s target point.
  34908. */
  34909. radius: number;
  34910. protected _target: Vector3;
  34911. protected _targetHost: Nullable<AbstractMesh>;
  34912. /**
  34913. * Defines the target point of the camera.
  34914. * The camera looks towards it form the radius distance.
  34915. */
  34916. target: Vector3;
  34917. /**
  34918. * Define the current local position of the camera in the scene
  34919. */
  34920. position: Vector3;
  34921. /**
  34922. * Current inertia value on the longitudinal axis.
  34923. * The bigger this number the longer it will take for the camera to stop.
  34924. */
  34925. inertialAlphaOffset: number;
  34926. /**
  34927. * Current inertia value on the latitudinal axis.
  34928. * The bigger this number the longer it will take for the camera to stop.
  34929. */
  34930. inertialBetaOffset: number;
  34931. /**
  34932. * Current inertia value on the radius axis.
  34933. * The bigger this number the longer it will take for the camera to stop.
  34934. */
  34935. inertialRadiusOffset: number;
  34936. /**
  34937. * Minimum allowed angle on the longitudinal axis.
  34938. * This can help limiting how the Camera is able to move in the scene.
  34939. */
  34940. lowerAlphaLimit: Nullable<number>;
  34941. /**
  34942. * Maximum allowed angle on the longitudinal axis.
  34943. * This can help limiting how the Camera is able to move in the scene.
  34944. */
  34945. upperAlphaLimit: Nullable<number>;
  34946. /**
  34947. * Minimum allowed angle on the latitudinal axis.
  34948. * This can help limiting how the Camera is able to move in the scene.
  34949. */
  34950. lowerBetaLimit: number;
  34951. /**
  34952. * Maximum allowed angle on the latitudinal axis.
  34953. * This can help limiting how the Camera is able to move in the scene.
  34954. */
  34955. upperBetaLimit: number;
  34956. /**
  34957. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  34958. * This can help limiting how the Camera is able to move in the scene.
  34959. */
  34960. lowerRadiusLimit: Nullable<number>;
  34961. /**
  34962. * Maximum allowed distance of the camera to the target (The camera can not get further).
  34963. * This can help limiting how the Camera is able to move in the scene.
  34964. */
  34965. upperRadiusLimit: Nullable<number>;
  34966. /**
  34967. * Defines the current inertia value used during panning of the camera along the X axis.
  34968. */
  34969. inertialPanningX: number;
  34970. /**
  34971. * Defines the current inertia value used during panning of the camera along the Y axis.
  34972. */
  34973. inertialPanningY: number;
  34974. /**
  34975. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  34976. * Basically if your fingers moves away from more than this distance you will be considered
  34977. * in pinch mode.
  34978. */
  34979. pinchToPanMaxDistance: number;
  34980. /**
  34981. * Defines the maximum distance the camera can pan.
  34982. * This could help keeping the cammera always in your scene.
  34983. */
  34984. panningDistanceLimit: Nullable<number>;
  34985. /**
  34986. * Defines the target of the camera before paning.
  34987. */
  34988. panningOriginTarget: Vector3;
  34989. /**
  34990. * Defines the value of the inertia used during panning.
  34991. * 0 would mean stop inertia and one would mean no decelleration at all.
  34992. */
  34993. panningInertia: number;
  34994. /**
  34995. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  34996. */
  34997. angularSensibilityX: number;
  34998. /**
  34999. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35000. */
  35001. angularSensibilityY: number;
  35002. /**
  35003. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35004. */
  35005. pinchPrecision: number;
  35006. /**
  35007. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35008. * It will be used instead of pinchDeltaPrecision if different from 0.
  35009. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35010. */
  35011. pinchDeltaPercentage: number;
  35012. /**
  35013. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35014. */
  35015. panningSensibility: number;
  35016. /**
  35017. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35018. */
  35019. keysUp: number[];
  35020. /**
  35021. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35022. */
  35023. keysDown: number[];
  35024. /**
  35025. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35026. */
  35027. keysLeft: number[];
  35028. /**
  35029. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35030. */
  35031. keysRight: number[];
  35032. /**
  35033. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35034. */
  35035. wheelPrecision: number;
  35036. /**
  35037. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35038. * It will be used instead of pinchDeltaPrecision if different from 0.
  35039. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35040. */
  35041. wheelDeltaPercentage: number;
  35042. /**
  35043. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35044. */
  35045. zoomOnFactor: number;
  35046. /**
  35047. * Defines a screen offset for the camera position.
  35048. */
  35049. targetScreenOffset: Vector2;
  35050. /**
  35051. * Allows the camera to be completely reversed.
  35052. * If false the camera can not arrive upside down.
  35053. */
  35054. allowUpsideDown: boolean;
  35055. /**
  35056. * Define if double tap/click is used to restore the previously saved state of the camera.
  35057. */
  35058. useInputToRestoreState: boolean;
  35059. /** @hidden */
  35060. _viewMatrix: Matrix;
  35061. /** @hidden */
  35062. _useCtrlForPanning: boolean;
  35063. /** @hidden */
  35064. _panningMouseButton: number;
  35065. /**
  35066. * Defines the input associated to the camera.
  35067. */
  35068. inputs: ArcRotateCameraInputsManager;
  35069. /** @hidden */
  35070. _reset: () => void;
  35071. /**
  35072. * Defines the allowed panning axis.
  35073. */
  35074. panningAxis: Vector3;
  35075. protected _localDirection: Vector3;
  35076. protected _transformedDirection: Vector3;
  35077. private _bouncingBehavior;
  35078. /**
  35079. * Gets the bouncing behavior of the camera if it has been enabled.
  35080. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35081. */
  35082. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35083. /**
  35084. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35085. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35086. */
  35087. useBouncingBehavior: boolean;
  35088. private _framingBehavior;
  35089. /**
  35090. * Gets the framing behavior of the camera if it has been enabled.
  35091. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35092. */
  35093. readonly framingBehavior: Nullable<FramingBehavior>;
  35094. /**
  35095. * Defines if the framing behavior of the camera is enabled on the camera.
  35096. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35097. */
  35098. useFramingBehavior: boolean;
  35099. private _autoRotationBehavior;
  35100. /**
  35101. * Gets the auto rotation behavior of the camera if it has been enabled.
  35102. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35103. */
  35104. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35105. /**
  35106. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35107. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35108. */
  35109. useAutoRotationBehavior: boolean;
  35110. /**
  35111. * Observable triggered when the mesh target has been changed on the camera.
  35112. */
  35113. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35114. /**
  35115. * Event raised when the camera is colliding with a mesh.
  35116. */
  35117. onCollide: (collidedMesh: AbstractMesh) => void;
  35118. /**
  35119. * Defines whether the camera should check collision with the objects oh the scene.
  35120. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35121. */
  35122. checkCollisions: boolean;
  35123. /**
  35124. * Defines the collision radius of the camera.
  35125. * This simulates a sphere around the camera.
  35126. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35127. */
  35128. collisionRadius: Vector3;
  35129. protected _collider: Collider;
  35130. protected _previousPosition: Vector3;
  35131. protected _collisionVelocity: Vector3;
  35132. protected _newPosition: Vector3;
  35133. protected _previousAlpha: number;
  35134. protected _previousBeta: number;
  35135. protected _previousRadius: number;
  35136. protected _collisionTriggered: boolean;
  35137. protected _targetBoundingCenter: Nullable<Vector3>;
  35138. private _computationVector;
  35139. private _tempAxisVector;
  35140. private _tempAxisRotationMatrix;
  35141. /**
  35142. * Instantiates a new ArcRotateCamera in a given scene
  35143. * @param name Defines the name of the camera
  35144. * @param alpha Defines the camera rotation along the logitudinal axis
  35145. * @param beta Defines the camera rotation along the latitudinal axis
  35146. * @param radius Defines the camera distance from its target
  35147. * @param target Defines the camera target
  35148. * @param scene Defines the scene the camera belongs to
  35149. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35150. */
  35151. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35152. /** @hidden */
  35153. _initCache(): void;
  35154. /** @hidden */
  35155. _updateCache(ignoreParentClass?: boolean): void;
  35156. protected _getTargetPosition(): Vector3;
  35157. private _storedAlpha;
  35158. private _storedBeta;
  35159. private _storedRadius;
  35160. private _storedTarget;
  35161. /**
  35162. * Stores the current state of the camera (alpha, beta, radius and target)
  35163. * @returns the camera itself
  35164. */
  35165. storeState(): Camera;
  35166. /**
  35167. * @hidden
  35168. * Restored camera state. You must call storeState() first
  35169. */
  35170. _restoreStateValues(): boolean;
  35171. /** @hidden */
  35172. _isSynchronizedViewMatrix(): boolean;
  35173. /**
  35174. * Attached controls to the current camera.
  35175. * @param element Defines the element the controls should be listened from
  35176. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35177. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35178. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35179. */
  35180. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35181. /**
  35182. * Detach the current controls from the camera.
  35183. * The camera will stop reacting to inputs.
  35184. * @param element Defines the element to stop listening the inputs from
  35185. */
  35186. detachControl(element: HTMLElement): void;
  35187. /** @hidden */
  35188. _checkInputs(): void;
  35189. protected _checkLimits(): void;
  35190. /**
  35191. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35192. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  35193. */
  35194. rebuildAnglesAndRadius(updateView?: boolean): void;
  35195. /**
  35196. * Use a position to define the current camera related information like aplha, beta and radius
  35197. * @param position Defines the position to set the camera at
  35198. */
  35199. setPosition(position: Vector3): void;
  35200. /**
  35201. * Defines the target the camera should look at.
  35202. * This will automatically adapt alpha beta and radius to fit within the new target.
  35203. * @param target Defines the new target as a Vector or a mesh
  35204. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35205. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35206. */
  35207. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35208. /** @hidden */
  35209. _getViewMatrix(): Matrix;
  35210. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35211. /**
  35212. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35213. * @param meshes Defines the mesh to zoom on
  35214. * @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)
  35215. */
  35216. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35217. /**
  35218. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35219. * The target will be changed but the radius
  35220. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35221. * @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)
  35222. */
  35223. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35224. min: Vector3;
  35225. max: Vector3;
  35226. distance: number;
  35227. }, doNotUpdateMaxZ?: boolean): void;
  35228. /**
  35229. * @override
  35230. * Override Camera.createRigCamera
  35231. */
  35232. createRigCamera(name: string, cameraIndex: number): Camera;
  35233. /**
  35234. * @hidden
  35235. * @override
  35236. * Override Camera._updateRigCameras
  35237. */
  35238. _updateRigCameras(): void;
  35239. /**
  35240. * Destroy the camera and release the current resources hold by it.
  35241. */
  35242. dispose(): void;
  35243. /**
  35244. * Gets the current object class name.
  35245. * @return the class name
  35246. */
  35247. getClassName(): string;
  35248. }
  35249. }
  35250. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  35251. import { Behavior } from "babylonjs/Behaviors/behavior";
  35252. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35253. /**
  35254. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35255. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35256. */
  35257. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35258. /**
  35259. * Gets the name of the behavior.
  35260. */
  35261. readonly name: string;
  35262. private _zoomStopsAnimation;
  35263. private _idleRotationSpeed;
  35264. private _idleRotationWaitTime;
  35265. private _idleRotationSpinupTime;
  35266. /**
  35267. * Sets the flag that indicates if user zooming should stop animation.
  35268. */
  35269. /**
  35270. * Gets the flag that indicates if user zooming should stop animation.
  35271. */
  35272. zoomStopsAnimation: boolean;
  35273. /**
  35274. * Sets the default speed at which the camera rotates around the model.
  35275. */
  35276. /**
  35277. * Gets the default speed at which the camera rotates around the model.
  35278. */
  35279. idleRotationSpeed: number;
  35280. /**
  35281. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35282. */
  35283. /**
  35284. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35285. */
  35286. idleRotationWaitTime: number;
  35287. /**
  35288. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35289. */
  35290. /**
  35291. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35292. */
  35293. idleRotationSpinupTime: number;
  35294. /**
  35295. * Gets a value indicating if the camera is currently rotating because of this behavior
  35296. */
  35297. readonly rotationInProgress: boolean;
  35298. private _onPrePointerObservableObserver;
  35299. private _onAfterCheckInputsObserver;
  35300. private _attachedCamera;
  35301. private _isPointerDown;
  35302. private _lastFrameTime;
  35303. private _lastInteractionTime;
  35304. private _cameraRotationSpeed;
  35305. /**
  35306. * Initializes the behavior.
  35307. */
  35308. init(): void;
  35309. /**
  35310. * Attaches the behavior to its arc rotate camera.
  35311. * @param camera Defines the camera to attach the behavior to
  35312. */
  35313. attach(camera: ArcRotateCamera): void;
  35314. /**
  35315. * Detaches the behavior from its current arc rotate camera.
  35316. */
  35317. detach(): void;
  35318. /**
  35319. * Returns true if user is scrolling.
  35320. * @return true if user is scrolling.
  35321. */
  35322. private _userIsZooming;
  35323. private _lastFrameRadius;
  35324. private _shouldAnimationStopForInteraction;
  35325. /**
  35326. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35327. */
  35328. private _applyUserInteraction;
  35329. private _userIsMoving;
  35330. }
  35331. }
  35332. declare module "babylonjs/Behaviors/Cameras/index" {
  35333. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35334. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35335. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  35336. }
  35337. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  35338. import { Mesh } from "babylonjs/Meshes/mesh";
  35339. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35340. import { Behavior } from "babylonjs/Behaviors/behavior";
  35341. /**
  35342. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35343. */
  35344. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35345. private ui;
  35346. /**
  35347. * The name of the behavior
  35348. */
  35349. name: string;
  35350. /**
  35351. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35352. */
  35353. distanceAwayFromFace: number;
  35354. /**
  35355. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35356. */
  35357. distanceAwayFromBottomOfFace: number;
  35358. private _faceVectors;
  35359. private _target;
  35360. private _scene;
  35361. private _onRenderObserver;
  35362. private _tmpMatrix;
  35363. private _tmpVector;
  35364. /**
  35365. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35366. * @param ui The transform node that should be attched to the mesh
  35367. */
  35368. constructor(ui: TransformNode);
  35369. /**
  35370. * Initializes the behavior
  35371. */
  35372. init(): void;
  35373. private _closestFace;
  35374. private _zeroVector;
  35375. private _lookAtTmpMatrix;
  35376. private _lookAtToRef;
  35377. /**
  35378. * Attaches the AttachToBoxBehavior to the passed in mesh
  35379. * @param target The mesh that the specified node will be attached to
  35380. */
  35381. attach(target: Mesh): void;
  35382. /**
  35383. * Detaches the behavior from the mesh
  35384. */
  35385. detach(): void;
  35386. }
  35387. }
  35388. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  35389. import { Behavior } from "babylonjs/Behaviors/behavior";
  35390. import { Mesh } from "babylonjs/Meshes/mesh";
  35391. /**
  35392. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35393. */
  35394. export class FadeInOutBehavior implements Behavior<Mesh> {
  35395. /**
  35396. * Time in milliseconds to delay before fading in (Default: 0)
  35397. */
  35398. delay: number;
  35399. /**
  35400. * Time in milliseconds for the mesh to fade in (Default: 300)
  35401. */
  35402. fadeInTime: number;
  35403. private _millisecondsPerFrame;
  35404. private _hovered;
  35405. private _hoverValue;
  35406. private _ownerNode;
  35407. /**
  35408. * Instatiates the FadeInOutBehavior
  35409. */
  35410. constructor();
  35411. /**
  35412. * The name of the behavior
  35413. */
  35414. readonly name: string;
  35415. /**
  35416. * Initializes the behavior
  35417. */
  35418. init(): void;
  35419. /**
  35420. * Attaches the fade behavior on the passed in mesh
  35421. * @param ownerNode The mesh that will be faded in/out once attached
  35422. */
  35423. attach(ownerNode: Mesh): void;
  35424. /**
  35425. * Detaches the behavior from the mesh
  35426. */
  35427. detach(): void;
  35428. /**
  35429. * Triggers the mesh to begin fading in or out
  35430. * @param value if the object should fade in or out (true to fade in)
  35431. */
  35432. fadeIn(value: boolean): void;
  35433. private _update;
  35434. private _setAllVisibility;
  35435. }
  35436. }
  35437. declare module "babylonjs/Misc/pivotTools" {
  35438. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35439. /**
  35440. * Class containing a set of static utilities functions for managing Pivots
  35441. * @hidden
  35442. */
  35443. export class PivotTools {
  35444. private static _PivotCached;
  35445. private static _OldPivotPoint;
  35446. private static _PivotTranslation;
  35447. private static _PivotTmpVector;
  35448. /** @hidden */
  35449. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35450. /** @hidden */
  35451. static _RestorePivotPoint(mesh: AbstractMesh): void;
  35452. }
  35453. }
  35454. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  35455. import { Scene } from "babylonjs/scene";
  35456. import { Vector4, Plane } from "babylonjs/Maths/math";
  35457. import { Mesh } from "babylonjs/Meshes/mesh";
  35458. /**
  35459. * Class containing static functions to help procedurally build meshes
  35460. */
  35461. export class PlaneBuilder {
  35462. /**
  35463. * Creates a plane mesh
  35464. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35465. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35466. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35467. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35468. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  35469. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35470. * @param name defines the name of the mesh
  35471. * @param options defines the options used to create the mesh
  35472. * @param scene defines the hosting scene
  35473. * @returns the plane mesh
  35474. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35475. */
  35476. static CreatePlane(name: string, options: {
  35477. size?: number;
  35478. width?: number;
  35479. height?: number;
  35480. sideOrientation?: number;
  35481. frontUVs?: Vector4;
  35482. backUVs?: Vector4;
  35483. updatable?: boolean;
  35484. sourcePlane?: Plane;
  35485. }, scene: Scene): Mesh;
  35486. }
  35487. }
  35488. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  35489. import { Behavior } from "babylonjs/Behaviors/behavior";
  35490. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35491. import { Observable } from "babylonjs/Misc/observable";
  35492. import { Vector3 } from "babylonjs/Maths/math";
  35493. import { Ray } from "babylonjs/Culling/ray";
  35494. import "babylonjs/Meshes/Builders/planeBuilder";
  35495. /**
  35496. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35497. */
  35498. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35499. private static _AnyMouseID;
  35500. private _attachedNode;
  35501. private _dragPlane;
  35502. private _scene;
  35503. private _pointerObserver;
  35504. private _beforeRenderObserver;
  35505. private static _planeScene;
  35506. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35507. /**
  35508. * 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)
  35509. */
  35510. maxDragAngle: number;
  35511. /**
  35512. * @hidden
  35513. */
  35514. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35515. /**
  35516. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35517. */
  35518. currentDraggingPointerID: number;
  35519. /**
  35520. * The last position where the pointer hit the drag plane in world space
  35521. */
  35522. lastDragPosition: Vector3;
  35523. /**
  35524. * If the behavior is currently in a dragging state
  35525. */
  35526. dragging: boolean;
  35527. /**
  35528. * 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)
  35529. */
  35530. dragDeltaRatio: number;
  35531. /**
  35532. * If the drag plane orientation should be updated during the dragging (Default: true)
  35533. */
  35534. updateDragPlane: boolean;
  35535. private _debugMode;
  35536. private _moving;
  35537. /**
  35538. * Fires each time the attached mesh is dragged with the pointer
  35539. * * delta between last drag position and current drag position in world space
  35540. * * dragDistance along the drag axis
  35541. * * dragPlaneNormal normal of the current drag plane used during the drag
  35542. * * dragPlanePoint in world space where the drag intersects the drag plane
  35543. */
  35544. onDragObservable: Observable<{
  35545. delta: Vector3;
  35546. dragPlanePoint: Vector3;
  35547. dragPlaneNormal: Vector3;
  35548. dragDistance: number;
  35549. pointerId: number;
  35550. }>;
  35551. /**
  35552. * Fires each time a drag begins (eg. mouse down on mesh)
  35553. */
  35554. onDragStartObservable: Observable<{
  35555. dragPlanePoint: Vector3;
  35556. pointerId: number;
  35557. }>;
  35558. /**
  35559. * Fires each time a drag ends (eg. mouse release after drag)
  35560. */
  35561. onDragEndObservable: Observable<{
  35562. dragPlanePoint: Vector3;
  35563. pointerId: number;
  35564. }>;
  35565. /**
  35566. * If the attached mesh should be moved when dragged
  35567. */
  35568. moveAttached: boolean;
  35569. /**
  35570. * If the drag behavior will react to drag events (Default: true)
  35571. */
  35572. enabled: boolean;
  35573. /**
  35574. * If camera controls should be detached during the drag
  35575. */
  35576. detachCameraControls: boolean;
  35577. /**
  35578. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35579. */
  35580. useObjectOrienationForDragging: boolean;
  35581. private _options;
  35582. /**
  35583. * Creates a pointer drag behavior that can be attached to a mesh
  35584. * @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)
  35585. */
  35586. constructor(options?: {
  35587. dragAxis?: Vector3;
  35588. dragPlaneNormal?: Vector3;
  35589. });
  35590. /**
  35591. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35592. */
  35593. validateDrag: (targetPosition: Vector3) => boolean;
  35594. /**
  35595. * The name of the behavior
  35596. */
  35597. readonly name: string;
  35598. /**
  35599. * Initializes the behavior
  35600. */
  35601. init(): void;
  35602. private _tmpVector;
  35603. private _alternatePickedPoint;
  35604. private _worldDragAxis;
  35605. private _targetPosition;
  35606. private _attachedElement;
  35607. /**
  35608. * Attaches the drag behavior the passed in mesh
  35609. * @param ownerNode The mesh that will be dragged around once attached
  35610. */
  35611. attach(ownerNode: AbstractMesh): void;
  35612. /**
  35613. * Force relase the drag action by code.
  35614. */
  35615. releaseDrag(): void;
  35616. private _startDragRay;
  35617. private _lastPointerRay;
  35618. /**
  35619. * Simulates the start of a pointer drag event on the behavior
  35620. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35621. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35622. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35623. */
  35624. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35625. private _startDrag;
  35626. private _dragDelta;
  35627. private _moveDrag;
  35628. private _pickWithRayOnDragPlane;
  35629. private _pointA;
  35630. private _pointB;
  35631. private _pointC;
  35632. private _lineA;
  35633. private _lineB;
  35634. private _localAxis;
  35635. private _lookAt;
  35636. private _updateDragPlanePosition;
  35637. /**
  35638. * Detaches the behavior from the mesh
  35639. */
  35640. detach(): void;
  35641. }
  35642. }
  35643. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  35644. import { Mesh } from "babylonjs/Meshes/mesh";
  35645. import { Behavior } from "babylonjs/Behaviors/behavior";
  35646. /**
  35647. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35648. */
  35649. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35650. private _dragBehaviorA;
  35651. private _dragBehaviorB;
  35652. private _startDistance;
  35653. private _initialScale;
  35654. private _targetScale;
  35655. private _ownerNode;
  35656. private _sceneRenderObserver;
  35657. /**
  35658. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35659. */
  35660. constructor();
  35661. /**
  35662. * The name of the behavior
  35663. */
  35664. readonly name: string;
  35665. /**
  35666. * Initializes the behavior
  35667. */
  35668. init(): void;
  35669. private _getCurrentDistance;
  35670. /**
  35671. * Attaches the scale behavior the passed in mesh
  35672. * @param ownerNode The mesh that will be scaled around once attached
  35673. */
  35674. attach(ownerNode: Mesh): void;
  35675. /**
  35676. * Detaches the behavior from the mesh
  35677. */
  35678. detach(): void;
  35679. }
  35680. }
  35681. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  35682. import { Behavior } from "babylonjs/Behaviors/behavior";
  35683. import { Mesh } from "babylonjs/Meshes/mesh";
  35684. import { Observable } from "babylonjs/Misc/observable";
  35685. /**
  35686. * 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
  35687. */
  35688. export class SixDofDragBehavior implements Behavior<Mesh> {
  35689. private static _virtualScene;
  35690. private _ownerNode;
  35691. private _sceneRenderObserver;
  35692. private _scene;
  35693. private _targetPosition;
  35694. private _virtualOriginMesh;
  35695. private _virtualDragMesh;
  35696. private _pointerObserver;
  35697. private _moving;
  35698. private _startingOrientation;
  35699. /**
  35700. * 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)
  35701. */
  35702. private zDragFactor;
  35703. /**
  35704. * If the object should rotate to face the drag origin
  35705. */
  35706. rotateDraggedObject: boolean;
  35707. /**
  35708. * If the behavior is currently in a dragging state
  35709. */
  35710. dragging: boolean;
  35711. /**
  35712. * 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)
  35713. */
  35714. dragDeltaRatio: number;
  35715. /**
  35716. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35717. */
  35718. currentDraggingPointerID: number;
  35719. /**
  35720. * If camera controls should be detached during the drag
  35721. */
  35722. detachCameraControls: boolean;
  35723. /**
  35724. * Fires each time a drag starts
  35725. */
  35726. onDragStartObservable: Observable<{}>;
  35727. /**
  35728. * Fires each time a drag ends (eg. mouse release after drag)
  35729. */
  35730. onDragEndObservable: Observable<{}>;
  35731. /**
  35732. * 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
  35733. */
  35734. constructor();
  35735. /**
  35736. * The name of the behavior
  35737. */
  35738. readonly name: string;
  35739. /**
  35740. * Initializes the behavior
  35741. */
  35742. init(): void;
  35743. /**
  35744. * Attaches the scale behavior the passed in mesh
  35745. * @param ownerNode The mesh that will be scaled around once attached
  35746. */
  35747. attach(ownerNode: Mesh): void;
  35748. /**
  35749. * Detaches the behavior from the mesh
  35750. */
  35751. detach(): void;
  35752. }
  35753. }
  35754. declare module "babylonjs/Behaviors/Meshes/index" {
  35755. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  35756. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  35757. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  35758. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  35759. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  35760. }
  35761. declare module "babylonjs/Behaviors/index" {
  35762. export * from "babylonjs/Behaviors/behavior";
  35763. export * from "babylonjs/Behaviors/Cameras/index";
  35764. export * from "babylonjs/Behaviors/Meshes/index";
  35765. }
  35766. declare module "babylonjs/Bones/boneIKController" {
  35767. import { Bone } from "babylonjs/Bones/bone";
  35768. import { Vector3 } from "babylonjs/Maths/math";
  35769. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35770. import { Nullable } from "babylonjs/types";
  35771. /**
  35772. * Class used to apply inverse kinematics to bones
  35773. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  35774. */
  35775. export class BoneIKController {
  35776. private static _tmpVecs;
  35777. private static _tmpQuat;
  35778. private static _tmpMats;
  35779. /**
  35780. * Gets or sets the target mesh
  35781. */
  35782. targetMesh: AbstractMesh;
  35783. /** Gets or sets the mesh used as pole */
  35784. poleTargetMesh: AbstractMesh;
  35785. /**
  35786. * Gets or sets the bone used as pole
  35787. */
  35788. poleTargetBone: Nullable<Bone>;
  35789. /**
  35790. * Gets or sets the target position
  35791. */
  35792. targetPosition: Vector3;
  35793. /**
  35794. * Gets or sets the pole target position
  35795. */
  35796. poleTargetPosition: Vector3;
  35797. /**
  35798. * Gets or sets the pole target local offset
  35799. */
  35800. poleTargetLocalOffset: Vector3;
  35801. /**
  35802. * Gets or sets the pole angle
  35803. */
  35804. poleAngle: number;
  35805. /**
  35806. * Gets or sets the mesh associated with the controller
  35807. */
  35808. mesh: AbstractMesh;
  35809. /**
  35810. * 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)
  35811. */
  35812. slerpAmount: number;
  35813. private _bone1Quat;
  35814. private _bone1Mat;
  35815. private _bone2Ang;
  35816. private _bone1;
  35817. private _bone2;
  35818. private _bone1Length;
  35819. private _bone2Length;
  35820. private _maxAngle;
  35821. private _maxReach;
  35822. private _rightHandedSystem;
  35823. private _bendAxis;
  35824. private _slerping;
  35825. private _adjustRoll;
  35826. /**
  35827. * Gets or sets maximum allowed angle
  35828. */
  35829. maxAngle: number;
  35830. /**
  35831. * Creates a new BoneIKController
  35832. * @param mesh defines the mesh to control
  35833. * @param bone defines the bone to control
  35834. * @param options defines options to set up the controller
  35835. */
  35836. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  35837. targetMesh?: AbstractMesh;
  35838. poleTargetMesh?: AbstractMesh;
  35839. poleTargetBone?: Bone;
  35840. poleTargetLocalOffset?: Vector3;
  35841. poleAngle?: number;
  35842. bendAxis?: Vector3;
  35843. maxAngle?: number;
  35844. slerpAmount?: number;
  35845. });
  35846. private _setMaxAngle;
  35847. /**
  35848. * Force the controller to update the bones
  35849. */
  35850. update(): void;
  35851. }
  35852. }
  35853. declare module "babylonjs/Bones/boneLookController" {
  35854. import { Vector3, Space } from "babylonjs/Maths/math";
  35855. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35856. import { Bone } from "babylonjs/Bones/bone";
  35857. /**
  35858. * Class used to make a bone look toward a point in space
  35859. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  35860. */
  35861. export class BoneLookController {
  35862. private static _tmpVecs;
  35863. private static _tmpQuat;
  35864. private static _tmpMats;
  35865. /**
  35866. * The target Vector3 that the bone will look at
  35867. */
  35868. target: Vector3;
  35869. /**
  35870. * The mesh that the bone is attached to
  35871. */
  35872. mesh: AbstractMesh;
  35873. /**
  35874. * The bone that will be looking to the target
  35875. */
  35876. bone: Bone;
  35877. /**
  35878. * The up axis of the coordinate system that is used when the bone is rotated
  35879. */
  35880. upAxis: Vector3;
  35881. /**
  35882. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  35883. */
  35884. upAxisSpace: Space;
  35885. /**
  35886. * Used to make an adjustment to the yaw of the bone
  35887. */
  35888. adjustYaw: number;
  35889. /**
  35890. * Used to make an adjustment to the pitch of the bone
  35891. */
  35892. adjustPitch: number;
  35893. /**
  35894. * Used to make an adjustment to the roll of the bone
  35895. */
  35896. adjustRoll: number;
  35897. /**
  35898. * 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)
  35899. */
  35900. slerpAmount: number;
  35901. private _minYaw;
  35902. private _maxYaw;
  35903. private _minPitch;
  35904. private _maxPitch;
  35905. private _minYawSin;
  35906. private _minYawCos;
  35907. private _maxYawSin;
  35908. private _maxYawCos;
  35909. private _midYawConstraint;
  35910. private _minPitchTan;
  35911. private _maxPitchTan;
  35912. private _boneQuat;
  35913. private _slerping;
  35914. private _transformYawPitch;
  35915. private _transformYawPitchInv;
  35916. private _firstFrameSkipped;
  35917. private _yawRange;
  35918. private _fowardAxis;
  35919. /**
  35920. * Gets or sets the minimum yaw angle that the bone can look to
  35921. */
  35922. minYaw: number;
  35923. /**
  35924. * Gets or sets the maximum yaw angle that the bone can look to
  35925. */
  35926. maxYaw: number;
  35927. /**
  35928. * Gets or sets the minimum pitch angle that the bone can look to
  35929. */
  35930. minPitch: number;
  35931. /**
  35932. * Gets or sets the maximum pitch angle that the bone can look to
  35933. */
  35934. maxPitch: number;
  35935. /**
  35936. * Create a BoneLookController
  35937. * @param mesh the mesh that the bone belongs to
  35938. * @param bone the bone that will be looking to the target
  35939. * @param target the target Vector3 to look at
  35940. * @param options optional settings:
  35941. * * maxYaw: the maximum angle the bone will yaw to
  35942. * * minYaw: the minimum angle the bone will yaw to
  35943. * * maxPitch: the maximum angle the bone will pitch to
  35944. * * minPitch: the minimum angle the bone will yaw to
  35945. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  35946. * * upAxis: the up axis of the coordinate system
  35947. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  35948. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  35949. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  35950. * * adjustYaw: used to make an adjustment to the yaw of the bone
  35951. * * adjustPitch: used to make an adjustment to the pitch of the bone
  35952. * * adjustRoll: used to make an adjustment to the roll of the bone
  35953. **/
  35954. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  35955. maxYaw?: number;
  35956. minYaw?: number;
  35957. maxPitch?: number;
  35958. minPitch?: number;
  35959. slerpAmount?: number;
  35960. upAxis?: Vector3;
  35961. upAxisSpace?: Space;
  35962. yawAxis?: Vector3;
  35963. pitchAxis?: Vector3;
  35964. adjustYaw?: number;
  35965. adjustPitch?: number;
  35966. adjustRoll?: number;
  35967. });
  35968. /**
  35969. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  35970. */
  35971. update(): void;
  35972. private _getAngleDiff;
  35973. private _getAngleBetween;
  35974. private _isAngleBetween;
  35975. }
  35976. }
  35977. declare module "babylonjs/Bones/index" {
  35978. export * from "babylonjs/Bones/bone";
  35979. export * from "babylonjs/Bones/boneIKController";
  35980. export * from "babylonjs/Bones/boneLookController";
  35981. export * from "babylonjs/Bones/skeleton";
  35982. }
  35983. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  35984. import { Nullable } from "babylonjs/types";
  35985. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35986. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35987. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  35988. /**
  35989. * Manage the gamepad inputs to control an arc rotate camera.
  35990. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35991. */
  35992. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  35993. /**
  35994. * Defines the camera the input is attached to.
  35995. */
  35996. camera: ArcRotateCamera;
  35997. /**
  35998. * Defines the gamepad the input is gathering event from.
  35999. */
  36000. gamepad: Nullable<Gamepad>;
  36001. /**
  36002. * Defines the gamepad rotation sensiblity.
  36003. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36004. */
  36005. gamepadRotationSensibility: number;
  36006. /**
  36007. * Defines the gamepad move sensiblity.
  36008. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36009. */
  36010. gamepadMoveSensibility: number;
  36011. private _onGamepadConnectedObserver;
  36012. private _onGamepadDisconnectedObserver;
  36013. /**
  36014. * Attach the input controls to a specific dom element to get the input from.
  36015. * @param element Defines the element the controls should be listened from
  36016. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36017. */
  36018. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36019. /**
  36020. * Detach the current controls from the specified dom element.
  36021. * @param element Defines the element to stop listening the inputs from
  36022. */
  36023. detachControl(element: Nullable<HTMLElement>): void;
  36024. /**
  36025. * Update the current camera state depending on the inputs that have been used this frame.
  36026. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36027. */
  36028. checkInputs(): void;
  36029. /**
  36030. * Gets the class name of the current intput.
  36031. * @returns the class name
  36032. */
  36033. getClassName(): string;
  36034. /**
  36035. * Get the friendly name associated with the input class.
  36036. * @returns the input friendly name
  36037. */
  36038. getSimpleName(): string;
  36039. }
  36040. }
  36041. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  36042. import { Nullable } from "babylonjs/types";
  36043. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36044. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36045. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36046. interface ArcRotateCameraInputsManager {
  36047. /**
  36048. * Add orientation input support to the input manager.
  36049. * @returns the current input manager
  36050. */
  36051. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36052. }
  36053. }
  36054. /**
  36055. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36056. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36057. */
  36058. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36059. /**
  36060. * Defines the camera the input is attached to.
  36061. */
  36062. camera: ArcRotateCamera;
  36063. /**
  36064. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36065. */
  36066. alphaCorrection: number;
  36067. /**
  36068. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36069. */
  36070. gammaCorrection: number;
  36071. private _alpha;
  36072. private _gamma;
  36073. private _dirty;
  36074. private _deviceOrientationHandler;
  36075. /**
  36076. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36077. */
  36078. constructor();
  36079. /**
  36080. * Attach the input controls to a specific dom element to get the input from.
  36081. * @param element Defines the element the controls should be listened from
  36082. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36083. */
  36084. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36085. /** @hidden */
  36086. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36087. /**
  36088. * Update the current camera state depending on the inputs that have been used this frame.
  36089. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36090. */
  36091. checkInputs(): void;
  36092. /**
  36093. * Detach the current controls from the specified dom element.
  36094. * @param element Defines the element to stop listening the inputs from
  36095. */
  36096. detachControl(element: Nullable<HTMLElement>): void;
  36097. /**
  36098. * Gets the class name of the current intput.
  36099. * @returns the class name
  36100. */
  36101. getClassName(): string;
  36102. /**
  36103. * Get the friendly name associated with the input class.
  36104. * @returns the input friendly name
  36105. */
  36106. getSimpleName(): string;
  36107. }
  36108. }
  36109. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  36110. import { Nullable } from "babylonjs/types";
  36111. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36112. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36113. /**
  36114. * Listen to mouse events to control the camera.
  36115. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36116. */
  36117. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36118. /**
  36119. * Defines the camera the input is attached to.
  36120. */
  36121. camera: FlyCamera;
  36122. /**
  36123. * Defines if touch is enabled. (Default is true.)
  36124. */
  36125. touchEnabled: boolean;
  36126. /**
  36127. * Defines the buttons associated with the input to handle camera rotation.
  36128. */
  36129. buttons: number[];
  36130. /**
  36131. * Assign buttons for Yaw control.
  36132. */
  36133. buttonsYaw: number[];
  36134. /**
  36135. * Assign buttons for Pitch control.
  36136. */
  36137. buttonsPitch: number[];
  36138. /**
  36139. * Assign buttons for Roll control.
  36140. */
  36141. buttonsRoll: number[];
  36142. /**
  36143. * Detect if any button is being pressed while mouse is moved.
  36144. * -1 = Mouse locked.
  36145. * 0 = Left button.
  36146. * 1 = Middle Button.
  36147. * 2 = Right Button.
  36148. */
  36149. activeButton: number;
  36150. /**
  36151. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36152. * Higher values reduce its sensitivity.
  36153. */
  36154. angularSensibility: number;
  36155. private _mousemoveCallback;
  36156. private _observer;
  36157. private _rollObserver;
  36158. private previousPosition;
  36159. private noPreventDefault;
  36160. private element;
  36161. /**
  36162. * Listen to mouse events to control the camera.
  36163. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36164. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36165. */
  36166. constructor(touchEnabled?: boolean);
  36167. /**
  36168. * Attach the mouse control to the HTML DOM element.
  36169. * @param element Defines the element that listens to the input events.
  36170. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36171. */
  36172. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36173. /**
  36174. * Detach the current controls from the specified dom element.
  36175. * @param element Defines the element to stop listening the inputs from
  36176. */
  36177. detachControl(element: Nullable<HTMLElement>): void;
  36178. /**
  36179. * Gets the class name of the current input.
  36180. * @returns the class name.
  36181. */
  36182. getClassName(): string;
  36183. /**
  36184. * Get the friendly name associated with the input class.
  36185. * @returns the input's friendly name.
  36186. */
  36187. getSimpleName(): string;
  36188. private _pointerInput;
  36189. private _onMouseMove;
  36190. /**
  36191. * Rotate camera by mouse offset.
  36192. */
  36193. private rotateCamera;
  36194. }
  36195. }
  36196. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  36197. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36198. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36199. /**
  36200. * Default Inputs manager for the FlyCamera.
  36201. * It groups all the default supported inputs for ease of use.
  36202. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36203. */
  36204. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36205. /**
  36206. * Instantiates a new FlyCameraInputsManager.
  36207. * @param camera Defines the camera the inputs belong to.
  36208. */
  36209. constructor(camera: FlyCamera);
  36210. /**
  36211. * Add keyboard input support to the input manager.
  36212. * @returns the new FlyCameraKeyboardMoveInput().
  36213. */
  36214. addKeyboard(): FlyCameraInputsManager;
  36215. /**
  36216. * Add mouse input support to the input manager.
  36217. * @param touchEnabled Enable touch screen support.
  36218. * @returns the new FlyCameraMouseInput().
  36219. */
  36220. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36221. }
  36222. }
  36223. declare module "babylonjs/Cameras/flyCamera" {
  36224. import { Scene } from "babylonjs/scene";
  36225. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  36226. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36227. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36228. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  36229. /**
  36230. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36231. * such as in a 3D Space Shooter or a Flight Simulator.
  36232. */
  36233. export class FlyCamera extends TargetCamera {
  36234. /**
  36235. * Define the collision ellipsoid of the camera.
  36236. * This is helpful for simulating a camera body, like a player's body.
  36237. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36238. */
  36239. ellipsoid: Vector3;
  36240. /**
  36241. * Define an offset for the position of the ellipsoid around the camera.
  36242. * This can be helpful if the camera is attached away from the player's body center,
  36243. * such as at its head.
  36244. */
  36245. ellipsoidOffset: Vector3;
  36246. /**
  36247. * Enable or disable collisions of the camera with the rest of the scene objects.
  36248. */
  36249. checkCollisions: boolean;
  36250. /**
  36251. * Enable or disable gravity on the camera.
  36252. */
  36253. applyGravity: boolean;
  36254. /**
  36255. * Define the current direction the camera is moving to.
  36256. */
  36257. cameraDirection: Vector3;
  36258. /**
  36259. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36260. * This overrides and empties cameraRotation.
  36261. */
  36262. rotationQuaternion: Quaternion;
  36263. /**
  36264. * Track Roll to maintain the wanted Rolling when looking around.
  36265. */
  36266. _trackRoll: number;
  36267. /**
  36268. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36269. */
  36270. rollCorrect: number;
  36271. /**
  36272. * Mimic a banked turn, Rolling the camera when Yawing.
  36273. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36274. */
  36275. bankedTurn: boolean;
  36276. /**
  36277. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36278. */
  36279. bankedTurnLimit: number;
  36280. /**
  36281. * Value of 0 disables the banked Roll.
  36282. * Value of 1 is equal to the Yaw angle in radians.
  36283. */
  36284. bankedTurnMultiplier: number;
  36285. /**
  36286. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36287. */
  36288. inputs: FlyCameraInputsManager;
  36289. /**
  36290. * Gets the input sensibility for mouse input.
  36291. * Higher values reduce sensitivity.
  36292. */
  36293. /**
  36294. * Sets the input sensibility for a mouse input.
  36295. * Higher values reduce sensitivity.
  36296. */
  36297. angularSensibility: number;
  36298. /**
  36299. * Get the keys for camera movement forward.
  36300. */
  36301. /**
  36302. * Set the keys for camera movement forward.
  36303. */
  36304. keysForward: number[];
  36305. /**
  36306. * Get the keys for camera movement backward.
  36307. */
  36308. keysBackward: number[];
  36309. /**
  36310. * Get the keys for camera movement up.
  36311. */
  36312. /**
  36313. * Set the keys for camera movement up.
  36314. */
  36315. keysUp: number[];
  36316. /**
  36317. * Get the keys for camera movement down.
  36318. */
  36319. /**
  36320. * Set the keys for camera movement down.
  36321. */
  36322. keysDown: number[];
  36323. /**
  36324. * Get the keys for camera movement left.
  36325. */
  36326. /**
  36327. * Set the keys for camera movement left.
  36328. */
  36329. keysLeft: number[];
  36330. /**
  36331. * Set the keys for camera movement right.
  36332. */
  36333. /**
  36334. * Set the keys for camera movement right.
  36335. */
  36336. keysRight: number[];
  36337. /**
  36338. * Event raised when the camera collides with a mesh in the scene.
  36339. */
  36340. onCollide: (collidedMesh: AbstractMesh) => void;
  36341. private _collider;
  36342. private _needMoveForGravity;
  36343. private _oldPosition;
  36344. private _diffPosition;
  36345. private _newPosition;
  36346. /** @hidden */
  36347. _localDirection: Vector3;
  36348. /** @hidden */
  36349. _transformedDirection: Vector3;
  36350. /**
  36351. * Instantiates a FlyCamera.
  36352. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36353. * such as in a 3D Space Shooter or a Flight Simulator.
  36354. * @param name Define the name of the camera in the scene.
  36355. * @param position Define the starting position of the camera in the scene.
  36356. * @param scene Define the scene the camera belongs to.
  36357. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36358. */
  36359. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36360. /**
  36361. * Attach a control to the HTML DOM element.
  36362. * @param element Defines the element that listens to the input events.
  36363. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36364. */
  36365. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36366. /**
  36367. * Detach a control from the HTML DOM element.
  36368. * The camera will stop reacting to that input.
  36369. * @param element Defines the element that listens to the input events.
  36370. */
  36371. detachControl(element: HTMLElement): void;
  36372. private _collisionMask;
  36373. /**
  36374. * Get the mask that the camera ignores in collision events.
  36375. */
  36376. /**
  36377. * Set the mask that the camera ignores in collision events.
  36378. */
  36379. collisionMask: number;
  36380. /** @hidden */
  36381. _collideWithWorld(displacement: Vector3): void;
  36382. /** @hidden */
  36383. private _onCollisionPositionChange;
  36384. /** @hidden */
  36385. _checkInputs(): void;
  36386. /** @hidden */
  36387. _decideIfNeedsToMove(): boolean;
  36388. /** @hidden */
  36389. _updatePosition(): void;
  36390. /**
  36391. * Restore the Roll to its target value at the rate specified.
  36392. * @param rate - Higher means slower restoring.
  36393. * @hidden
  36394. */
  36395. restoreRoll(rate: number): void;
  36396. /**
  36397. * Destroy the camera and release the current resources held by it.
  36398. */
  36399. dispose(): void;
  36400. /**
  36401. * Get the current object class name.
  36402. * @returns the class name.
  36403. */
  36404. getClassName(): string;
  36405. }
  36406. }
  36407. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  36408. import { Nullable } from "babylonjs/types";
  36409. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36410. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36411. /**
  36412. * Listen to keyboard events to control the camera.
  36413. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36414. */
  36415. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36416. /**
  36417. * Defines the camera the input is attached to.
  36418. */
  36419. camera: FlyCamera;
  36420. /**
  36421. * The list of keyboard keys used to control the forward move of the camera.
  36422. */
  36423. keysForward: number[];
  36424. /**
  36425. * The list of keyboard keys used to control the backward move of the camera.
  36426. */
  36427. keysBackward: number[];
  36428. /**
  36429. * The list of keyboard keys used to control the forward move of the camera.
  36430. */
  36431. keysUp: number[];
  36432. /**
  36433. * The list of keyboard keys used to control the backward move of the camera.
  36434. */
  36435. keysDown: number[];
  36436. /**
  36437. * The list of keyboard keys used to control the right strafe move of the camera.
  36438. */
  36439. keysRight: number[];
  36440. /**
  36441. * The list of keyboard keys used to control the left strafe move of the camera.
  36442. */
  36443. keysLeft: number[];
  36444. private _keys;
  36445. private _onCanvasBlurObserver;
  36446. private _onKeyboardObserver;
  36447. private _engine;
  36448. private _scene;
  36449. /**
  36450. * Attach the input controls to a specific dom element to get the input from.
  36451. * @param element Defines the element the controls should be listened from
  36452. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36453. */
  36454. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36455. /**
  36456. * Detach the current controls from the specified dom element.
  36457. * @param element Defines the element to stop listening the inputs from
  36458. */
  36459. detachControl(element: Nullable<HTMLElement>): void;
  36460. /**
  36461. * Gets the class name of the current intput.
  36462. * @returns the class name
  36463. */
  36464. getClassName(): string;
  36465. /** @hidden */
  36466. _onLostFocus(e: FocusEvent): void;
  36467. /**
  36468. * Get the friendly name associated with the input class.
  36469. * @returns the input friendly name
  36470. */
  36471. getSimpleName(): string;
  36472. /**
  36473. * Update the current camera state depending on the inputs that have been used this frame.
  36474. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36475. */
  36476. checkInputs(): void;
  36477. }
  36478. }
  36479. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  36480. import { Nullable } from "babylonjs/types";
  36481. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36482. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  36483. module "babylonjs/Cameras/freeCameraInputsManager" {
  36484. interface FreeCameraInputsManager {
  36485. /**
  36486. * Add orientation input support to the input manager.
  36487. * @returns the current input manager
  36488. */
  36489. addDeviceOrientation(): FreeCameraInputsManager;
  36490. }
  36491. }
  36492. /**
  36493. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  36494. * Screen rotation is taken into account.
  36495. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36496. */
  36497. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  36498. private _camera;
  36499. private _screenOrientationAngle;
  36500. private _constantTranform;
  36501. private _screenQuaternion;
  36502. private _alpha;
  36503. private _beta;
  36504. private _gamma;
  36505. /**
  36506. * Instantiates a new input
  36507. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36508. */
  36509. constructor();
  36510. /**
  36511. * Define the camera controlled by the input.
  36512. */
  36513. camera: FreeCamera;
  36514. /**
  36515. * Attach the input controls to a specific dom element to get the input from.
  36516. * @param element Defines the element the controls should be listened from
  36517. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36518. */
  36519. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36520. private _orientationChanged;
  36521. private _deviceOrientation;
  36522. /**
  36523. * Detach the current controls from the specified dom element.
  36524. * @param element Defines the element to stop listening the inputs from
  36525. */
  36526. detachControl(element: Nullable<HTMLElement>): void;
  36527. /**
  36528. * Update the current camera state depending on the inputs that have been used this frame.
  36529. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36530. */
  36531. checkInputs(): void;
  36532. /**
  36533. * Gets the class name of the current intput.
  36534. * @returns the class name
  36535. */
  36536. getClassName(): string;
  36537. /**
  36538. * Get the friendly name associated with the input class.
  36539. * @returns the input friendly name
  36540. */
  36541. getSimpleName(): string;
  36542. }
  36543. }
  36544. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  36545. import { Nullable } from "babylonjs/types";
  36546. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36547. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  36548. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  36549. /**
  36550. * Manage the gamepad inputs to control a free camera.
  36551. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36552. */
  36553. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  36554. /**
  36555. * Define the camera the input is attached to.
  36556. */
  36557. camera: FreeCamera;
  36558. /**
  36559. * Define the Gamepad controlling the input
  36560. */
  36561. gamepad: Nullable<Gamepad>;
  36562. /**
  36563. * Defines the gamepad rotation sensiblity.
  36564. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36565. */
  36566. gamepadAngularSensibility: number;
  36567. /**
  36568. * Defines the gamepad move sensiblity.
  36569. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36570. */
  36571. gamepadMoveSensibility: number;
  36572. private _onGamepadConnectedObserver;
  36573. private _onGamepadDisconnectedObserver;
  36574. private _cameraTransform;
  36575. private _deltaTransform;
  36576. private _vector3;
  36577. private _vector2;
  36578. /**
  36579. * Attach the input controls to a specific dom element to get the input from.
  36580. * @param element Defines the element the controls should be listened from
  36581. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36582. */
  36583. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36584. /**
  36585. * Detach the current controls from the specified dom element.
  36586. * @param element Defines the element to stop listening the inputs from
  36587. */
  36588. detachControl(element: Nullable<HTMLElement>): void;
  36589. /**
  36590. * Update the current camera state depending on the inputs that have been used this frame.
  36591. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36592. */
  36593. checkInputs(): void;
  36594. /**
  36595. * Gets the class name of the current intput.
  36596. * @returns the class name
  36597. */
  36598. getClassName(): string;
  36599. /**
  36600. * Get the friendly name associated with the input class.
  36601. * @returns the input friendly name
  36602. */
  36603. getSimpleName(): string;
  36604. }
  36605. }
  36606. declare module "babylonjs/Misc/virtualJoystick" {
  36607. import { Nullable } from "babylonjs/types";
  36608. import { Vector3 } from "babylonjs/Maths/math";
  36609. /**
  36610. * Defines the potential axis of a Joystick
  36611. */
  36612. export enum JoystickAxis {
  36613. /** X axis */
  36614. X = 0,
  36615. /** Y axis */
  36616. Y = 1,
  36617. /** Z axis */
  36618. Z = 2
  36619. }
  36620. /**
  36621. * Class used to define virtual joystick (used in touch mode)
  36622. */
  36623. export class VirtualJoystick {
  36624. /**
  36625. * Gets or sets a boolean indicating that left and right values must be inverted
  36626. */
  36627. reverseLeftRight: boolean;
  36628. /**
  36629. * Gets or sets a boolean indicating that up and down values must be inverted
  36630. */
  36631. reverseUpDown: boolean;
  36632. /**
  36633. * Gets the offset value for the position (ie. the change of the position value)
  36634. */
  36635. deltaPosition: Vector3;
  36636. /**
  36637. * Gets a boolean indicating if the virtual joystick was pressed
  36638. */
  36639. pressed: boolean;
  36640. /**
  36641. * Canvas the virtual joystick will render onto, default z-index of this is 5
  36642. */
  36643. static Canvas: Nullable<HTMLCanvasElement>;
  36644. private static _globalJoystickIndex;
  36645. private static vjCanvasContext;
  36646. private static vjCanvasWidth;
  36647. private static vjCanvasHeight;
  36648. private static halfWidth;
  36649. private _action;
  36650. private _axisTargetedByLeftAndRight;
  36651. private _axisTargetedByUpAndDown;
  36652. private _joystickSensibility;
  36653. private _inversedSensibility;
  36654. private _joystickPointerID;
  36655. private _joystickColor;
  36656. private _joystickPointerPos;
  36657. private _joystickPreviousPointerPos;
  36658. private _joystickPointerStartPos;
  36659. private _deltaJoystickVector;
  36660. private _leftJoystick;
  36661. private _touches;
  36662. private _onPointerDownHandlerRef;
  36663. private _onPointerMoveHandlerRef;
  36664. private _onPointerUpHandlerRef;
  36665. private _onResize;
  36666. /**
  36667. * Creates a new virtual joystick
  36668. * @param leftJoystick defines that the joystick is for left hand (false by default)
  36669. */
  36670. constructor(leftJoystick?: boolean);
  36671. /**
  36672. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  36673. * @param newJoystickSensibility defines the new sensibility
  36674. */
  36675. setJoystickSensibility(newJoystickSensibility: number): void;
  36676. private _onPointerDown;
  36677. private _onPointerMove;
  36678. private _onPointerUp;
  36679. /**
  36680. * Change the color of the virtual joystick
  36681. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  36682. */
  36683. setJoystickColor(newColor: string): void;
  36684. /**
  36685. * Defines a callback to call when the joystick is touched
  36686. * @param action defines the callback
  36687. */
  36688. setActionOnTouch(action: () => any): void;
  36689. /**
  36690. * Defines which axis you'd like to control for left & right
  36691. * @param axis defines the axis to use
  36692. */
  36693. setAxisForLeftRight(axis: JoystickAxis): void;
  36694. /**
  36695. * Defines which axis you'd like to control for up & down
  36696. * @param axis defines the axis to use
  36697. */
  36698. setAxisForUpDown(axis: JoystickAxis): void;
  36699. private _drawVirtualJoystick;
  36700. /**
  36701. * Release internal HTML canvas
  36702. */
  36703. releaseCanvas(): void;
  36704. }
  36705. }
  36706. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  36707. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  36708. import { Nullable } from "babylonjs/types";
  36709. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36710. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  36711. module "babylonjs/Cameras/freeCameraInputsManager" {
  36712. interface FreeCameraInputsManager {
  36713. /**
  36714. * Add virtual joystick input support to the input manager.
  36715. * @returns the current input manager
  36716. */
  36717. addVirtualJoystick(): FreeCameraInputsManager;
  36718. }
  36719. }
  36720. /**
  36721. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  36722. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36723. */
  36724. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  36725. /**
  36726. * Defines the camera the input is attached to.
  36727. */
  36728. camera: FreeCamera;
  36729. private _leftjoystick;
  36730. private _rightjoystick;
  36731. /**
  36732. * Gets the left stick of the virtual joystick.
  36733. * @returns The virtual Joystick
  36734. */
  36735. getLeftJoystick(): VirtualJoystick;
  36736. /**
  36737. * Gets the right stick of the virtual joystick.
  36738. * @returns The virtual Joystick
  36739. */
  36740. getRightJoystick(): VirtualJoystick;
  36741. /**
  36742. * Update the current camera state depending on the inputs that have been used this frame.
  36743. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36744. */
  36745. checkInputs(): void;
  36746. /**
  36747. * Attach the input controls to a specific dom element to get the input from.
  36748. * @param element Defines the element the controls should be listened from
  36749. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36750. */
  36751. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36752. /**
  36753. * Detach the current controls from the specified dom element.
  36754. * @param element Defines the element to stop listening the inputs from
  36755. */
  36756. detachControl(element: Nullable<HTMLElement>): void;
  36757. /**
  36758. * Gets the class name of the current intput.
  36759. * @returns the class name
  36760. */
  36761. getClassName(): string;
  36762. /**
  36763. * Get the friendly name associated with the input class.
  36764. * @returns the input friendly name
  36765. */
  36766. getSimpleName(): string;
  36767. }
  36768. }
  36769. declare module "babylonjs/Cameras/Inputs/index" {
  36770. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  36771. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  36772. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  36773. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  36774. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  36775. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  36776. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  36777. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  36778. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  36779. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  36780. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  36781. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  36782. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  36783. }
  36784. declare module "babylonjs/Cameras/touchCamera" {
  36785. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  36786. import { Scene } from "babylonjs/scene";
  36787. import { Vector3 } from "babylonjs/Maths/math";
  36788. /**
  36789. * This represents a FPS type of camera controlled by touch.
  36790. * This is like a universal camera minus the Gamepad controls.
  36791. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36792. */
  36793. export class TouchCamera extends FreeCamera {
  36794. /**
  36795. * Defines the touch sensibility for rotation.
  36796. * The higher the faster.
  36797. */
  36798. touchAngularSensibility: number;
  36799. /**
  36800. * Defines the touch sensibility for move.
  36801. * The higher the faster.
  36802. */
  36803. touchMoveSensibility: number;
  36804. /**
  36805. * Instantiates a new touch camera.
  36806. * This represents a FPS type of camera controlled by touch.
  36807. * This is like a universal camera minus the Gamepad controls.
  36808. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36809. * @param name Define the name of the camera in the scene
  36810. * @param position Define the start position of the camera in the scene
  36811. * @param scene Define the scene the camera belongs to
  36812. */
  36813. constructor(name: string, position: Vector3, scene: Scene);
  36814. /**
  36815. * Gets the current object class name.
  36816. * @return the class name
  36817. */
  36818. getClassName(): string;
  36819. /** @hidden */
  36820. _setupInputs(): void;
  36821. }
  36822. }
  36823. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  36824. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  36825. import { Scene } from "babylonjs/scene";
  36826. import { Vector3, Axis } from "babylonjs/Maths/math";
  36827. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  36828. /**
  36829. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  36830. * being tilted forward or back and left or right.
  36831. */
  36832. export class DeviceOrientationCamera extends FreeCamera {
  36833. private _initialQuaternion;
  36834. private _quaternionCache;
  36835. /**
  36836. * Creates a new device orientation camera
  36837. * @param name The name of the camera
  36838. * @param position The start position camera
  36839. * @param scene The scene the camera belongs to
  36840. */
  36841. constructor(name: string, position: Vector3, scene: Scene);
  36842. /**
  36843. * Gets the current instance class name ("DeviceOrientationCamera").
  36844. * This helps avoiding instanceof at run time.
  36845. * @returns the class name
  36846. */
  36847. getClassName(): string;
  36848. /**
  36849. * @hidden
  36850. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  36851. */
  36852. _checkInputs(): void;
  36853. /**
  36854. * Reset the camera to its default orientation on the specified axis only.
  36855. * @param axis The axis to reset
  36856. */
  36857. resetToCurrentRotation(axis?: Axis): void;
  36858. }
  36859. }
  36860. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  36861. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36862. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36863. import { Nullable } from "babylonjs/types";
  36864. /**
  36865. * Manage the keyboard inputs to control the movement of a follow camera.
  36866. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36867. */
  36868. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  36869. /**
  36870. * Defines the camera the input is attached to.
  36871. */
  36872. camera: FollowCamera;
  36873. /**
  36874. * Defines the list of key codes associated with the up action (increase heightOffset)
  36875. */
  36876. keysHeightOffsetIncr: number[];
  36877. /**
  36878. * Defines the list of key codes associated with the down action (decrease heightOffset)
  36879. */
  36880. keysHeightOffsetDecr: number[];
  36881. /**
  36882. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  36883. */
  36884. keysHeightOffsetModifierAlt: boolean;
  36885. /**
  36886. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  36887. */
  36888. keysHeightOffsetModifierCtrl: boolean;
  36889. /**
  36890. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  36891. */
  36892. keysHeightOffsetModifierShift: boolean;
  36893. /**
  36894. * Defines the list of key codes associated with the left action (increase rotationOffset)
  36895. */
  36896. keysRotationOffsetIncr: number[];
  36897. /**
  36898. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  36899. */
  36900. keysRotationOffsetDecr: number[];
  36901. /**
  36902. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  36903. */
  36904. keysRotationOffsetModifierAlt: boolean;
  36905. /**
  36906. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  36907. */
  36908. keysRotationOffsetModifierCtrl: boolean;
  36909. /**
  36910. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  36911. */
  36912. keysRotationOffsetModifierShift: boolean;
  36913. /**
  36914. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  36915. */
  36916. keysRadiusIncr: number[];
  36917. /**
  36918. * Defines the list of key codes associated with the zoom-out action (increase radius)
  36919. */
  36920. keysRadiusDecr: number[];
  36921. /**
  36922. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  36923. */
  36924. keysRadiusModifierAlt: boolean;
  36925. /**
  36926. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  36927. */
  36928. keysRadiusModifierCtrl: boolean;
  36929. /**
  36930. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  36931. */
  36932. keysRadiusModifierShift: boolean;
  36933. /**
  36934. * Defines the rate of change of heightOffset.
  36935. */
  36936. heightSensibility: number;
  36937. /**
  36938. * Defines the rate of change of rotationOffset.
  36939. */
  36940. rotationSensibility: number;
  36941. /**
  36942. * Defines the rate of change of radius.
  36943. */
  36944. radiusSensibility: number;
  36945. private _keys;
  36946. private _ctrlPressed;
  36947. private _altPressed;
  36948. private _shiftPressed;
  36949. private _onCanvasBlurObserver;
  36950. private _onKeyboardObserver;
  36951. private _engine;
  36952. private _scene;
  36953. /**
  36954. * Attach the input controls to a specific dom element to get the input from.
  36955. * @param element Defines the element the controls should be listened from
  36956. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36957. */
  36958. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36959. /**
  36960. * Detach the current controls from the specified dom element.
  36961. * @param element Defines the element to stop listening the inputs from
  36962. */
  36963. detachControl(element: Nullable<HTMLElement>): void;
  36964. /**
  36965. * Update the current camera state depending on the inputs that have been used this frame.
  36966. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36967. */
  36968. checkInputs(): void;
  36969. /**
  36970. * Gets the class name of the current input.
  36971. * @returns the class name
  36972. */
  36973. getClassName(): string;
  36974. /**
  36975. * Get the friendly name associated with the input class.
  36976. * @returns the input friendly name
  36977. */
  36978. getSimpleName(): string;
  36979. /**
  36980. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36981. * allow modification of the heightOffset value.
  36982. */
  36983. private _modifierHeightOffset;
  36984. /**
  36985. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36986. * allow modification of the rotationOffset value.
  36987. */
  36988. private _modifierRotationOffset;
  36989. /**
  36990. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36991. * allow modification of the radius value.
  36992. */
  36993. private _modifierRadius;
  36994. }
  36995. }
  36996. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  36997. import { Nullable } from "babylonjs/types";
  36998. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36999. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37000. /**
  37001. * Manage the mouse wheel inputs to control a follow camera.
  37002. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37003. */
  37004. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37005. /**
  37006. * Defines the camera the input is attached to.
  37007. */
  37008. camera: FollowCamera;
  37009. /**
  37010. * Moue wheel controls zoom. (Moue wheel modifies camera.radius value.)
  37011. */
  37012. axisControlRadius: boolean;
  37013. /**
  37014. * Moue wheel controls height. (Moue wheel modifies camera.heightOffset value.)
  37015. */
  37016. axisControlHeight: boolean;
  37017. /**
  37018. * Moue wheel controls angle. (Moue wheel modifies camera.rotationOffset value.)
  37019. */
  37020. axisControlRotation: boolean;
  37021. /**
  37022. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37023. * relation to mouseWheel events.
  37024. */
  37025. wheelPrecision: number;
  37026. /**
  37027. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37028. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37029. */
  37030. wheelDeltaPercentage: number;
  37031. private _wheel;
  37032. private _observer;
  37033. /**
  37034. * Attach the input controls to a specific dom element to get the input from.
  37035. * @param element Defines the element the controls should be listened from
  37036. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37037. */
  37038. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37039. /**
  37040. * Detach the current controls from the specified dom element.
  37041. * @param element Defines the element to stop listening the inputs from
  37042. */
  37043. detachControl(element: Nullable<HTMLElement>): void;
  37044. /**
  37045. * Gets the class name of the current intput.
  37046. * @returns the class name
  37047. */
  37048. getClassName(): string;
  37049. /**
  37050. * Get the friendly name associated with the input class.
  37051. * @returns the input friendly name
  37052. */
  37053. getSimpleName(): string;
  37054. }
  37055. }
  37056. declare module "babylonjs/Cameras/followCameraInputsManager" {
  37057. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37058. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37059. /**
  37060. * Default Inputs manager for the FollowCamera.
  37061. * It groups all the default supported inputs for ease of use.
  37062. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37063. */
  37064. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37065. /**
  37066. * Instantiates a new FollowCameraInputsManager.
  37067. * @param camera Defines the camera the inputs belong to
  37068. */
  37069. constructor(camera: FollowCamera);
  37070. /**
  37071. * Add keyboard input support to the input manager.
  37072. * @returns the current input manager
  37073. */
  37074. addKeyboard(): FollowCameraInputsManager;
  37075. /**
  37076. * Add mouse wheel input support to the input manager.
  37077. * @returns the current input manager
  37078. */
  37079. addMouseWheel(): FollowCameraInputsManager;
  37080. /**
  37081. * Add pointers input support to the input manager.
  37082. * @returns the current input manager
  37083. */
  37084. addPointers(): FollowCameraInputsManager;
  37085. /**
  37086. * Add orientation input support to the input manager.
  37087. * @returns the current input manager
  37088. */
  37089. addVRDeviceOrientation(): FollowCameraInputsManager;
  37090. }
  37091. }
  37092. declare module "babylonjs/Cameras/followCamera" {
  37093. import { Nullable } from "babylonjs/types";
  37094. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37095. import { Scene } from "babylonjs/scene";
  37096. import { Vector3 } from "babylonjs/Maths/math";
  37097. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37098. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  37099. /**
  37100. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37101. * an arc rotate version arcFollowCamera are available.
  37102. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37103. */
  37104. export class FollowCamera extends TargetCamera {
  37105. /**
  37106. * Distance the follow camera should follow an object at
  37107. */
  37108. radius: number;
  37109. /**
  37110. * Minimum allowed distance of the camera to the axis of rotation
  37111. * (The camera can not get closer).
  37112. * This can help limiting how the Camera is able to move in the scene.
  37113. */
  37114. lowerRadiusLimit: Nullable<number>;
  37115. /**
  37116. * Maximum allowed distance of the camera to the axis of rotation
  37117. * (The camera can not get further).
  37118. * This can help limiting how the Camera is able to move in the scene.
  37119. */
  37120. upperRadiusLimit: Nullable<number>;
  37121. /**
  37122. * Define a rotation offset between the camera and the object it follows
  37123. */
  37124. rotationOffset: number;
  37125. /**
  37126. * Minimum allowed angle to camera position relative to target object.
  37127. * This can help limiting how the Camera is able to move in the scene.
  37128. */
  37129. lowerRotationOffsetLimit: Nullable<number>;
  37130. /**
  37131. * Maximum allowed angle to camera position relative to target object.
  37132. * This can help limiting how the Camera is able to move in the scene.
  37133. */
  37134. upperRotationOffsetLimit: Nullable<number>;
  37135. /**
  37136. * Define a height offset between the camera and the object it follows.
  37137. * It can help following an object from the top (like a car chaing a plane)
  37138. */
  37139. heightOffset: number;
  37140. /**
  37141. * Minimum allowed height of camera position relative to target object.
  37142. * This can help limiting how the Camera is able to move in the scene.
  37143. */
  37144. lowerHeightOffsetLimit: Nullable<number>;
  37145. /**
  37146. * Maximum allowed height of camera position relative to target object.
  37147. * This can help limiting how the Camera is able to move in the scene.
  37148. */
  37149. upperHeightOffsetLimit: Nullable<number>;
  37150. /**
  37151. * Define how fast the camera can accelerate to follow it s target.
  37152. */
  37153. cameraAcceleration: number;
  37154. /**
  37155. * Define the speed limit of the camera following an object.
  37156. */
  37157. maxCameraSpeed: number;
  37158. /**
  37159. * Define the target of the camera.
  37160. */
  37161. lockedTarget: Nullable<AbstractMesh>;
  37162. /**
  37163. * Defines the input associated with the camera.
  37164. */
  37165. inputs: FollowCameraInputsManager;
  37166. /**
  37167. * Instantiates the follow camera.
  37168. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37169. * @param name Define the name of the camera in the scene
  37170. * @param position Define the position of the camera
  37171. * @param scene Define the scene the camera belong to
  37172. * @param lockedTarget Define the target of the camera
  37173. */
  37174. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37175. private _follow;
  37176. /**
  37177. * Attached controls to the current camera.
  37178. * @param element Defines the element the controls should be listened from
  37179. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37180. */
  37181. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37182. /**
  37183. * Detach the current controls from the camera.
  37184. * The camera will stop reacting to inputs.
  37185. * @param element Defines the element to stop listening the inputs from
  37186. */
  37187. detachControl(element: HTMLElement): void;
  37188. /** @hidden */
  37189. _checkInputs(): void;
  37190. private _checkLimits;
  37191. /**
  37192. * Gets the camera class name.
  37193. * @returns the class name
  37194. */
  37195. getClassName(): string;
  37196. }
  37197. /**
  37198. * Arc Rotate version of the follow camera.
  37199. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37200. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37201. */
  37202. export class ArcFollowCamera extends TargetCamera {
  37203. /** The longitudinal angle of the camera */
  37204. alpha: number;
  37205. /** The latitudinal angle of the camera */
  37206. beta: number;
  37207. /** The radius of the camera from its target */
  37208. radius: number;
  37209. /** Define the camera target (the messh it should follow) */
  37210. target: Nullable<AbstractMesh>;
  37211. private _cartesianCoordinates;
  37212. /**
  37213. * Instantiates a new ArcFollowCamera
  37214. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37215. * @param name Define the name of the camera
  37216. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37217. * @param beta Define the rotation angle of the camera around the elevation axis
  37218. * @param radius Define the radius of the camera from its target point
  37219. * @param target Define the target of the camera
  37220. * @param scene Define the scene the camera belongs to
  37221. */
  37222. constructor(name: string,
  37223. /** The longitudinal angle of the camera */
  37224. alpha: number,
  37225. /** The latitudinal angle of the camera */
  37226. beta: number,
  37227. /** The radius of the camera from its target */
  37228. radius: number,
  37229. /** Define the camera target (the messh it should follow) */
  37230. target: Nullable<AbstractMesh>, scene: Scene);
  37231. private _follow;
  37232. /** @hidden */
  37233. _checkInputs(): void;
  37234. /**
  37235. * Returns the class name of the object.
  37236. * It is mostly used internally for serialization purposes.
  37237. */
  37238. getClassName(): string;
  37239. }
  37240. }
  37241. declare module "babylonjs/Cameras/universalCamera" {
  37242. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  37243. import { Scene } from "babylonjs/scene";
  37244. import { Vector3 } from "babylonjs/Maths/math";
  37245. /**
  37246. * 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,
  37247. * which still works and will still be found in many Playgrounds.
  37248. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37249. */
  37250. export class UniversalCamera extends TouchCamera {
  37251. /**
  37252. * Defines the gamepad rotation sensiblity.
  37253. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37254. */
  37255. gamepadAngularSensibility: number;
  37256. /**
  37257. * Defines the gamepad move sensiblity.
  37258. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37259. */
  37260. gamepadMoveSensibility: number;
  37261. /**
  37262. * 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,
  37263. * which still works and will still be found in many Playgrounds.
  37264. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37265. * @param name Define the name of the camera in the scene
  37266. * @param position Define the start position of the camera in the scene
  37267. * @param scene Define the scene the camera belongs to
  37268. */
  37269. constructor(name: string, position: Vector3, scene: Scene);
  37270. /**
  37271. * Gets the current object class name.
  37272. * @return the class name
  37273. */
  37274. getClassName(): string;
  37275. }
  37276. }
  37277. declare module "babylonjs/Cameras/gamepadCamera" {
  37278. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37279. import { Scene } from "babylonjs/scene";
  37280. import { Vector3 } from "babylonjs/Maths/math";
  37281. /**
  37282. * This represents a FPS type of camera. This is only here for back compat purpose.
  37283. * Please use the UniversalCamera instead as both are identical.
  37284. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37285. */
  37286. export class GamepadCamera extends UniversalCamera {
  37287. /**
  37288. * Instantiates a new Gamepad Camera
  37289. * This represents a FPS type of camera. This is only here for back compat purpose.
  37290. * Please use the UniversalCamera instead as both are identical.
  37291. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37292. * @param name Define the name of the camera in the scene
  37293. * @param position Define the start position of the camera in the scene
  37294. * @param scene Define the scene the camera belongs to
  37295. */
  37296. constructor(name: string, position: Vector3, scene: Scene);
  37297. /**
  37298. * Gets the current object class name.
  37299. * @return the class name
  37300. */
  37301. getClassName(): string;
  37302. }
  37303. }
  37304. declare module "babylonjs/Shaders/pass.fragment" {
  37305. /** @hidden */
  37306. export var passPixelShader: {
  37307. name: string;
  37308. shader: string;
  37309. };
  37310. }
  37311. declare module "babylonjs/Shaders/passCube.fragment" {
  37312. /** @hidden */
  37313. export var passCubePixelShader: {
  37314. name: string;
  37315. shader: string;
  37316. };
  37317. }
  37318. declare module "babylonjs/PostProcesses/passPostProcess" {
  37319. import { Nullable } from "babylonjs/types";
  37320. import { Camera } from "babylonjs/Cameras/camera";
  37321. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  37322. import { Engine } from "babylonjs/Engines/engine";
  37323. import "babylonjs/Shaders/pass.fragment";
  37324. import "babylonjs/Shaders/passCube.fragment";
  37325. /**
  37326. * PassPostProcess which produces an output the same as it's input
  37327. */
  37328. export class PassPostProcess extends PostProcess {
  37329. /**
  37330. * Creates the PassPostProcess
  37331. * @param name The name of the effect.
  37332. * @param options The required width/height ratio to downsize to before computing the render pass.
  37333. * @param camera The camera to apply the render pass to.
  37334. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37335. * @param engine The engine which the post process will be applied. (default: current engine)
  37336. * @param reusable If the post process can be reused on the same frame. (default: false)
  37337. * @param textureType The type of texture to be used when performing the post processing.
  37338. * @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)
  37339. */
  37340. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37341. }
  37342. /**
  37343. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  37344. */
  37345. export class PassCubePostProcess extends PostProcess {
  37346. private _face;
  37347. /**
  37348. * Gets or sets the cube face to display.
  37349. * * 0 is +X
  37350. * * 1 is -X
  37351. * * 2 is +Y
  37352. * * 3 is -Y
  37353. * * 4 is +Z
  37354. * * 5 is -Z
  37355. */
  37356. face: number;
  37357. /**
  37358. * Creates the PassCubePostProcess
  37359. * @param name The name of the effect.
  37360. * @param options The required width/height ratio to downsize to before computing the render pass.
  37361. * @param camera The camera to apply the render pass to.
  37362. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37363. * @param engine The engine which the post process will be applied. (default: current engine)
  37364. * @param reusable If the post process can be reused on the same frame. (default: false)
  37365. * @param textureType The type of texture to be used when performing the post processing.
  37366. * @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)
  37367. */
  37368. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37369. }
  37370. }
  37371. declare module "babylonjs/Shaders/anaglyph.fragment" {
  37372. /** @hidden */
  37373. export var anaglyphPixelShader: {
  37374. name: string;
  37375. shader: string;
  37376. };
  37377. }
  37378. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  37379. import { Engine } from "babylonjs/Engines/engine";
  37380. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  37381. import { Camera } from "babylonjs/Cameras/camera";
  37382. import "babylonjs/Shaders/anaglyph.fragment";
  37383. /**
  37384. * Postprocess used to generate anaglyphic rendering
  37385. */
  37386. export class AnaglyphPostProcess extends PostProcess {
  37387. private _passedProcess;
  37388. /**
  37389. * Creates a new AnaglyphPostProcess
  37390. * @param name defines postprocess name
  37391. * @param options defines creation options or target ratio scale
  37392. * @param rigCameras defines cameras using this postprocess
  37393. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  37394. * @param engine defines hosting engine
  37395. * @param reusable defines if the postprocess will be reused multiple times per frame
  37396. */
  37397. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  37398. }
  37399. }
  37400. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  37401. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  37402. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37403. import { Scene } from "babylonjs/scene";
  37404. import { Vector3 } from "babylonjs/Maths/math";
  37405. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37406. /**
  37407. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  37408. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37409. */
  37410. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  37411. /**
  37412. * Creates a new AnaglyphArcRotateCamera
  37413. * @param name defines camera name
  37414. * @param alpha defines alpha angle (in radians)
  37415. * @param beta defines beta angle (in radians)
  37416. * @param radius defines radius
  37417. * @param target defines camera target
  37418. * @param interaxialDistance defines distance between each color axis
  37419. * @param scene defines the hosting scene
  37420. */
  37421. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  37422. /**
  37423. * Gets camera class name
  37424. * @returns AnaglyphArcRotateCamera
  37425. */
  37426. getClassName(): string;
  37427. }
  37428. }
  37429. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  37430. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37431. import { Scene } from "babylonjs/scene";
  37432. import { Vector3 } from "babylonjs/Maths/math";
  37433. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37434. /**
  37435. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  37436. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37437. */
  37438. export class AnaglyphFreeCamera extends FreeCamera {
  37439. /**
  37440. * Creates a new AnaglyphFreeCamera
  37441. * @param name defines camera name
  37442. * @param position defines initial position
  37443. * @param interaxialDistance defines distance between each color axis
  37444. * @param scene defines the hosting scene
  37445. */
  37446. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37447. /**
  37448. * Gets camera class name
  37449. * @returns AnaglyphFreeCamera
  37450. */
  37451. getClassName(): string;
  37452. }
  37453. }
  37454. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  37455. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  37456. import { Scene } from "babylonjs/scene";
  37457. import { Vector3 } from "babylonjs/Maths/math";
  37458. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37459. /**
  37460. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  37461. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37462. */
  37463. export class AnaglyphGamepadCamera extends GamepadCamera {
  37464. /**
  37465. * Creates a new AnaglyphGamepadCamera
  37466. * @param name defines camera name
  37467. * @param position defines initial position
  37468. * @param interaxialDistance defines distance between each color axis
  37469. * @param scene defines the hosting scene
  37470. */
  37471. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37472. /**
  37473. * Gets camera class name
  37474. * @returns AnaglyphGamepadCamera
  37475. */
  37476. getClassName(): string;
  37477. }
  37478. }
  37479. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  37480. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37481. import { Scene } from "babylonjs/scene";
  37482. import { Vector3 } from "babylonjs/Maths/math";
  37483. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37484. /**
  37485. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  37486. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37487. */
  37488. export class AnaglyphUniversalCamera extends UniversalCamera {
  37489. /**
  37490. * Creates a new AnaglyphUniversalCamera
  37491. * @param name defines camera name
  37492. * @param position defines initial position
  37493. * @param interaxialDistance defines distance between each color axis
  37494. * @param scene defines the hosting scene
  37495. */
  37496. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37497. /**
  37498. * Gets camera class name
  37499. * @returns AnaglyphUniversalCamera
  37500. */
  37501. getClassName(): string;
  37502. }
  37503. }
  37504. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  37505. /** @hidden */
  37506. export var stereoscopicInterlacePixelShader: {
  37507. name: string;
  37508. shader: string;
  37509. };
  37510. }
  37511. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  37512. import { Camera } from "babylonjs/Cameras/camera";
  37513. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  37514. import { Engine } from "babylonjs/Engines/engine";
  37515. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  37516. /**
  37517. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  37518. */
  37519. export class StereoscopicInterlacePostProcess extends PostProcess {
  37520. private _stepSize;
  37521. private _passedProcess;
  37522. /**
  37523. * Initializes a StereoscopicInterlacePostProcess
  37524. * @param name The name of the effect.
  37525. * @param rigCameras The rig cameras to be appled to the post process
  37526. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  37527. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37528. * @param engine The engine which the post process will be applied. (default: current engine)
  37529. * @param reusable If the post process can be reused on the same frame. (default: false)
  37530. */
  37531. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  37532. }
  37533. }
  37534. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  37535. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  37536. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37537. import { Scene } from "babylonjs/scene";
  37538. import { Vector3 } from "babylonjs/Maths/math";
  37539. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37540. /**
  37541. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  37542. * @see http://doc.babylonjs.com/features/cameras
  37543. */
  37544. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  37545. /**
  37546. * Creates a new StereoscopicArcRotateCamera
  37547. * @param name defines camera name
  37548. * @param alpha defines alpha angle (in radians)
  37549. * @param beta defines beta angle (in radians)
  37550. * @param radius defines radius
  37551. * @param target defines camera target
  37552. * @param interaxialDistance defines distance between each color axis
  37553. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37554. * @param scene defines the hosting scene
  37555. */
  37556. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37557. /**
  37558. * Gets camera class name
  37559. * @returns StereoscopicArcRotateCamera
  37560. */
  37561. getClassName(): string;
  37562. }
  37563. }
  37564. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  37565. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37566. import { Scene } from "babylonjs/scene";
  37567. import { Vector3 } from "babylonjs/Maths/math";
  37568. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37569. /**
  37570. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  37571. * @see http://doc.babylonjs.com/features/cameras
  37572. */
  37573. export class StereoscopicFreeCamera extends FreeCamera {
  37574. /**
  37575. * Creates a new StereoscopicFreeCamera
  37576. * @param name defines camera name
  37577. * @param position defines initial position
  37578. * @param interaxialDistance defines distance between each color axis
  37579. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37580. * @param scene defines the hosting scene
  37581. */
  37582. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37583. /**
  37584. * Gets camera class name
  37585. * @returns StereoscopicFreeCamera
  37586. */
  37587. getClassName(): string;
  37588. }
  37589. }
  37590. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  37591. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  37592. import { Scene } from "babylonjs/scene";
  37593. import { Vector3 } from "babylonjs/Maths/math";
  37594. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37595. /**
  37596. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  37597. * @see http://doc.babylonjs.com/features/cameras
  37598. */
  37599. export class StereoscopicGamepadCamera extends GamepadCamera {
  37600. /**
  37601. * Creates a new StereoscopicGamepadCamera
  37602. * @param name defines camera name
  37603. * @param position defines initial position
  37604. * @param interaxialDistance defines distance between each color axis
  37605. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37606. * @param scene defines the hosting scene
  37607. */
  37608. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37609. /**
  37610. * Gets camera class name
  37611. * @returns StereoscopicGamepadCamera
  37612. */
  37613. getClassName(): string;
  37614. }
  37615. }
  37616. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  37617. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37618. import { Scene } from "babylonjs/scene";
  37619. import { Vector3 } from "babylonjs/Maths/math";
  37620. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37621. /**
  37622. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  37623. * @see http://doc.babylonjs.com/features/cameras
  37624. */
  37625. export class StereoscopicUniversalCamera extends UniversalCamera {
  37626. /**
  37627. * Creates a new StereoscopicUniversalCamera
  37628. * @param name defines camera name
  37629. * @param position defines initial position
  37630. * @param interaxialDistance defines distance between each color axis
  37631. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37632. * @param scene defines the hosting scene
  37633. */
  37634. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37635. /**
  37636. * Gets camera class name
  37637. * @returns StereoscopicUniversalCamera
  37638. */
  37639. getClassName(): string;
  37640. }
  37641. }
  37642. declare module "babylonjs/Cameras/Stereoscopic/index" {
  37643. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  37644. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  37645. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  37646. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  37647. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  37648. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  37649. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  37650. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  37651. }
  37652. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  37653. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37654. import { Scene } from "babylonjs/scene";
  37655. import { Vector3 } from "babylonjs/Maths/math";
  37656. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  37657. /**
  37658. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  37659. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37660. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37661. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37662. */
  37663. export class VirtualJoysticksCamera extends FreeCamera {
  37664. /**
  37665. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  37666. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37667. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37668. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37669. * @param name Define the name of the camera in the scene
  37670. * @param position Define the start position of the camera in the scene
  37671. * @param scene Define the scene the camera belongs to
  37672. */
  37673. constructor(name: string, position: Vector3, scene: Scene);
  37674. /**
  37675. * Gets the current object class name.
  37676. * @return the class name
  37677. */
  37678. getClassName(): string;
  37679. }
  37680. }
  37681. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  37682. import { Matrix } from "babylonjs/Maths/math";
  37683. /**
  37684. * This represents all the required metrics to create a VR camera.
  37685. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  37686. */
  37687. export class VRCameraMetrics {
  37688. /**
  37689. * Define the horizontal resolution off the screen.
  37690. */
  37691. hResolution: number;
  37692. /**
  37693. * Define the vertical resolution off the screen.
  37694. */
  37695. vResolution: number;
  37696. /**
  37697. * Define the horizontal screen size.
  37698. */
  37699. hScreenSize: number;
  37700. /**
  37701. * Define the vertical screen size.
  37702. */
  37703. vScreenSize: number;
  37704. /**
  37705. * Define the vertical screen center position.
  37706. */
  37707. vScreenCenter: number;
  37708. /**
  37709. * Define the distance of the eyes to the screen.
  37710. */
  37711. eyeToScreenDistance: number;
  37712. /**
  37713. * Define the distance between both lenses
  37714. */
  37715. lensSeparationDistance: number;
  37716. /**
  37717. * Define the distance between both viewer's eyes.
  37718. */
  37719. interpupillaryDistance: number;
  37720. /**
  37721. * Define the distortion factor of the VR postprocess.
  37722. * Please, touch with care.
  37723. */
  37724. distortionK: number[];
  37725. /**
  37726. * Define the chromatic aberration correction factors for the VR post process.
  37727. */
  37728. chromaAbCorrection: number[];
  37729. /**
  37730. * Define the scale factor of the post process.
  37731. * The smaller the better but the slower.
  37732. */
  37733. postProcessScaleFactor: number;
  37734. /**
  37735. * Define an offset for the lens center.
  37736. */
  37737. lensCenterOffset: number;
  37738. /**
  37739. * Define if the current vr camera should compensate the distortion of the lense or not.
  37740. */
  37741. compensateDistortion: boolean;
  37742. /**
  37743. * Gets the rendering aspect ratio based on the provided resolutions.
  37744. */
  37745. readonly aspectRatio: number;
  37746. /**
  37747. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  37748. */
  37749. readonly aspectRatioFov: number;
  37750. /**
  37751. * @hidden
  37752. */
  37753. readonly leftHMatrix: Matrix;
  37754. /**
  37755. * @hidden
  37756. */
  37757. readonly rightHMatrix: Matrix;
  37758. /**
  37759. * @hidden
  37760. */
  37761. readonly leftPreViewMatrix: Matrix;
  37762. /**
  37763. * @hidden
  37764. */
  37765. readonly rightPreViewMatrix: Matrix;
  37766. /**
  37767. * Get the default VRMetrics based on the most generic setup.
  37768. * @returns the default vr metrics
  37769. */
  37770. static GetDefault(): VRCameraMetrics;
  37771. }
  37772. }
  37773. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  37774. /** @hidden */
  37775. export var vrDistortionCorrectionPixelShader: {
  37776. name: string;
  37777. shader: string;
  37778. };
  37779. }
  37780. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  37781. import { Camera } from "babylonjs/Cameras/camera";
  37782. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  37783. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  37784. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  37785. /**
  37786. * VRDistortionCorrectionPostProcess used for mobile VR
  37787. */
  37788. export class VRDistortionCorrectionPostProcess extends PostProcess {
  37789. private _isRightEye;
  37790. private _distortionFactors;
  37791. private _postProcessScaleFactor;
  37792. private _lensCenterOffset;
  37793. private _scaleIn;
  37794. private _scaleFactor;
  37795. private _lensCenter;
  37796. /**
  37797. * Initializes the VRDistortionCorrectionPostProcess
  37798. * @param name The name of the effect.
  37799. * @param camera The camera to apply the render pass to.
  37800. * @param isRightEye If this is for the right eye distortion
  37801. * @param vrMetrics All the required metrics for the VR camera
  37802. */
  37803. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  37804. }
  37805. }
  37806. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  37807. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  37808. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37809. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  37810. import { Scene } from "babylonjs/scene";
  37811. import { Vector3 } from "babylonjs/Maths/math";
  37812. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  37813. import "babylonjs/Cameras/RigModes/vrRigMode";
  37814. /**
  37815. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  37816. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37817. */
  37818. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  37819. /**
  37820. * Creates a new VRDeviceOrientationArcRotateCamera
  37821. * @param name defines camera name
  37822. * @param alpha defines the camera rotation along the logitudinal axis
  37823. * @param beta defines the camera rotation along the latitudinal axis
  37824. * @param radius defines the camera distance from its target
  37825. * @param target defines the camera target
  37826. * @param scene defines the scene the camera belongs to
  37827. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37828. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37829. */
  37830. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37831. /**
  37832. * Gets camera class name
  37833. * @returns VRDeviceOrientationArcRotateCamera
  37834. */
  37835. getClassName(): string;
  37836. }
  37837. }
  37838. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  37839. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  37840. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  37841. import { Scene } from "babylonjs/scene";
  37842. import { Vector3 } from "babylonjs/Maths/math";
  37843. import "babylonjs/Cameras/RigModes/vrRigMode";
  37844. /**
  37845. * Camera used to simulate VR rendering (based on FreeCamera)
  37846. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37847. */
  37848. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  37849. /**
  37850. * Creates a new VRDeviceOrientationFreeCamera
  37851. * @param name defines camera name
  37852. * @param position defines the start position of the camera
  37853. * @param scene defines the scene the camera belongs to
  37854. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37855. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37856. */
  37857. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37858. /**
  37859. * Gets camera class name
  37860. * @returns VRDeviceOrientationFreeCamera
  37861. */
  37862. getClassName(): string;
  37863. }
  37864. }
  37865. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  37866. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  37867. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  37868. import { Scene } from "babylonjs/scene";
  37869. import { Vector3 } from "babylonjs/Maths/math";
  37870. /**
  37871. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  37872. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37873. */
  37874. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  37875. /**
  37876. * Creates a new VRDeviceOrientationGamepadCamera
  37877. * @param name defines camera name
  37878. * @param position defines the start position of the camera
  37879. * @param scene defines the scene the camera belongs to
  37880. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37881. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37882. */
  37883. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37884. /**
  37885. * Gets camera class name
  37886. * @returns VRDeviceOrientationGamepadCamera
  37887. */
  37888. getClassName(): string;
  37889. }
  37890. }
  37891. declare module "babylonjs/Gamepads/xboxGamepad" {
  37892. import { Observable } from "babylonjs/Misc/observable";
  37893. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37894. /**
  37895. * Defines supported buttons for XBox360 compatible gamepads
  37896. */
  37897. export enum Xbox360Button {
  37898. /** A */
  37899. A = 0,
  37900. /** B */
  37901. B = 1,
  37902. /** X */
  37903. X = 2,
  37904. /** Y */
  37905. Y = 3,
  37906. /** Start */
  37907. Start = 4,
  37908. /** Back */
  37909. Back = 5,
  37910. /** Left button */
  37911. LB = 6,
  37912. /** Right button */
  37913. RB = 7,
  37914. /** Left stick */
  37915. LeftStick = 8,
  37916. /** Right stick */
  37917. RightStick = 9
  37918. }
  37919. /** Defines values for XBox360 DPad */
  37920. export enum Xbox360Dpad {
  37921. /** Up */
  37922. Up = 0,
  37923. /** Down */
  37924. Down = 1,
  37925. /** Left */
  37926. Left = 2,
  37927. /** Right */
  37928. Right = 3
  37929. }
  37930. /**
  37931. * Defines a XBox360 gamepad
  37932. */
  37933. export class Xbox360Pad extends Gamepad {
  37934. private _leftTrigger;
  37935. private _rightTrigger;
  37936. private _onlefttriggerchanged;
  37937. private _onrighttriggerchanged;
  37938. private _onbuttondown;
  37939. private _onbuttonup;
  37940. private _ondpaddown;
  37941. private _ondpadup;
  37942. /** Observable raised when a button is pressed */
  37943. onButtonDownObservable: Observable<Xbox360Button>;
  37944. /** Observable raised when a button is released */
  37945. onButtonUpObservable: Observable<Xbox360Button>;
  37946. /** Observable raised when a pad is pressed */
  37947. onPadDownObservable: Observable<Xbox360Dpad>;
  37948. /** Observable raised when a pad is released */
  37949. onPadUpObservable: Observable<Xbox360Dpad>;
  37950. private _buttonA;
  37951. private _buttonB;
  37952. private _buttonX;
  37953. private _buttonY;
  37954. private _buttonBack;
  37955. private _buttonStart;
  37956. private _buttonLB;
  37957. private _buttonRB;
  37958. private _buttonLeftStick;
  37959. private _buttonRightStick;
  37960. private _dPadUp;
  37961. private _dPadDown;
  37962. private _dPadLeft;
  37963. private _dPadRight;
  37964. private _isXboxOnePad;
  37965. /**
  37966. * Creates a new XBox360 gamepad object
  37967. * @param id defines the id of this gamepad
  37968. * @param index defines its index
  37969. * @param gamepad defines the internal HTML gamepad object
  37970. * @param xboxOne defines if it is a XBox One gamepad
  37971. */
  37972. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37973. /**
  37974. * Defines the callback to call when left trigger is pressed
  37975. * @param callback defines the callback to use
  37976. */
  37977. onlefttriggerchanged(callback: (value: number) => void): void;
  37978. /**
  37979. * Defines the callback to call when right trigger is pressed
  37980. * @param callback defines the callback to use
  37981. */
  37982. onrighttriggerchanged(callback: (value: number) => void): void;
  37983. /**
  37984. * Gets the left trigger value
  37985. */
  37986. /**
  37987. * Sets the left trigger value
  37988. */
  37989. leftTrigger: number;
  37990. /**
  37991. * Gets the right trigger value
  37992. */
  37993. /**
  37994. * Sets the right trigger value
  37995. */
  37996. rightTrigger: number;
  37997. /**
  37998. * Defines the callback to call when a button is pressed
  37999. * @param callback defines the callback to use
  38000. */
  38001. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38002. /**
  38003. * Defines the callback to call when a button is released
  38004. * @param callback defines the callback to use
  38005. */
  38006. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38007. /**
  38008. * Defines the callback to call when a pad is pressed
  38009. * @param callback defines the callback to use
  38010. */
  38011. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38012. /**
  38013. * Defines the callback to call when a pad is released
  38014. * @param callback defines the callback to use
  38015. */
  38016. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38017. private _setButtonValue;
  38018. private _setDPadValue;
  38019. /**
  38020. * Gets the value of the `A` button
  38021. */
  38022. /**
  38023. * Sets the value of the `A` button
  38024. */
  38025. buttonA: number;
  38026. /**
  38027. * Gets the value of the `B` button
  38028. */
  38029. /**
  38030. * Sets the value of the `B` button
  38031. */
  38032. buttonB: number;
  38033. /**
  38034. * Gets the value of the `X` button
  38035. */
  38036. /**
  38037. * Sets the value of the `X` button
  38038. */
  38039. buttonX: number;
  38040. /**
  38041. * Gets the value of the `Y` button
  38042. */
  38043. /**
  38044. * Sets the value of the `Y` button
  38045. */
  38046. buttonY: number;
  38047. /**
  38048. * Gets the value of the `Start` button
  38049. */
  38050. /**
  38051. * Sets the value of the `Start` button
  38052. */
  38053. buttonStart: number;
  38054. /**
  38055. * Gets the value of the `Back` button
  38056. */
  38057. /**
  38058. * Sets the value of the `Back` button
  38059. */
  38060. buttonBack: number;
  38061. /**
  38062. * Gets the value of the `Left` button
  38063. */
  38064. /**
  38065. * Sets the value of the `Left` button
  38066. */
  38067. buttonLB: number;
  38068. /**
  38069. * Gets the value of the `Right` button
  38070. */
  38071. /**
  38072. * Sets the value of the `Right` button
  38073. */
  38074. buttonRB: number;
  38075. /**
  38076. * Gets the value of the Left joystick
  38077. */
  38078. /**
  38079. * Sets the value of the Left joystick
  38080. */
  38081. buttonLeftStick: number;
  38082. /**
  38083. * Gets the value of the Right joystick
  38084. */
  38085. /**
  38086. * Sets the value of the Right joystick
  38087. */
  38088. buttonRightStick: number;
  38089. /**
  38090. * Gets the value of D-pad up
  38091. */
  38092. /**
  38093. * Sets the value of D-pad up
  38094. */
  38095. dPadUp: number;
  38096. /**
  38097. * Gets the value of D-pad down
  38098. */
  38099. /**
  38100. * Sets the value of D-pad down
  38101. */
  38102. dPadDown: number;
  38103. /**
  38104. * Gets the value of D-pad left
  38105. */
  38106. /**
  38107. * Sets the value of D-pad left
  38108. */
  38109. dPadLeft: number;
  38110. /**
  38111. * Gets the value of D-pad right
  38112. */
  38113. /**
  38114. * Sets the value of D-pad right
  38115. */
  38116. dPadRight: number;
  38117. /**
  38118. * Force the gamepad to synchronize with device values
  38119. */
  38120. update(): void;
  38121. /**
  38122. * Disposes the gamepad
  38123. */
  38124. dispose(): void;
  38125. }
  38126. }
  38127. declare module "babylonjs/Materials/pushMaterial" {
  38128. import { Nullable } from "babylonjs/types";
  38129. import { Scene } from "babylonjs/scene";
  38130. import { Matrix } from "babylonjs/Maths/math";
  38131. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38132. import { Mesh } from "babylonjs/Meshes/mesh";
  38133. import { Material } from "babylonjs/Materials/material";
  38134. import { Effect } from "babylonjs/Materials/effect";
  38135. /**
  38136. * Base class of materials working in push mode in babylon JS
  38137. * @hidden
  38138. */
  38139. export class PushMaterial extends Material {
  38140. protected _activeEffect: Effect;
  38141. protected _normalMatrix: Matrix;
  38142. /**
  38143. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38144. * This means that the material can keep using a previous shader while a new one is being compiled.
  38145. * This is mostly used when shader parallel compilation is supported (true by default)
  38146. */
  38147. allowShaderHotSwapping: boolean;
  38148. constructor(name: string, scene: Scene);
  38149. getEffect(): Effect;
  38150. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38151. /**
  38152. * Binds the given world matrix to the active effect
  38153. *
  38154. * @param world the matrix to bind
  38155. */
  38156. bindOnlyWorldMatrix(world: Matrix): void;
  38157. /**
  38158. * Binds the given normal matrix to the active effect
  38159. *
  38160. * @param normalMatrix the matrix to bind
  38161. */
  38162. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38163. bind(world: Matrix, mesh?: Mesh): void;
  38164. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38165. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38166. }
  38167. }
  38168. declare module "babylonjs/Materials/materialFlags" {
  38169. /**
  38170. * This groups all the flags used to control the materials channel.
  38171. */
  38172. export class MaterialFlags {
  38173. private static _DiffuseTextureEnabled;
  38174. /**
  38175. * Are diffuse textures enabled in the application.
  38176. */
  38177. static DiffuseTextureEnabled: boolean;
  38178. private static _AmbientTextureEnabled;
  38179. /**
  38180. * Are ambient textures enabled in the application.
  38181. */
  38182. static AmbientTextureEnabled: boolean;
  38183. private static _OpacityTextureEnabled;
  38184. /**
  38185. * Are opacity textures enabled in the application.
  38186. */
  38187. static OpacityTextureEnabled: boolean;
  38188. private static _ReflectionTextureEnabled;
  38189. /**
  38190. * Are reflection textures enabled in the application.
  38191. */
  38192. static ReflectionTextureEnabled: boolean;
  38193. private static _EmissiveTextureEnabled;
  38194. /**
  38195. * Are emissive textures enabled in the application.
  38196. */
  38197. static EmissiveTextureEnabled: boolean;
  38198. private static _SpecularTextureEnabled;
  38199. /**
  38200. * Are specular textures enabled in the application.
  38201. */
  38202. static SpecularTextureEnabled: boolean;
  38203. private static _BumpTextureEnabled;
  38204. /**
  38205. * Are bump textures enabled in the application.
  38206. */
  38207. static BumpTextureEnabled: boolean;
  38208. private static _LightmapTextureEnabled;
  38209. /**
  38210. * Are lightmap textures enabled in the application.
  38211. */
  38212. static LightmapTextureEnabled: boolean;
  38213. private static _RefractionTextureEnabled;
  38214. /**
  38215. * Are refraction textures enabled in the application.
  38216. */
  38217. static RefractionTextureEnabled: boolean;
  38218. private static _ColorGradingTextureEnabled;
  38219. /**
  38220. * Are color grading textures enabled in the application.
  38221. */
  38222. static ColorGradingTextureEnabled: boolean;
  38223. private static _FresnelEnabled;
  38224. /**
  38225. * Are fresnels enabled in the application.
  38226. */
  38227. static FresnelEnabled: boolean;
  38228. private static _ClearCoatTextureEnabled;
  38229. /**
  38230. * Are clear coat textures enabled in the application.
  38231. */
  38232. static ClearCoatTextureEnabled: boolean;
  38233. private static _ClearCoatBumpTextureEnabled;
  38234. /**
  38235. * Are clear coat bump textures enabled in the application.
  38236. */
  38237. static ClearCoatBumpTextureEnabled: boolean;
  38238. private static _ClearCoatTintTextureEnabled;
  38239. /**
  38240. * Are clear coat tint textures enabled in the application.
  38241. */
  38242. static ClearCoatTintTextureEnabled: boolean;
  38243. }
  38244. }
  38245. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  38246. /** @hidden */
  38247. export var defaultFragmentDeclaration: {
  38248. name: string;
  38249. shader: string;
  38250. };
  38251. }
  38252. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  38253. /** @hidden */
  38254. export var defaultUboDeclaration: {
  38255. name: string;
  38256. shader: string;
  38257. };
  38258. }
  38259. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  38260. /** @hidden */
  38261. export var lightFragmentDeclaration: {
  38262. name: string;
  38263. shader: string;
  38264. };
  38265. }
  38266. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  38267. /** @hidden */
  38268. export var lightUboDeclaration: {
  38269. name: string;
  38270. shader: string;
  38271. };
  38272. }
  38273. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  38274. /** @hidden */
  38275. export var lightsFragmentFunctions: {
  38276. name: string;
  38277. shader: string;
  38278. };
  38279. }
  38280. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  38281. /** @hidden */
  38282. export var shadowsFragmentFunctions: {
  38283. name: string;
  38284. shader: string;
  38285. };
  38286. }
  38287. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  38288. /** @hidden */
  38289. export var fresnelFunction: {
  38290. name: string;
  38291. shader: string;
  38292. };
  38293. }
  38294. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  38295. /** @hidden */
  38296. export var reflectionFunction: {
  38297. name: string;
  38298. shader: string;
  38299. };
  38300. }
  38301. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  38302. /** @hidden */
  38303. export var bumpFragmentFunctions: {
  38304. name: string;
  38305. shader: string;
  38306. };
  38307. }
  38308. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  38309. /** @hidden */
  38310. export var logDepthDeclaration: {
  38311. name: string;
  38312. shader: string;
  38313. };
  38314. }
  38315. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  38316. /** @hidden */
  38317. export var bumpFragment: {
  38318. name: string;
  38319. shader: string;
  38320. };
  38321. }
  38322. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  38323. /** @hidden */
  38324. export var depthPrePass: {
  38325. name: string;
  38326. shader: string;
  38327. };
  38328. }
  38329. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  38330. /** @hidden */
  38331. export var lightFragment: {
  38332. name: string;
  38333. shader: string;
  38334. };
  38335. }
  38336. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  38337. /** @hidden */
  38338. export var logDepthFragment: {
  38339. name: string;
  38340. shader: string;
  38341. };
  38342. }
  38343. declare module "babylonjs/Shaders/default.fragment" {
  38344. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  38345. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  38346. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  38347. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  38348. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  38349. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  38350. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  38351. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  38352. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  38353. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  38354. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  38355. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  38356. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  38357. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  38358. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  38359. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  38360. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  38361. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  38362. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  38363. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  38364. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  38365. /** @hidden */
  38366. export var defaultPixelShader: {
  38367. name: string;
  38368. shader: string;
  38369. };
  38370. }
  38371. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  38372. /** @hidden */
  38373. export var defaultVertexDeclaration: {
  38374. name: string;
  38375. shader: string;
  38376. };
  38377. }
  38378. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  38379. /** @hidden */
  38380. export var bumpVertexDeclaration: {
  38381. name: string;
  38382. shader: string;
  38383. };
  38384. }
  38385. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  38386. /** @hidden */
  38387. export var bumpVertex: {
  38388. name: string;
  38389. shader: string;
  38390. };
  38391. }
  38392. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  38393. /** @hidden */
  38394. export var fogVertex: {
  38395. name: string;
  38396. shader: string;
  38397. };
  38398. }
  38399. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  38400. /** @hidden */
  38401. export var shadowsVertex: {
  38402. name: string;
  38403. shader: string;
  38404. };
  38405. }
  38406. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  38407. /** @hidden */
  38408. export var pointCloudVertex: {
  38409. name: string;
  38410. shader: string;
  38411. };
  38412. }
  38413. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  38414. /** @hidden */
  38415. export var logDepthVertex: {
  38416. name: string;
  38417. shader: string;
  38418. };
  38419. }
  38420. declare module "babylonjs/Shaders/default.vertex" {
  38421. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  38422. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  38423. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  38424. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  38425. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  38426. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  38427. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  38428. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  38429. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  38430. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  38431. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  38432. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  38433. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  38434. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  38435. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  38436. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  38437. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  38438. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  38439. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  38440. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  38441. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  38442. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  38443. /** @hidden */
  38444. export var defaultVertexShader: {
  38445. name: string;
  38446. shader: string;
  38447. };
  38448. }
  38449. declare module "babylonjs/Materials/standardMaterial" {
  38450. import { SmartArray } from "babylonjs/Misc/smartArray";
  38451. import { IAnimatable } from "babylonjs/Misc/tools";
  38452. import { Nullable } from "babylonjs/types";
  38453. import { Scene } from "babylonjs/scene";
  38454. import { Matrix, Color3 } from "babylonjs/Maths/math";
  38455. import { SubMesh } from "babylonjs/Meshes/subMesh";
  38456. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38457. import { Mesh } from "babylonjs/Meshes/mesh";
  38458. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  38459. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  38460. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  38461. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  38462. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  38463. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38464. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38465. import "babylonjs/Shaders/default.fragment";
  38466. import "babylonjs/Shaders/default.vertex";
  38467. /** @hidden */
  38468. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  38469. MAINUV1: boolean;
  38470. MAINUV2: boolean;
  38471. DIFFUSE: boolean;
  38472. DIFFUSEDIRECTUV: number;
  38473. AMBIENT: boolean;
  38474. AMBIENTDIRECTUV: number;
  38475. OPACITY: boolean;
  38476. OPACITYDIRECTUV: number;
  38477. OPACITYRGB: boolean;
  38478. REFLECTION: boolean;
  38479. EMISSIVE: boolean;
  38480. EMISSIVEDIRECTUV: number;
  38481. SPECULAR: boolean;
  38482. SPECULARDIRECTUV: number;
  38483. BUMP: boolean;
  38484. BUMPDIRECTUV: number;
  38485. PARALLAX: boolean;
  38486. PARALLAXOCCLUSION: boolean;
  38487. SPECULAROVERALPHA: boolean;
  38488. CLIPPLANE: boolean;
  38489. CLIPPLANE2: boolean;
  38490. CLIPPLANE3: boolean;
  38491. CLIPPLANE4: boolean;
  38492. ALPHATEST: boolean;
  38493. DEPTHPREPASS: boolean;
  38494. ALPHAFROMDIFFUSE: boolean;
  38495. POINTSIZE: boolean;
  38496. FOG: boolean;
  38497. SPECULARTERM: boolean;
  38498. DIFFUSEFRESNEL: boolean;
  38499. OPACITYFRESNEL: boolean;
  38500. REFLECTIONFRESNEL: boolean;
  38501. REFRACTIONFRESNEL: boolean;
  38502. EMISSIVEFRESNEL: boolean;
  38503. FRESNEL: boolean;
  38504. NORMAL: boolean;
  38505. UV1: boolean;
  38506. UV2: boolean;
  38507. VERTEXCOLOR: boolean;
  38508. VERTEXALPHA: boolean;
  38509. NUM_BONE_INFLUENCERS: number;
  38510. BonesPerMesh: number;
  38511. BONETEXTURE: boolean;
  38512. INSTANCES: boolean;
  38513. GLOSSINESS: boolean;
  38514. ROUGHNESS: boolean;
  38515. EMISSIVEASILLUMINATION: boolean;
  38516. LINKEMISSIVEWITHDIFFUSE: boolean;
  38517. REFLECTIONFRESNELFROMSPECULAR: boolean;
  38518. LIGHTMAP: boolean;
  38519. LIGHTMAPDIRECTUV: number;
  38520. OBJECTSPACE_NORMALMAP: boolean;
  38521. USELIGHTMAPASSHADOWMAP: boolean;
  38522. REFLECTIONMAP_3D: boolean;
  38523. REFLECTIONMAP_SPHERICAL: boolean;
  38524. REFLECTIONMAP_PLANAR: boolean;
  38525. REFLECTIONMAP_CUBIC: boolean;
  38526. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  38527. REFLECTIONMAP_PROJECTION: boolean;
  38528. REFLECTIONMAP_SKYBOX: boolean;
  38529. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  38530. REFLECTIONMAP_EXPLICIT: boolean;
  38531. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  38532. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  38533. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  38534. INVERTCUBICMAP: boolean;
  38535. LOGARITHMICDEPTH: boolean;
  38536. REFRACTION: boolean;
  38537. REFRACTIONMAP_3D: boolean;
  38538. REFLECTIONOVERALPHA: boolean;
  38539. TWOSIDEDLIGHTING: boolean;
  38540. SHADOWFLOAT: boolean;
  38541. MORPHTARGETS: boolean;
  38542. MORPHTARGETS_NORMAL: boolean;
  38543. MORPHTARGETS_TANGENT: boolean;
  38544. NUM_MORPH_INFLUENCERS: number;
  38545. NONUNIFORMSCALING: boolean;
  38546. PREMULTIPLYALPHA: boolean;
  38547. IMAGEPROCESSING: boolean;
  38548. VIGNETTE: boolean;
  38549. VIGNETTEBLENDMODEMULTIPLY: boolean;
  38550. VIGNETTEBLENDMODEOPAQUE: boolean;
  38551. TONEMAPPING: boolean;
  38552. TONEMAPPING_ACES: boolean;
  38553. CONTRAST: boolean;
  38554. COLORCURVES: boolean;
  38555. COLORGRADING: boolean;
  38556. COLORGRADING3D: boolean;
  38557. SAMPLER3DGREENDEPTH: boolean;
  38558. SAMPLER3DBGRMAP: boolean;
  38559. IMAGEPROCESSINGPOSTPROCESS: boolean;
  38560. /**
  38561. * If the reflection texture on this material is in linear color space
  38562. * @hidden
  38563. */
  38564. IS_REFLECTION_LINEAR: boolean;
  38565. /**
  38566. * If the refraction texture on this material is in linear color space
  38567. * @hidden
  38568. */
  38569. IS_REFRACTION_LINEAR: boolean;
  38570. EXPOSURE: boolean;
  38571. constructor();
  38572. setReflectionMode(modeToEnable: string): void;
  38573. }
  38574. /**
  38575. * This is the default material used in Babylon. It is the best trade off between quality
  38576. * and performances.
  38577. * @see http://doc.babylonjs.com/babylon101/materials
  38578. */
  38579. export class StandardMaterial extends PushMaterial {
  38580. private _diffuseTexture;
  38581. /**
  38582. * The basic texture of the material as viewed under a light.
  38583. */
  38584. diffuseTexture: Nullable<BaseTexture>;
  38585. private _ambientTexture;
  38586. /**
  38587. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  38588. */
  38589. ambientTexture: Nullable<BaseTexture>;
  38590. private _opacityTexture;
  38591. /**
  38592. * Define the transparency of the material from a texture.
  38593. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  38594. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  38595. */
  38596. opacityTexture: Nullable<BaseTexture>;
  38597. private _reflectionTexture;
  38598. /**
  38599. * Define the texture used to display the reflection.
  38600. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38601. */
  38602. reflectionTexture: Nullable<BaseTexture>;
  38603. private _emissiveTexture;
  38604. /**
  38605. * Define texture of the material as if self lit.
  38606. * This will be mixed in the final result even in the absence of light.
  38607. */
  38608. emissiveTexture: Nullable<BaseTexture>;
  38609. private _specularTexture;
  38610. /**
  38611. * Define how the color and intensity of the highlight given by the light in the material.
  38612. */
  38613. specularTexture: Nullable<BaseTexture>;
  38614. private _bumpTexture;
  38615. /**
  38616. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  38617. * 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.
  38618. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  38619. */
  38620. bumpTexture: Nullable<BaseTexture>;
  38621. private _lightmapTexture;
  38622. /**
  38623. * Complex lighting can be computationally expensive to compute at runtime.
  38624. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  38625. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  38626. */
  38627. lightmapTexture: Nullable<BaseTexture>;
  38628. private _refractionTexture;
  38629. /**
  38630. * Define the texture used to display the refraction.
  38631. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38632. */
  38633. refractionTexture: Nullable<BaseTexture>;
  38634. /**
  38635. * The color of the material lit by the environmental background lighting.
  38636. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  38637. */
  38638. ambientColor: Color3;
  38639. /**
  38640. * The basic color of the material as viewed under a light.
  38641. */
  38642. diffuseColor: Color3;
  38643. /**
  38644. * Define how the color and intensity of the highlight given by the light in the material.
  38645. */
  38646. specularColor: Color3;
  38647. /**
  38648. * Define the color of the material as if self lit.
  38649. * This will be mixed in the final result even in the absence of light.
  38650. */
  38651. emissiveColor: Color3;
  38652. /**
  38653. * Defines how sharp are the highlights in the material.
  38654. * The bigger the value the sharper giving a more glossy feeling to the result.
  38655. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  38656. */
  38657. specularPower: number;
  38658. private _useAlphaFromDiffuseTexture;
  38659. /**
  38660. * Does the transparency come from the diffuse texture alpha channel.
  38661. */
  38662. useAlphaFromDiffuseTexture: boolean;
  38663. private _useEmissiveAsIllumination;
  38664. /**
  38665. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  38666. */
  38667. useEmissiveAsIllumination: boolean;
  38668. private _linkEmissiveWithDiffuse;
  38669. /**
  38670. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  38671. * the emissive level when the final color is close to one.
  38672. */
  38673. linkEmissiveWithDiffuse: boolean;
  38674. private _useSpecularOverAlpha;
  38675. /**
  38676. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  38677. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  38678. */
  38679. useSpecularOverAlpha: boolean;
  38680. private _useReflectionOverAlpha;
  38681. /**
  38682. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  38683. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  38684. */
  38685. useReflectionOverAlpha: boolean;
  38686. private _disableLighting;
  38687. /**
  38688. * Does lights from the scene impacts this material.
  38689. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  38690. */
  38691. disableLighting: boolean;
  38692. private _useObjectSpaceNormalMap;
  38693. /**
  38694. * Allows using an object space normal map (instead of tangent space).
  38695. */
  38696. useObjectSpaceNormalMap: boolean;
  38697. private _useParallax;
  38698. /**
  38699. * Is parallax enabled or not.
  38700. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38701. */
  38702. useParallax: boolean;
  38703. private _useParallaxOcclusion;
  38704. /**
  38705. * Is parallax occlusion enabled or not.
  38706. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  38707. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38708. */
  38709. useParallaxOcclusion: boolean;
  38710. /**
  38711. * 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.
  38712. */
  38713. parallaxScaleBias: number;
  38714. private _roughness;
  38715. /**
  38716. * Helps to define how blurry the reflections should appears in the material.
  38717. */
  38718. roughness: number;
  38719. /**
  38720. * In case of refraction, define the value of the indice of refraction.
  38721. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38722. */
  38723. indexOfRefraction: number;
  38724. /**
  38725. * Invert the refraction texture alongside the y axis.
  38726. * It can be useful with procedural textures or probe for instance.
  38727. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38728. */
  38729. invertRefractionY: boolean;
  38730. /**
  38731. * Defines the alpha limits in alpha test mode.
  38732. */
  38733. alphaCutOff: number;
  38734. private _useLightmapAsShadowmap;
  38735. /**
  38736. * In case of light mapping, define whether the map contains light or shadow informations.
  38737. */
  38738. useLightmapAsShadowmap: boolean;
  38739. private _diffuseFresnelParameters;
  38740. /**
  38741. * Define the diffuse fresnel parameters of the material.
  38742. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38743. */
  38744. diffuseFresnelParameters: FresnelParameters;
  38745. private _opacityFresnelParameters;
  38746. /**
  38747. * Define the opacity fresnel parameters of the material.
  38748. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38749. */
  38750. opacityFresnelParameters: FresnelParameters;
  38751. private _reflectionFresnelParameters;
  38752. /**
  38753. * Define the reflection fresnel parameters of the material.
  38754. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38755. */
  38756. reflectionFresnelParameters: FresnelParameters;
  38757. private _refractionFresnelParameters;
  38758. /**
  38759. * Define the refraction fresnel parameters of the material.
  38760. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38761. */
  38762. refractionFresnelParameters: FresnelParameters;
  38763. private _emissiveFresnelParameters;
  38764. /**
  38765. * Define the emissive fresnel parameters of the material.
  38766. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38767. */
  38768. emissiveFresnelParameters: FresnelParameters;
  38769. private _useReflectionFresnelFromSpecular;
  38770. /**
  38771. * If true automatically deducts the fresnels values from the material specularity.
  38772. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38773. */
  38774. useReflectionFresnelFromSpecular: boolean;
  38775. private _useGlossinessFromSpecularMapAlpha;
  38776. /**
  38777. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  38778. */
  38779. useGlossinessFromSpecularMapAlpha: boolean;
  38780. private _maxSimultaneousLights;
  38781. /**
  38782. * Defines the maximum number of lights that can be used in the material
  38783. */
  38784. maxSimultaneousLights: number;
  38785. private _invertNormalMapX;
  38786. /**
  38787. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  38788. */
  38789. invertNormalMapX: boolean;
  38790. private _invertNormalMapY;
  38791. /**
  38792. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  38793. */
  38794. invertNormalMapY: boolean;
  38795. private _twoSidedLighting;
  38796. /**
  38797. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  38798. */
  38799. twoSidedLighting: boolean;
  38800. /**
  38801. * Default configuration related to image processing available in the standard Material.
  38802. */
  38803. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38804. /**
  38805. * Gets the image processing configuration used either in this material.
  38806. */
  38807. /**
  38808. * Sets the Default image processing configuration used either in the this material.
  38809. *
  38810. * If sets to null, the scene one is in use.
  38811. */
  38812. imageProcessingConfiguration: ImageProcessingConfiguration;
  38813. /**
  38814. * Keep track of the image processing observer to allow dispose and replace.
  38815. */
  38816. private _imageProcessingObserver;
  38817. /**
  38818. * Attaches a new image processing configuration to the Standard Material.
  38819. * @param configuration
  38820. */
  38821. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  38822. /**
  38823. * Gets wether the color curves effect is enabled.
  38824. */
  38825. /**
  38826. * Sets wether the color curves effect is enabled.
  38827. */
  38828. cameraColorCurvesEnabled: boolean;
  38829. /**
  38830. * Gets wether the color grading effect is enabled.
  38831. */
  38832. /**
  38833. * Gets wether the color grading effect is enabled.
  38834. */
  38835. cameraColorGradingEnabled: boolean;
  38836. /**
  38837. * Gets wether tonemapping is enabled or not.
  38838. */
  38839. /**
  38840. * Sets wether tonemapping is enabled or not
  38841. */
  38842. cameraToneMappingEnabled: boolean;
  38843. /**
  38844. * The camera exposure used on this material.
  38845. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38846. * This corresponds to a photographic exposure.
  38847. */
  38848. /**
  38849. * The camera exposure used on this material.
  38850. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38851. * This corresponds to a photographic exposure.
  38852. */
  38853. cameraExposure: number;
  38854. /**
  38855. * Gets The camera contrast used on this material.
  38856. */
  38857. /**
  38858. * Sets The camera contrast used on this material.
  38859. */
  38860. cameraContrast: number;
  38861. /**
  38862. * Gets the Color Grading 2D Lookup Texture.
  38863. */
  38864. /**
  38865. * Sets the Color Grading 2D Lookup Texture.
  38866. */
  38867. cameraColorGradingTexture: Nullable<BaseTexture>;
  38868. /**
  38869. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38870. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38871. * 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;
  38872. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38873. */
  38874. /**
  38875. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38876. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38877. * 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;
  38878. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38879. */
  38880. cameraColorCurves: Nullable<ColorCurves>;
  38881. /**
  38882. * Custom callback helping to override the default shader used in the material.
  38883. */
  38884. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  38885. protected _renderTargets: SmartArray<RenderTargetTexture>;
  38886. protected _worldViewProjectionMatrix: Matrix;
  38887. protected _globalAmbientColor: Color3;
  38888. protected _useLogarithmicDepth: boolean;
  38889. /**
  38890. * Instantiates a new standard material.
  38891. * This is the default material used in Babylon. It is the best trade off between quality
  38892. * and performances.
  38893. * @see http://doc.babylonjs.com/babylon101/materials
  38894. * @param name Define the name of the material in the scene
  38895. * @param scene Define the scene the material belong to
  38896. */
  38897. constructor(name: string, scene: Scene);
  38898. /**
  38899. * Gets a boolean indicating that current material needs to register RTT
  38900. */
  38901. readonly hasRenderTargetTextures: boolean;
  38902. /**
  38903. * Gets the current class name of the material e.g. "StandardMaterial"
  38904. * Mainly use in serialization.
  38905. * @returns the class name
  38906. */
  38907. getClassName(): string;
  38908. /**
  38909. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  38910. * You can try switching to logarithmic depth.
  38911. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  38912. */
  38913. useLogarithmicDepth: boolean;
  38914. /**
  38915. * Specifies if the material will require alpha blending
  38916. * @returns a boolean specifying if alpha blending is needed
  38917. */
  38918. needAlphaBlending(): boolean;
  38919. /**
  38920. * Specifies if this material should be rendered in alpha test mode
  38921. * @returns a boolean specifying if an alpha test is needed.
  38922. */
  38923. needAlphaTesting(): boolean;
  38924. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  38925. /**
  38926. * Get the texture used for alpha test purpose.
  38927. * @returns the diffuse texture in case of the standard material.
  38928. */
  38929. getAlphaTestTexture(): Nullable<BaseTexture>;
  38930. /**
  38931. * Get if the submesh is ready to be used and all its information available.
  38932. * Child classes can use it to update shaders
  38933. * @param mesh defines the mesh to check
  38934. * @param subMesh defines which submesh to check
  38935. * @param useInstances specifies that instances should be used
  38936. * @returns a boolean indicating that the submesh is ready or not
  38937. */
  38938. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  38939. /**
  38940. * Builds the material UBO layouts.
  38941. * Used internally during the effect preparation.
  38942. */
  38943. buildUniformLayout(): void;
  38944. /**
  38945. * Unbinds the material from the mesh
  38946. */
  38947. unbind(): void;
  38948. /**
  38949. * Binds the submesh to this material by preparing the effect and shader to draw
  38950. * @param world defines the world transformation matrix
  38951. * @param mesh defines the mesh containing the submesh
  38952. * @param subMesh defines the submesh to bind the material to
  38953. */
  38954. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  38955. /**
  38956. * Get the list of animatables in the material.
  38957. * @returns the list of animatables object used in the material
  38958. */
  38959. getAnimatables(): IAnimatable[];
  38960. /**
  38961. * Gets the active textures from the material
  38962. * @returns an array of textures
  38963. */
  38964. getActiveTextures(): BaseTexture[];
  38965. /**
  38966. * Specifies if the material uses a texture
  38967. * @param texture defines the texture to check against the material
  38968. * @returns a boolean specifying if the material uses the texture
  38969. */
  38970. hasTexture(texture: BaseTexture): boolean;
  38971. /**
  38972. * Disposes the material
  38973. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  38974. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  38975. */
  38976. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  38977. /**
  38978. * Makes a duplicate of the material, and gives it a new name
  38979. * @param name defines the new name for the duplicated material
  38980. * @returns the cloned material
  38981. */
  38982. clone(name: string): StandardMaterial;
  38983. /**
  38984. * Serializes this material in a JSON representation
  38985. * @returns the serialized material object
  38986. */
  38987. serialize(): any;
  38988. /**
  38989. * Creates a standard material from parsed material data
  38990. * @param source defines the JSON representation of the material
  38991. * @param scene defines the hosting scene
  38992. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  38993. * @returns a new standard material
  38994. */
  38995. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  38996. /**
  38997. * Are diffuse textures enabled in the application.
  38998. */
  38999. static DiffuseTextureEnabled: boolean;
  39000. /**
  39001. * Are ambient textures enabled in the application.
  39002. */
  39003. static AmbientTextureEnabled: boolean;
  39004. /**
  39005. * Are opacity textures enabled in the application.
  39006. */
  39007. static OpacityTextureEnabled: boolean;
  39008. /**
  39009. * Are reflection textures enabled in the application.
  39010. */
  39011. static ReflectionTextureEnabled: boolean;
  39012. /**
  39013. * Are emissive textures enabled in the application.
  39014. */
  39015. static EmissiveTextureEnabled: boolean;
  39016. /**
  39017. * Are specular textures enabled in the application.
  39018. */
  39019. static SpecularTextureEnabled: boolean;
  39020. /**
  39021. * Are bump textures enabled in the application.
  39022. */
  39023. static BumpTextureEnabled: boolean;
  39024. /**
  39025. * Are lightmap textures enabled in the application.
  39026. */
  39027. static LightmapTextureEnabled: boolean;
  39028. /**
  39029. * Are refraction textures enabled in the application.
  39030. */
  39031. static RefractionTextureEnabled: boolean;
  39032. /**
  39033. * Are color grading textures enabled in the application.
  39034. */
  39035. static ColorGradingTextureEnabled: boolean;
  39036. /**
  39037. * Are fresnels enabled in the application.
  39038. */
  39039. static FresnelEnabled: boolean;
  39040. }
  39041. }
  39042. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  39043. import { Scene } from "babylonjs/scene";
  39044. import { Texture } from "babylonjs/Materials/Textures/texture";
  39045. /**
  39046. * A class extending Texture allowing drawing on a texture
  39047. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39048. */
  39049. export class DynamicTexture extends Texture {
  39050. private _generateMipMaps;
  39051. private _canvas;
  39052. private _context;
  39053. private _engine;
  39054. /**
  39055. * Creates a DynamicTexture
  39056. * @param name defines the name of the texture
  39057. * @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
  39058. * @param scene defines the scene where you want the texture
  39059. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39060. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39061. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39062. */
  39063. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39064. /**
  39065. * Get the current class name of the texture useful for serialization or dynamic coding.
  39066. * @returns "DynamicTexture"
  39067. */
  39068. getClassName(): string;
  39069. /**
  39070. * Gets the current state of canRescale
  39071. */
  39072. readonly canRescale: boolean;
  39073. private _recreate;
  39074. /**
  39075. * Scales the texture
  39076. * @param ratio the scale factor to apply to both width and height
  39077. */
  39078. scale(ratio: number): void;
  39079. /**
  39080. * Resizes the texture
  39081. * @param width the new width
  39082. * @param height the new height
  39083. */
  39084. scaleTo(width: number, height: number): void;
  39085. /**
  39086. * Gets the context of the canvas used by the texture
  39087. * @returns the canvas context of the dynamic texture
  39088. */
  39089. getContext(): CanvasRenderingContext2D;
  39090. /**
  39091. * Clears the texture
  39092. */
  39093. clear(): void;
  39094. /**
  39095. * Updates the texture
  39096. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39097. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39098. */
  39099. update(invertY?: boolean, premulAlpha?: boolean): void;
  39100. /**
  39101. * Draws text onto the texture
  39102. * @param text defines the text to be drawn
  39103. * @param x defines the placement of the text from the left
  39104. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39105. * @param font defines the font to be used with font-style, font-size, font-name
  39106. * @param color defines the color used for the text
  39107. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39108. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39109. * @param update defines whether texture is immediately update (default is true)
  39110. */
  39111. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39112. /**
  39113. * Clones the texture
  39114. * @returns the clone of the texture.
  39115. */
  39116. clone(): DynamicTexture;
  39117. /**
  39118. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39119. * @returns a serialized dynamic texture object
  39120. */
  39121. serialize(): any;
  39122. /** @hidden */
  39123. _rebuild(): void;
  39124. }
  39125. }
  39126. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  39127. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39128. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39129. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39130. /** @hidden */
  39131. export var imageProcessingPixelShader: {
  39132. name: string;
  39133. shader: string;
  39134. };
  39135. }
  39136. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  39137. import { Nullable } from "babylonjs/types";
  39138. import { Color4 } from "babylonjs/Maths/math";
  39139. import { Camera } from "babylonjs/Cameras/camera";
  39140. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39141. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39142. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  39143. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39144. import { Engine } from "babylonjs/Engines/engine";
  39145. import "babylonjs/Shaders/imageProcessing.fragment";
  39146. import "babylonjs/Shaders/postprocess.vertex";
  39147. /**
  39148. * ImageProcessingPostProcess
  39149. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39150. */
  39151. export class ImageProcessingPostProcess extends PostProcess {
  39152. /**
  39153. * Default configuration related to image processing available in the PBR Material.
  39154. */
  39155. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39156. /**
  39157. * Gets the image processing configuration used either in this material.
  39158. */
  39159. /**
  39160. * Sets the Default image processing configuration used either in the this material.
  39161. *
  39162. * If sets to null, the scene one is in use.
  39163. */
  39164. imageProcessingConfiguration: ImageProcessingConfiguration;
  39165. /**
  39166. * Keep track of the image processing observer to allow dispose and replace.
  39167. */
  39168. private _imageProcessingObserver;
  39169. /**
  39170. * Attaches a new image processing configuration to the PBR Material.
  39171. * @param configuration
  39172. */
  39173. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39174. /**
  39175. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39176. */
  39177. /**
  39178. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39179. */
  39180. colorCurves: Nullable<ColorCurves>;
  39181. /**
  39182. * Gets wether the color curves effect is enabled.
  39183. */
  39184. /**
  39185. * Sets wether the color curves effect is enabled.
  39186. */
  39187. colorCurvesEnabled: boolean;
  39188. /**
  39189. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39190. */
  39191. /**
  39192. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39193. */
  39194. colorGradingTexture: Nullable<BaseTexture>;
  39195. /**
  39196. * Gets wether the color grading effect is enabled.
  39197. */
  39198. /**
  39199. * Gets wether the color grading effect is enabled.
  39200. */
  39201. colorGradingEnabled: boolean;
  39202. /**
  39203. * Gets exposure used in the effect.
  39204. */
  39205. /**
  39206. * Sets exposure used in the effect.
  39207. */
  39208. exposure: number;
  39209. /**
  39210. * Gets wether tonemapping is enabled or not.
  39211. */
  39212. /**
  39213. * Sets wether tonemapping is enabled or not
  39214. */
  39215. toneMappingEnabled: boolean;
  39216. /**
  39217. * Gets contrast used in the effect.
  39218. */
  39219. /**
  39220. * Sets contrast used in the effect.
  39221. */
  39222. contrast: number;
  39223. /**
  39224. * Gets Vignette stretch size.
  39225. */
  39226. /**
  39227. * Sets Vignette stretch size.
  39228. */
  39229. vignetteStretch: number;
  39230. /**
  39231. * Gets Vignette centre X Offset.
  39232. */
  39233. /**
  39234. * Sets Vignette centre X Offset.
  39235. */
  39236. vignetteCentreX: number;
  39237. /**
  39238. * Gets Vignette centre Y Offset.
  39239. */
  39240. /**
  39241. * Sets Vignette centre Y Offset.
  39242. */
  39243. vignetteCentreY: number;
  39244. /**
  39245. * Gets Vignette weight or intensity of the vignette effect.
  39246. */
  39247. /**
  39248. * Sets Vignette weight or intensity of the vignette effect.
  39249. */
  39250. vignetteWeight: number;
  39251. /**
  39252. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39253. * if vignetteEnabled is set to true.
  39254. */
  39255. /**
  39256. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39257. * if vignetteEnabled is set to true.
  39258. */
  39259. vignetteColor: Color4;
  39260. /**
  39261. * Gets Camera field of view used by the Vignette effect.
  39262. */
  39263. /**
  39264. * Sets Camera field of view used by the Vignette effect.
  39265. */
  39266. vignetteCameraFov: number;
  39267. /**
  39268. * Gets the vignette blend mode allowing different kind of effect.
  39269. */
  39270. /**
  39271. * Sets the vignette blend mode allowing different kind of effect.
  39272. */
  39273. vignetteBlendMode: number;
  39274. /**
  39275. * Gets wether the vignette effect is enabled.
  39276. */
  39277. /**
  39278. * Sets wether the vignette effect is enabled.
  39279. */
  39280. vignetteEnabled: boolean;
  39281. private _fromLinearSpace;
  39282. /**
  39283. * Gets wether the input of the processing is in Gamma or Linear Space.
  39284. */
  39285. /**
  39286. * Sets wether the input of the processing is in Gamma or Linear Space.
  39287. */
  39288. fromLinearSpace: boolean;
  39289. /**
  39290. * Defines cache preventing GC.
  39291. */
  39292. private _defines;
  39293. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39294. /**
  39295. * "ImageProcessingPostProcess"
  39296. * @returns "ImageProcessingPostProcess"
  39297. */
  39298. getClassName(): string;
  39299. protected _updateParameters(): void;
  39300. dispose(camera?: Camera): void;
  39301. }
  39302. }
  39303. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  39304. import { Scene } from "babylonjs/scene";
  39305. import { Color3 } from "babylonjs/Maths/math";
  39306. import { Mesh } from "babylonjs/Meshes/mesh";
  39307. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  39308. /**
  39309. * Class containing static functions to help procedurally build meshes
  39310. */
  39311. export class GroundBuilder {
  39312. /**
  39313. * Creates a ground mesh
  39314. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39315. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39316. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39317. * @param name defines the name of the mesh
  39318. * @param options defines the options used to create the mesh
  39319. * @param scene defines the hosting scene
  39320. * @returns the ground mesh
  39321. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39322. */
  39323. static CreateGround(name: string, options: {
  39324. width?: number;
  39325. height?: number;
  39326. subdivisions?: number;
  39327. subdivisionsX?: number;
  39328. subdivisionsY?: number;
  39329. updatable?: boolean;
  39330. }, scene: any): Mesh;
  39331. /**
  39332. * Creates a tiled ground mesh
  39333. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39334. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39335. * * 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
  39336. * * 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
  39337. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39338. * @param name defines the name of the mesh
  39339. * @param options defines the options used to create the mesh
  39340. * @param scene defines the hosting scene
  39341. * @returns the tiled ground mesh
  39342. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39343. */
  39344. static CreateTiledGround(name: string, options: {
  39345. xmin: number;
  39346. zmin: number;
  39347. xmax: number;
  39348. zmax: number;
  39349. subdivisions?: {
  39350. w: number;
  39351. h: number;
  39352. };
  39353. precision?: {
  39354. w: number;
  39355. h: number;
  39356. };
  39357. updatable?: boolean;
  39358. }, scene: Scene): Mesh;
  39359. /**
  39360. * Creates a ground mesh from a height map
  39361. * * The parameter `url` sets the URL of the height map image resource.
  39362. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  39363. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  39364. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  39365. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  39366. * * 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.
  39367. * * 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).
  39368. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  39369. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39370. * @param name defines the name of the mesh
  39371. * @param url defines the url to the height map
  39372. * @param options defines the options used to create the mesh
  39373. * @param scene defines the hosting scene
  39374. * @returns the ground mesh
  39375. * @see https://doc.babylonjs.com/babylon101/height_map
  39376. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  39377. */
  39378. static CreateGroundFromHeightMap(name: string, url: string, options: {
  39379. width?: number;
  39380. height?: number;
  39381. subdivisions?: number;
  39382. minHeight?: number;
  39383. maxHeight?: number;
  39384. colorFilter?: Color3;
  39385. alphaFilter?: number;
  39386. updatable?: boolean;
  39387. onReady?: (mesh: GroundMesh) => void;
  39388. }, scene: Scene): GroundMesh;
  39389. }
  39390. }
  39391. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  39392. import { Vector4 } from "babylonjs/Maths/math";
  39393. import { Mesh } from "babylonjs/Meshes/mesh";
  39394. /**
  39395. * Class containing static functions to help procedurally build meshes
  39396. */
  39397. export class TorusBuilder {
  39398. /**
  39399. * Creates a torus mesh
  39400. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  39401. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  39402. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  39403. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39404. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39405. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39406. * @param name defines the name of the mesh
  39407. * @param options defines the options used to create the mesh
  39408. * @param scene defines the hosting scene
  39409. * @returns the torus mesh
  39410. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  39411. */
  39412. static CreateTorus(name: string, options: {
  39413. diameter?: number;
  39414. thickness?: number;
  39415. tessellation?: number;
  39416. updatable?: boolean;
  39417. sideOrientation?: number;
  39418. frontUVs?: Vector4;
  39419. backUVs?: Vector4;
  39420. }, scene: any): Mesh;
  39421. }
  39422. }
  39423. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  39424. import { Color4, Vector4 } from "babylonjs/Maths/math";
  39425. import { Mesh } from "babylonjs/Meshes/mesh";
  39426. /**
  39427. * Class containing static functions to help procedurally build meshes
  39428. */
  39429. export class CylinderBuilder {
  39430. /**
  39431. * Creates a cylinder or a cone mesh
  39432. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  39433. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  39434. * * 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.
  39435. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  39436. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  39437. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  39438. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  39439. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  39440. * * 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).
  39441. * * 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
  39442. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  39443. * * 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
  39444. * * 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.
  39445. * * If `enclose` is false, a ring surface is one element.
  39446. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  39447. * * 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
  39448. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39449. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39450. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39451. * @param name defines the name of the mesh
  39452. * @param options defines the options used to create the mesh
  39453. * @param scene defines the hosting scene
  39454. * @returns the cylinder mesh
  39455. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  39456. */
  39457. static CreateCylinder(name: string, options: {
  39458. height?: number;
  39459. diameterTop?: number;
  39460. diameterBottom?: number;
  39461. diameter?: number;
  39462. tessellation?: number;
  39463. subdivisions?: number;
  39464. arc?: number;
  39465. faceColors?: Color4[];
  39466. faceUV?: Vector4[];
  39467. updatable?: boolean;
  39468. hasRings?: boolean;
  39469. enclose?: boolean;
  39470. sideOrientation?: number;
  39471. frontUVs?: Vector4;
  39472. backUVs?: Vector4;
  39473. }, scene: any): Mesh;
  39474. }
  39475. }
  39476. declare module "babylonjs/Gamepads/gamepadManager" {
  39477. import { Observable } from "babylonjs/Misc/observable";
  39478. import { Nullable } from "babylonjs/types";
  39479. import { Scene } from "babylonjs/scene";
  39480. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39481. /**
  39482. * Manager for handling gamepads
  39483. */
  39484. export class GamepadManager {
  39485. private _scene?;
  39486. private _babylonGamepads;
  39487. private _oneGamepadConnected;
  39488. /** @hidden */
  39489. _isMonitoring: boolean;
  39490. private _gamepadEventSupported;
  39491. private _gamepadSupport;
  39492. /**
  39493. * observable to be triggered when the gamepad controller has been connected
  39494. */
  39495. onGamepadConnectedObservable: Observable<Gamepad>;
  39496. /**
  39497. * observable to be triggered when the gamepad controller has been disconnected
  39498. */
  39499. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39500. private _onGamepadConnectedEvent;
  39501. private _onGamepadDisconnectedEvent;
  39502. /**
  39503. * Initializes the gamepad manager
  39504. * @param _scene BabylonJS scene
  39505. */
  39506. constructor(_scene?: Scene | undefined);
  39507. /**
  39508. * The gamepads in the game pad manager
  39509. */
  39510. readonly gamepads: Gamepad[];
  39511. /**
  39512. * Get the gamepad controllers based on type
  39513. * @param type The type of gamepad controller
  39514. * @returns Nullable gamepad
  39515. */
  39516. getGamepadByType(type?: number): Nullable<Gamepad>;
  39517. /**
  39518. * Disposes the gamepad manager
  39519. */
  39520. dispose(): void;
  39521. private _addNewGamepad;
  39522. private _startMonitoringGamepads;
  39523. private _stopMonitoringGamepads;
  39524. /** @hidden */
  39525. _checkGamepadsStatus(): void;
  39526. private _updateGamepadObjects;
  39527. }
  39528. }
  39529. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  39530. import { Nullable } from "babylonjs/types";
  39531. import { Scene } from "babylonjs/scene";
  39532. import { ISceneComponent } from "babylonjs/sceneComponent";
  39533. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  39534. module "babylonjs/scene" {
  39535. interface Scene {
  39536. /** @hidden */
  39537. _gamepadManager: Nullable<GamepadManager>;
  39538. /**
  39539. * Gets the gamepad manager associated with the scene
  39540. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39541. */
  39542. gamepadManager: GamepadManager;
  39543. }
  39544. }
  39545. module "babylonjs/Cameras/freeCameraInputsManager" {
  39546. /**
  39547. * Interface representing a free camera inputs manager
  39548. */
  39549. interface FreeCameraInputsManager {
  39550. /**
  39551. * Adds gamepad input support to the FreeCameraInputsManager.
  39552. * @returns the FreeCameraInputsManager
  39553. */
  39554. addGamepad(): FreeCameraInputsManager;
  39555. }
  39556. }
  39557. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39558. /**
  39559. * Interface representing an arc rotate camera inputs manager
  39560. */
  39561. interface ArcRotateCameraInputsManager {
  39562. /**
  39563. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39564. * @returns the camera inputs manager
  39565. */
  39566. addGamepad(): ArcRotateCameraInputsManager;
  39567. }
  39568. }
  39569. /**
  39570. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39571. */
  39572. export class GamepadSystemSceneComponent implements ISceneComponent {
  39573. /**
  39574. * The component name helpfull to identify the component in the list of scene components.
  39575. */
  39576. readonly name: string;
  39577. /**
  39578. * The scene the component belongs to.
  39579. */
  39580. scene: Scene;
  39581. /**
  39582. * Creates a new instance of the component for the given scene
  39583. * @param scene Defines the scene to register the component in
  39584. */
  39585. constructor(scene: Scene);
  39586. /**
  39587. * Registers the component in a given scene
  39588. */
  39589. register(): void;
  39590. /**
  39591. * Rebuilds the elements related to this component in case of
  39592. * context lost for instance.
  39593. */
  39594. rebuild(): void;
  39595. /**
  39596. * Disposes the component and the associated ressources
  39597. */
  39598. dispose(): void;
  39599. private _beforeCameraUpdate;
  39600. }
  39601. }
  39602. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  39603. import { Observable } from "babylonjs/Misc/observable";
  39604. import { Nullable } from "babylonjs/types";
  39605. import { Camera } from "babylonjs/Cameras/camera";
  39606. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  39607. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  39608. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  39609. import { Scene } from "babylonjs/scene";
  39610. import { Vector3, Color3 } from "babylonjs/Maths/math";
  39611. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  39612. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39613. import { Mesh } from "babylonjs/Meshes/mesh";
  39614. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  39615. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39616. import "babylonjs/Meshes/Builders/groundBuilder";
  39617. import "babylonjs/Meshes/Builders/torusBuilder";
  39618. import "babylonjs/Meshes/Builders/cylinderBuilder";
  39619. import "babylonjs/Gamepads/gamepadSceneComponent";
  39620. import "babylonjs/Animations/animatable";
  39621. /**
  39622. * Options to modify the vr teleportation behavior.
  39623. */
  39624. export interface VRTeleportationOptions {
  39625. /**
  39626. * The name of the mesh which should be used as the teleportation floor. (default: null)
  39627. */
  39628. floorMeshName?: string;
  39629. /**
  39630. * A list of meshes to be used as the teleportation floor. (default: empty)
  39631. */
  39632. floorMeshes?: Mesh[];
  39633. }
  39634. /**
  39635. * Options to modify the vr experience helper's behavior.
  39636. */
  39637. export interface VRExperienceHelperOptions extends WebVROptions {
  39638. /**
  39639. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  39640. */
  39641. createDeviceOrientationCamera?: boolean;
  39642. /**
  39643. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  39644. */
  39645. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  39646. /**
  39647. * Uses the main button on the controller to toggle the laser casted. (default: true)
  39648. */
  39649. laserToggle?: boolean;
  39650. /**
  39651. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  39652. */
  39653. floorMeshes?: Mesh[];
  39654. /**
  39655. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  39656. */
  39657. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  39658. }
  39659. /**
  39660. * Helps to quickly add VR support to an existing scene.
  39661. * See http://doc.babylonjs.com/how_to/webvr_helper
  39662. */
  39663. export class VRExperienceHelper {
  39664. /** Options to modify the vr experience helper's behavior. */
  39665. webVROptions: VRExperienceHelperOptions;
  39666. private _scene;
  39667. private _position;
  39668. private _btnVR;
  39669. private _btnVRDisplayed;
  39670. private _webVRsupported;
  39671. private _webVRready;
  39672. private _webVRrequesting;
  39673. private _webVRpresenting;
  39674. private _hasEnteredVR;
  39675. private _fullscreenVRpresenting;
  39676. private _canvas;
  39677. private _webVRCamera;
  39678. private _vrDeviceOrientationCamera;
  39679. private _deviceOrientationCamera;
  39680. private _existingCamera;
  39681. private _onKeyDown;
  39682. private _onVrDisplayPresentChange;
  39683. private _onVRDisplayChanged;
  39684. private _onVRRequestPresentStart;
  39685. private _onVRRequestPresentComplete;
  39686. /**
  39687. * Observable raised when entering VR.
  39688. */
  39689. onEnteringVRObservable: Observable<VRExperienceHelper>;
  39690. /**
  39691. * Observable raised when exiting VR.
  39692. */
  39693. onExitingVRObservable: Observable<VRExperienceHelper>;
  39694. /**
  39695. * Observable raised when controller mesh is loaded.
  39696. */
  39697. onControllerMeshLoadedObservable: Observable<WebVRController>;
  39698. /** Return this.onEnteringVRObservable
  39699. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  39700. */
  39701. readonly onEnteringVR: Observable<VRExperienceHelper>;
  39702. /** Return this.onExitingVRObservable
  39703. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  39704. */
  39705. readonly onExitingVR: Observable<VRExperienceHelper>;
  39706. /** Return this.onControllerMeshLoadedObservable
  39707. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  39708. */
  39709. readonly onControllerMeshLoaded: Observable<WebVRController>;
  39710. private _rayLength;
  39711. private _useCustomVRButton;
  39712. private _teleportationRequested;
  39713. private _teleportActive;
  39714. private _floorMeshName;
  39715. private _floorMeshesCollection;
  39716. private _rotationAllowed;
  39717. private _teleportBackwardsVector;
  39718. private _teleportationTarget;
  39719. private _isDefaultTeleportationTarget;
  39720. private _postProcessMove;
  39721. private _teleportationFillColor;
  39722. private _teleportationBorderColor;
  39723. private _rotationAngle;
  39724. private _haloCenter;
  39725. private _cameraGazer;
  39726. private _padSensibilityUp;
  39727. private _padSensibilityDown;
  39728. private _leftController;
  39729. private _rightController;
  39730. /**
  39731. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  39732. */
  39733. onNewMeshSelected: Observable<AbstractMesh>;
  39734. /**
  39735. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  39736. */
  39737. onNewMeshPicked: Observable<PickingInfo>;
  39738. private _circleEase;
  39739. /**
  39740. * Observable raised before camera teleportation
  39741. */
  39742. onBeforeCameraTeleport: Observable<Vector3>;
  39743. /**
  39744. * Observable raised after camera teleportation
  39745. */
  39746. onAfterCameraTeleport: Observable<Vector3>;
  39747. /**
  39748. * Observable raised when current selected mesh gets unselected
  39749. */
  39750. onSelectedMeshUnselected: Observable<AbstractMesh>;
  39751. private _raySelectionPredicate;
  39752. /**
  39753. * To be optionaly changed by user to define custom ray selection
  39754. */
  39755. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  39756. /**
  39757. * To be optionaly changed by user to define custom selection logic (after ray selection)
  39758. */
  39759. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  39760. /**
  39761. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  39762. */
  39763. teleportationEnabled: boolean;
  39764. private _defaultHeight;
  39765. private _teleportationInitialized;
  39766. private _interactionsEnabled;
  39767. private _interactionsRequested;
  39768. private _displayGaze;
  39769. private _displayLaserPointer;
  39770. /**
  39771. * The mesh used to display where the user is going to teleport.
  39772. */
  39773. /**
  39774. * Sets the mesh to be used to display where the user is going to teleport.
  39775. */
  39776. teleportationTarget: Mesh;
  39777. /**
  39778. * 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
  39779. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  39780. * See http://doc.babylonjs.com/resources/baking_transformations
  39781. */
  39782. gazeTrackerMesh: Mesh;
  39783. /**
  39784. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  39785. */
  39786. updateGazeTrackerScale: boolean;
  39787. /**
  39788. * If the gaze trackers color should be updated when selecting meshes
  39789. */
  39790. updateGazeTrackerColor: boolean;
  39791. /**
  39792. * The gaze tracking mesh corresponding to the left controller
  39793. */
  39794. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  39795. /**
  39796. * The gaze tracking mesh corresponding to the right controller
  39797. */
  39798. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  39799. /**
  39800. * If the ray of the gaze should be displayed.
  39801. */
  39802. /**
  39803. * Sets if the ray of the gaze should be displayed.
  39804. */
  39805. displayGaze: boolean;
  39806. /**
  39807. * If the ray of the LaserPointer should be displayed.
  39808. */
  39809. /**
  39810. * Sets if the ray of the LaserPointer should be displayed.
  39811. */
  39812. displayLaserPointer: boolean;
  39813. /**
  39814. * The deviceOrientationCamera used as the camera when not in VR.
  39815. */
  39816. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  39817. /**
  39818. * Based on the current WebVR support, returns the current VR camera used.
  39819. */
  39820. readonly currentVRCamera: Nullable<Camera>;
  39821. /**
  39822. * The webVRCamera which is used when in VR.
  39823. */
  39824. readonly webVRCamera: WebVRFreeCamera;
  39825. /**
  39826. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  39827. */
  39828. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  39829. private readonly _teleportationRequestInitiated;
  39830. /**
  39831. * Defines wether or not Pointer lock should be requested when switching to
  39832. * full screen.
  39833. */
  39834. requestPointerLockOnFullScreen: boolean;
  39835. /**
  39836. * Instantiates a VRExperienceHelper.
  39837. * Helps to quickly add VR support to an existing scene.
  39838. * @param scene The scene the VRExperienceHelper belongs to.
  39839. * @param webVROptions Options to modify the vr experience helper's behavior.
  39840. */
  39841. constructor(scene: Scene,
  39842. /** Options to modify the vr experience helper's behavior. */
  39843. webVROptions?: VRExperienceHelperOptions);
  39844. private _onDefaultMeshLoaded;
  39845. private _onResize;
  39846. private _onFullscreenChange;
  39847. /**
  39848. * Gets a value indicating if we are currently in VR mode.
  39849. */
  39850. readonly isInVRMode: boolean;
  39851. private onVrDisplayPresentChange;
  39852. private onVRDisplayChanged;
  39853. private moveButtonToBottomRight;
  39854. private displayVRButton;
  39855. private updateButtonVisibility;
  39856. private _cachedAngularSensibility;
  39857. /**
  39858. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  39859. * Otherwise, will use the fullscreen API.
  39860. */
  39861. enterVR(): void;
  39862. /**
  39863. * Attempt to exit VR, or fullscreen.
  39864. */
  39865. exitVR(): void;
  39866. /**
  39867. * The position of the vr experience helper.
  39868. */
  39869. /**
  39870. * Sets the position of the vr experience helper.
  39871. */
  39872. position: Vector3;
  39873. /**
  39874. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  39875. */
  39876. enableInteractions(): void;
  39877. private readonly _noControllerIsActive;
  39878. private beforeRender;
  39879. private _isTeleportationFloor;
  39880. /**
  39881. * Adds a floor mesh to be used for teleportation.
  39882. * @param floorMesh the mesh to be used for teleportation.
  39883. */
  39884. addFloorMesh(floorMesh: Mesh): void;
  39885. /**
  39886. * Removes a floor mesh from being used for teleportation.
  39887. * @param floorMesh the mesh to be removed.
  39888. */
  39889. removeFloorMesh(floorMesh: Mesh): void;
  39890. /**
  39891. * Enables interactions and teleportation using the VR controllers and gaze.
  39892. * @param vrTeleportationOptions options to modify teleportation behavior.
  39893. */
  39894. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  39895. private _onNewGamepadConnected;
  39896. private _tryEnableInteractionOnController;
  39897. private _onNewGamepadDisconnected;
  39898. private _enableInteractionOnController;
  39899. private _checkTeleportWithRay;
  39900. private _checkRotate;
  39901. private _checkTeleportBackwards;
  39902. private _enableTeleportationOnController;
  39903. private _createTeleportationCircles;
  39904. private _displayTeleportationTarget;
  39905. private _hideTeleportationTarget;
  39906. private _rotateCamera;
  39907. private _moveTeleportationSelectorTo;
  39908. private _workingVector;
  39909. private _workingQuaternion;
  39910. private _workingMatrix;
  39911. /**
  39912. * Teleports the users feet to the desired location
  39913. * @param location The location where the user's feet should be placed
  39914. */
  39915. teleportCamera(location: Vector3): void;
  39916. private _convertNormalToDirectionOfRay;
  39917. private _castRayAndSelectObject;
  39918. private _notifySelectedMeshUnselected;
  39919. /**
  39920. * Sets the color of the laser ray from the vr controllers.
  39921. * @param color new color for the ray.
  39922. */
  39923. changeLaserColor(color: Color3): void;
  39924. /**
  39925. * Sets the color of the ray from the vr headsets gaze.
  39926. * @param color new color for the ray.
  39927. */
  39928. changeGazeColor(color: Color3): void;
  39929. /**
  39930. * Exits VR and disposes of the vr experience helper
  39931. */
  39932. dispose(): void;
  39933. /**
  39934. * Gets the name of the VRExperienceHelper class
  39935. * @returns "VRExperienceHelper"
  39936. */
  39937. getClassName(): string;
  39938. }
  39939. }
  39940. declare module "babylonjs/Cameras/VR/index" {
  39941. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  39942. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  39943. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  39944. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  39945. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  39946. export * from "babylonjs/Cameras/VR/webVRCamera";
  39947. }
  39948. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  39949. import { Observable } from "babylonjs/Misc/observable";
  39950. import { Nullable } from "babylonjs/types";
  39951. import { IDisposable, Scene } from "babylonjs/scene";
  39952. import { Vector3 } from "babylonjs/Maths/math";
  39953. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39954. import { Ray } from "babylonjs/Culling/ray";
  39955. /**
  39956. * Manages an XRSession
  39957. * @see https://doc.babylonjs.com/how_to/webxr
  39958. */
  39959. export class WebXRSessionManager implements IDisposable {
  39960. private scene;
  39961. /**
  39962. * Fires every time a new xrFrame arrives which can be used to update the camera
  39963. */
  39964. onXRFrameObservable: Observable<any>;
  39965. /**
  39966. * Fires when the xr session is ended either by the device or manually done
  39967. */
  39968. onXRSessionEnded: Observable<any>;
  39969. /** @hidden */
  39970. _xrSession: XRSession;
  39971. /** @hidden */
  39972. _frameOfReference: XRFrameOfReference;
  39973. /** @hidden */
  39974. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  39975. /** @hidden */
  39976. _currentXRFrame: Nullable<XRFrame>;
  39977. private _xrNavigator;
  39978. private _xrDevice;
  39979. private _tmpMatrix;
  39980. /**
  39981. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  39982. * @param scene The scene which the session should be created for
  39983. */
  39984. constructor(scene: Scene);
  39985. /**
  39986. * Initializes the manager
  39987. * After initialization enterXR can be called to start an XR session
  39988. * @returns Promise which resolves after it is initialized
  39989. */
  39990. initializeAsync(): Promise<void>;
  39991. /**
  39992. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  39993. * @param sessionCreationOptions xr options to create the session with
  39994. * @param frameOfReferenceType option to configure how the xr pose is expressed
  39995. * @returns Promise which resolves after it enters XR
  39996. */
  39997. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  39998. /**
  39999. * Stops the xrSession and restores the renderloop
  40000. * @returns Promise which resolves after it exits XR
  40001. */
  40002. exitXRAsync(): Promise<void>;
  40003. /**
  40004. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40005. * @param ray ray to cast into the environment
  40006. * @returns Promise which resolves with a collision point in the environment if it exists
  40007. */
  40008. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40009. /**
  40010. * Checks if a session would be supported for the creation options specified
  40011. * @param options creation options to check if they are supported
  40012. * @returns true if supported
  40013. */
  40014. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40015. /**
  40016. * @hidden
  40017. * Converts the render layer of xrSession to a render target
  40018. * @param session session to create render target for
  40019. * @param scene scene the new render target should be created for
  40020. */
  40021. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  40022. /**
  40023. * Disposes of the session manager
  40024. */
  40025. dispose(): void;
  40026. }
  40027. }
  40028. declare module "babylonjs/Cameras/XR/webXRCamera" {
  40029. import { Scene } from "babylonjs/scene";
  40030. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40031. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40032. /**
  40033. * WebXR Camera which holds the views for the xrSession
  40034. * @see https://doc.babylonjs.com/how_to/webxr
  40035. */
  40036. export class WebXRCamera extends FreeCamera {
  40037. private static _TmpMatrix;
  40038. /**
  40039. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40040. * @param name the name of the camera
  40041. * @param scene the scene to add the camera to
  40042. */
  40043. constructor(name: string, scene: Scene);
  40044. private _updateNumberOfRigCameras;
  40045. /** @hidden */
  40046. _updateForDualEyeDebugging(pupilDistance?: number): void;
  40047. /**
  40048. * Updates the cameras position from the current pose information of the XR session
  40049. * @param xrSessionManager the session containing pose information
  40050. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40051. */
  40052. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40053. }
  40054. }
  40055. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  40056. import { Nullable } from "babylonjs/types";
  40057. import { Observable } from "babylonjs/Misc/observable";
  40058. import { IDisposable, Scene } from "babylonjs/scene";
  40059. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  40060. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40061. import { Ray } from "babylonjs/Culling/ray";
  40062. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40063. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  40064. /**
  40065. * States of the webXR experience
  40066. */
  40067. export enum WebXRState {
  40068. /**
  40069. * Transitioning to being in XR mode
  40070. */
  40071. ENTERING_XR = 0,
  40072. /**
  40073. * Transitioning to non XR mode
  40074. */
  40075. EXITING_XR = 1,
  40076. /**
  40077. * In XR mode and presenting
  40078. */
  40079. IN_XR = 2,
  40080. /**
  40081. * Not entered XR mode
  40082. */
  40083. NOT_IN_XR = 3
  40084. }
  40085. /**
  40086. * Helper class used to enable XR
  40087. * @see https://doc.babylonjs.com/how_to/webxr
  40088. */
  40089. export class WebXRExperienceHelper implements IDisposable {
  40090. private scene;
  40091. /**
  40092. * 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
  40093. */
  40094. container: AbstractMesh;
  40095. /**
  40096. * Camera used to render xr content
  40097. */
  40098. camera: WebXRCamera;
  40099. /**
  40100. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40101. */
  40102. state: WebXRState;
  40103. private _setState;
  40104. private static _TmpVector;
  40105. /**
  40106. * Fires when the state of the experience helper has changed
  40107. */
  40108. onStateChangedObservable: Observable<WebXRState>;
  40109. /** @hidden */
  40110. _sessionManager: WebXRSessionManager;
  40111. private _nonVRCamera;
  40112. private _originalSceneAutoClear;
  40113. private _supported;
  40114. /**
  40115. * Creates the experience helper
  40116. * @param scene the scene to attach the experience helper to
  40117. * @returns a promise for the experience helper
  40118. */
  40119. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40120. /**
  40121. * Creates a WebXRExperienceHelper
  40122. * @param scene The scene the helper should be created in
  40123. */
  40124. private constructor();
  40125. /**
  40126. * Exits XR mode and returns the scene to its original state
  40127. * @returns promise that resolves after xr mode has exited
  40128. */
  40129. exitXRAsync(): Promise<void>;
  40130. /**
  40131. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40132. * @param sessionCreationOptions options for the XR session
  40133. * @param frameOfReference frame of reference of the XR session
  40134. * @returns promise that resolves after xr mode has entered
  40135. */
  40136. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  40137. /**
  40138. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40139. * @param ray ray to cast into the environment
  40140. * @returns Promise which resolves with a collision point in the environment if it exists
  40141. */
  40142. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40143. /**
  40144. * Updates the global position of the camera by moving the camera's container
  40145. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40146. * @param position The desired global position of the camera
  40147. */
  40148. setPositionOfCameraUsingContainer(position: Vector3): void;
  40149. /**
  40150. * Rotates the xr camera by rotating the camera's container around the camera's position
  40151. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40152. * @param rotation the desired quaternion rotation to apply to the camera
  40153. */
  40154. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40155. /**
  40156. * Checks if the creation options are supported by the xr session
  40157. * @param options creation options
  40158. * @returns true if supported
  40159. */
  40160. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40161. /**
  40162. * Disposes of the experience helper
  40163. */
  40164. dispose(): void;
  40165. }
  40166. }
  40167. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  40168. import { Nullable } from "babylonjs/types";
  40169. import { Observable } from "babylonjs/Misc/observable";
  40170. import { IDisposable, Scene } from "babylonjs/scene";
  40171. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40172. /**
  40173. * Button which can be used to enter a different mode of XR
  40174. */
  40175. export class WebXREnterExitUIButton {
  40176. /** button element */
  40177. element: HTMLElement;
  40178. /** XR initialization options for the button */
  40179. initializationOptions: XRSessionCreationOptions;
  40180. /**
  40181. * Creates a WebXREnterExitUIButton
  40182. * @param element button element
  40183. * @param initializationOptions XR initialization options for the button
  40184. */
  40185. constructor(
  40186. /** button element */
  40187. element: HTMLElement,
  40188. /** XR initialization options for the button */
  40189. initializationOptions: XRSessionCreationOptions);
  40190. /**
  40191. * Overwritable function which can be used to update the button's visuals when the state changes
  40192. * @param activeButton the current active button in the UI
  40193. */
  40194. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40195. }
  40196. /**
  40197. * Options to create the webXR UI
  40198. */
  40199. export class WebXREnterExitUIOptions {
  40200. /**
  40201. * Context to enter xr with
  40202. */
  40203. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  40204. /**
  40205. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40206. */
  40207. customButtons?: Array<WebXREnterExitUIButton>;
  40208. }
  40209. /**
  40210. * UI to allow the user to enter/exit XR mode
  40211. */
  40212. export class WebXREnterExitUI implements IDisposable {
  40213. private scene;
  40214. private _overlay;
  40215. private _buttons;
  40216. private _activeButton;
  40217. /**
  40218. * Fired every time the active button is changed.
  40219. *
  40220. * When xr is entered via a button that launches xr that button will be the callback parameter
  40221. *
  40222. * When exiting xr the callback parameter will be null)
  40223. */
  40224. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40225. /**
  40226. * Creates UI to allow the user to enter/exit XR mode
  40227. * @param scene the scene to add the ui to
  40228. * @param helper the xr experience helper to enter/exit xr with
  40229. * @param options options to configure the UI
  40230. * @returns the created ui
  40231. */
  40232. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40233. private constructor();
  40234. private _updateButtons;
  40235. /**
  40236. * Disposes of the object
  40237. */
  40238. dispose(): void;
  40239. }
  40240. }
  40241. declare module "babylonjs/Cameras/XR/webXRInput" {
  40242. import { IDisposable, Scene } from "babylonjs/scene";
  40243. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40244. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40245. /**
  40246. * Represents an XR input
  40247. */
  40248. export class WebXRController {
  40249. /**
  40250. * 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
  40251. */
  40252. grip?: AbstractMesh;
  40253. /**
  40254. * Pointer which can be used to select objects or attach a visible laser to
  40255. */
  40256. pointer: AbstractMesh;
  40257. /**
  40258. * Creates the controller
  40259. * @see https://doc.babylonjs.com/how_to/webxr
  40260. * @param scene the scene which the controller should be associated to
  40261. */
  40262. constructor(scene: Scene);
  40263. /**
  40264. * Disposes of the object
  40265. */
  40266. dispose(): void;
  40267. }
  40268. /**
  40269. * XR input used to track XR inputs such as controllers/rays
  40270. */
  40271. export class WebXRInput implements IDisposable {
  40272. private helper;
  40273. /**
  40274. * XR controllers being tracked
  40275. */
  40276. controllers: Array<WebXRController>;
  40277. private _tmpMatrix;
  40278. private _frameObserver;
  40279. /**
  40280. * Initializes the WebXRInput
  40281. * @param helper experience helper which the input should be created for
  40282. */
  40283. constructor(helper: WebXRExperienceHelper);
  40284. /**
  40285. * Disposes of the object
  40286. */
  40287. dispose(): void;
  40288. }
  40289. }
  40290. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  40291. import { Nullable } from "babylonjs/types";
  40292. import { IDisposable } from "babylonjs/scene";
  40293. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40294. /**
  40295. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40296. */
  40297. export class WebXRManagedOutputCanvas implements IDisposable {
  40298. private _canvas;
  40299. /**
  40300. * xrpresent context of the canvas which can be used to display/mirror xr content
  40301. */
  40302. canvasContext: Nullable<WebGLRenderingContext>;
  40303. /**
  40304. * Initializes the canvas to be added/removed upon entering/exiting xr
  40305. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40306. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40307. */
  40308. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40309. /**
  40310. * Disposes of the object
  40311. */
  40312. dispose(): void;
  40313. private _setManagedOutputCanvas;
  40314. private _addCanvas;
  40315. private _removeCanvas;
  40316. }
  40317. }
  40318. declare module "babylonjs/Cameras/XR/index" {
  40319. export * from "babylonjs/Cameras/XR/webXRCamera";
  40320. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  40321. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40322. export * from "babylonjs/Cameras/XR/webXRInput";
  40323. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  40324. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  40325. }
  40326. declare module "babylonjs/Cameras/RigModes/index" {
  40327. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40328. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40329. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  40330. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  40331. }
  40332. declare module "babylonjs/Cameras/index" {
  40333. export * from "babylonjs/Cameras/Inputs/index";
  40334. export * from "babylonjs/Cameras/cameraInputsManager";
  40335. export * from "babylonjs/Cameras/camera";
  40336. export * from "babylonjs/Cameras/targetCamera";
  40337. export * from "babylonjs/Cameras/freeCamera";
  40338. export * from "babylonjs/Cameras/freeCameraInputsManager";
  40339. export * from "babylonjs/Cameras/touchCamera";
  40340. export * from "babylonjs/Cameras/arcRotateCamera";
  40341. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  40342. export * from "babylonjs/Cameras/deviceOrientationCamera";
  40343. export * from "babylonjs/Cameras/flyCamera";
  40344. export * from "babylonjs/Cameras/flyCameraInputsManager";
  40345. export * from "babylonjs/Cameras/followCamera";
  40346. export * from "babylonjs/Cameras/gamepadCamera";
  40347. export * from "babylonjs/Cameras/Stereoscopic/index";
  40348. export * from "babylonjs/Cameras/universalCamera";
  40349. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  40350. export * from "babylonjs/Cameras/VR/index";
  40351. export * from "babylonjs/Cameras/XR/index";
  40352. export * from "babylonjs/Cameras/RigModes/index";
  40353. }
  40354. declare module "babylonjs/Collisions/index" {
  40355. export * from "babylonjs/Collisions/collider";
  40356. export * from "babylonjs/Collisions/collisionCoordinator";
  40357. export * from "babylonjs/Collisions/pickingInfo";
  40358. export * from "babylonjs/Collisions/intersectionInfo";
  40359. }
  40360. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  40361. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  40362. import { Vector3, Plane } from "babylonjs/Maths/math";
  40363. import { Ray } from "babylonjs/Culling/ray";
  40364. /**
  40365. * Contains an array of blocks representing the octree
  40366. */
  40367. export interface IOctreeContainer<T> {
  40368. /**
  40369. * Blocks within the octree
  40370. */
  40371. blocks: Array<OctreeBlock<T>>;
  40372. }
  40373. /**
  40374. * Class used to store a cell in an octree
  40375. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40376. */
  40377. export class OctreeBlock<T> {
  40378. /**
  40379. * Gets the content of the current block
  40380. */
  40381. entries: T[];
  40382. /**
  40383. * Gets the list of block children
  40384. */
  40385. blocks: Array<OctreeBlock<T>>;
  40386. private _depth;
  40387. private _maxDepth;
  40388. private _capacity;
  40389. private _minPoint;
  40390. private _maxPoint;
  40391. private _boundingVectors;
  40392. private _creationFunc;
  40393. /**
  40394. * Creates a new block
  40395. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40396. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40397. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40398. * @param depth defines the current depth of this block in the octree
  40399. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40400. * @param creationFunc defines a callback to call when an element is added to the block
  40401. */
  40402. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40403. /**
  40404. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40405. */
  40406. readonly capacity: number;
  40407. /**
  40408. * Gets the minimum vector (in world space) of the block's bounding box
  40409. */
  40410. readonly minPoint: Vector3;
  40411. /**
  40412. * Gets the maximum vector (in world space) of the block's bounding box
  40413. */
  40414. readonly maxPoint: Vector3;
  40415. /**
  40416. * Add a new element to this block
  40417. * @param entry defines the element to add
  40418. */
  40419. addEntry(entry: T): void;
  40420. /**
  40421. * Remove an element from this block
  40422. * @param entry defines the element to remove
  40423. */
  40424. removeEntry(entry: T): void;
  40425. /**
  40426. * Add an array of elements to this block
  40427. * @param entries defines the array of elements to add
  40428. */
  40429. addEntries(entries: T[]): void;
  40430. /**
  40431. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40432. * @param frustumPlanes defines the frustum planes to test
  40433. * @param selection defines the array to store current content if selection is positive
  40434. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40435. */
  40436. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40437. /**
  40438. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40439. * @param sphereCenter defines the bounding sphere center
  40440. * @param sphereRadius defines the bounding sphere radius
  40441. * @param selection defines the array to store current content if selection is positive
  40442. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40443. */
  40444. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40445. /**
  40446. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40447. * @param ray defines the ray to test with
  40448. * @param selection defines the array to store current content if selection is positive
  40449. */
  40450. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40451. /**
  40452. * Subdivide the content into child blocks (this block will then be empty)
  40453. */
  40454. createInnerBlocks(): void;
  40455. /**
  40456. * @hidden
  40457. */
  40458. 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;
  40459. }
  40460. }
  40461. declare module "babylonjs/Culling/Octrees/octree" {
  40462. import { SmartArray } from "babylonjs/Misc/smartArray";
  40463. import { Vector3, Plane } from "babylonjs/Maths/math";
  40464. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40465. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40466. import { Ray } from "babylonjs/Culling/ray";
  40467. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  40468. /**
  40469. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40470. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40471. */
  40472. export class Octree<T> {
  40473. /** 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.) */
  40474. maxDepth: number;
  40475. /**
  40476. * Blocks within the octree containing objects
  40477. */
  40478. blocks: Array<OctreeBlock<T>>;
  40479. /**
  40480. * Content stored in the octree
  40481. */
  40482. dynamicContent: T[];
  40483. private _maxBlockCapacity;
  40484. private _selectionContent;
  40485. private _creationFunc;
  40486. /**
  40487. * Creates a octree
  40488. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40489. * @param creationFunc function to be used to instatiate the octree
  40490. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40491. * @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.)
  40492. */
  40493. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40494. /** 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.) */
  40495. maxDepth?: number);
  40496. /**
  40497. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40498. * @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);
  40499. * @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);
  40500. * @param entries meshes to be added to the octree blocks
  40501. */
  40502. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40503. /**
  40504. * Adds a mesh to the octree
  40505. * @param entry Mesh to add to the octree
  40506. */
  40507. addMesh(entry: T): void;
  40508. /**
  40509. * Remove an element from the octree
  40510. * @param entry defines the element to remove
  40511. */
  40512. removeMesh(entry: T): void;
  40513. /**
  40514. * Selects an array of meshes within the frustum
  40515. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40516. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40517. * @returns array of meshes within the frustum
  40518. */
  40519. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40520. /**
  40521. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40522. * @param sphereCenter defines the bounding sphere center
  40523. * @param sphereRadius defines the bounding sphere radius
  40524. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40525. * @returns an array of objects that intersect the sphere
  40526. */
  40527. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40528. /**
  40529. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40530. * @param ray defines the ray to test with
  40531. * @returns array of intersected objects
  40532. */
  40533. intersectsRay(ray: Ray): SmartArray<T>;
  40534. /**
  40535. * Adds a mesh into the octree block if it intersects the block
  40536. */
  40537. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40538. /**
  40539. * Adds a submesh into the octree block if it intersects the block
  40540. */
  40541. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40542. }
  40543. }
  40544. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  40545. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  40546. import { Scene } from "babylonjs/scene";
  40547. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40548. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40549. import { Ray } from "babylonjs/Culling/ray";
  40550. import { Octree } from "babylonjs/Culling/Octrees/octree";
  40551. import { Collider } from "babylonjs/Collisions/collider";
  40552. module "babylonjs/scene" {
  40553. interface Scene {
  40554. /**
  40555. * @hidden
  40556. * Backing Filed
  40557. */
  40558. _selectionOctree: Octree<AbstractMesh>;
  40559. /**
  40560. * Gets the octree used to boost mesh selection (picking)
  40561. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40562. */
  40563. selectionOctree: Octree<AbstractMesh>;
  40564. /**
  40565. * Creates or updates the octree used to boost selection (picking)
  40566. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40567. * @param maxCapacity defines the maximum capacity per leaf
  40568. * @param maxDepth defines the maximum depth of the octree
  40569. * @returns an octree of AbstractMesh
  40570. */
  40571. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  40572. }
  40573. }
  40574. module "babylonjs/Meshes/abstractMesh" {
  40575. interface AbstractMesh {
  40576. /**
  40577. * @hidden
  40578. * Backing Field
  40579. */
  40580. _submeshesOctree: Octree<SubMesh>;
  40581. /**
  40582. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  40583. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  40584. * @param maxCapacity defines the maximum size of each block (64 by default)
  40585. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  40586. * @returns the new octree
  40587. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  40588. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40589. */
  40590. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  40591. }
  40592. }
  40593. /**
  40594. * Defines the octree scene component responsible to manage any octrees
  40595. * in a given scene.
  40596. */
  40597. export class OctreeSceneComponent {
  40598. /**
  40599. * The component name helpfull to identify the component in the list of scene components.
  40600. */
  40601. readonly name: string;
  40602. /**
  40603. * The scene the component belongs to.
  40604. */
  40605. scene: Scene;
  40606. /**
  40607. * Indicates if the meshes have been checked to make sure they are isEnabled()
  40608. */
  40609. readonly checksIsEnabled: boolean;
  40610. /**
  40611. * Creates a new instance of the component for the given scene
  40612. * @param scene Defines the scene to register the component in
  40613. */
  40614. constructor(scene: Scene);
  40615. /**
  40616. * Registers the component in a given scene
  40617. */
  40618. register(): void;
  40619. /**
  40620. * Return the list of active meshes
  40621. * @returns the list of active meshes
  40622. */
  40623. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40624. /**
  40625. * Return the list of active sub meshes
  40626. * @param mesh The mesh to get the candidates sub meshes from
  40627. * @returns the list of active sub meshes
  40628. */
  40629. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40630. private _tempRay;
  40631. /**
  40632. * Return the list of sub meshes intersecting with a given local ray
  40633. * @param mesh defines the mesh to find the submesh for
  40634. * @param localRay defines the ray in local space
  40635. * @returns the list of intersecting sub meshes
  40636. */
  40637. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  40638. /**
  40639. * Return the list of sub meshes colliding with a collider
  40640. * @param mesh defines the mesh to find the submesh for
  40641. * @param collider defines the collider to evaluate the collision against
  40642. * @returns the list of colliding sub meshes
  40643. */
  40644. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  40645. /**
  40646. * Rebuilds the elements related to this component in case of
  40647. * context lost for instance.
  40648. */
  40649. rebuild(): void;
  40650. /**
  40651. * Disposes the component and the associated ressources.
  40652. */
  40653. dispose(): void;
  40654. }
  40655. }
  40656. declare module "babylonjs/Culling/Octrees/index" {
  40657. export * from "babylonjs/Culling/Octrees/octree";
  40658. export * from "babylonjs/Culling/Octrees/octreeBlock";
  40659. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  40660. }
  40661. declare module "babylonjs/Culling/index" {
  40662. export * from "babylonjs/Culling/boundingBox";
  40663. export * from "babylonjs/Culling/boundingInfo";
  40664. export * from "babylonjs/Culling/boundingSphere";
  40665. export * from "babylonjs/Culling/Octrees/index";
  40666. export * from "babylonjs/Culling/ray";
  40667. }
  40668. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  40669. import { Vector3, Color4 } from "babylonjs/Maths/math";
  40670. import { Nullable } from "babylonjs/types";
  40671. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  40672. import { Scene } from "babylonjs/scene";
  40673. /**
  40674. * Class containing static functions to help procedurally build meshes
  40675. */
  40676. export class LinesBuilder {
  40677. /**
  40678. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  40679. * * 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
  40680. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  40681. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  40682. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  40683. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  40684. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  40685. * * 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
  40686. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  40687. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40688. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  40689. * @param name defines the name of the new line system
  40690. * @param options defines the options used to create the line system
  40691. * @param scene defines the hosting scene
  40692. * @returns a new line system mesh
  40693. */
  40694. static CreateLineSystem(name: string, options: {
  40695. lines: Vector3[][];
  40696. updatable?: boolean;
  40697. instance?: Nullable<LinesMesh>;
  40698. colors?: Nullable<Color4[][]>;
  40699. useVertexAlpha?: boolean;
  40700. }, scene: Nullable<Scene>): LinesMesh;
  40701. /**
  40702. * Creates a line mesh
  40703. * 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
  40704. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40705. * * The parameter `points` is an array successive Vector3
  40706. * * 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
  40707. * * The optional parameter `colors` is an array of successive Color4, one per line point
  40708. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  40709. * * When updating an instance, remember that only point positions can change, not the number of points
  40710. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40711. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  40712. * @param name defines the name of the new line system
  40713. * @param options defines the options used to create the line system
  40714. * @param scene defines the hosting scene
  40715. * @returns a new line mesh
  40716. */
  40717. static CreateLines(name: string, options: {
  40718. points: Vector3[];
  40719. updatable?: boolean;
  40720. instance?: Nullable<LinesMesh>;
  40721. colors?: Color4[];
  40722. useVertexAlpha?: boolean;
  40723. }, scene?: Nullable<Scene>): LinesMesh;
  40724. /**
  40725. * Creates a dashed line mesh
  40726. * * 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
  40727. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40728. * * The parameter `points` is an array successive Vector3
  40729. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  40730. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  40731. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  40732. * * 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
  40733. * * When updating an instance, remember that only point positions can change, not the number of points
  40734. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40735. * @param name defines the name of the mesh
  40736. * @param options defines the options used to create the mesh
  40737. * @param scene defines the hosting scene
  40738. * @returns the dashed line mesh
  40739. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  40740. */
  40741. static CreateDashedLines(name: string, options: {
  40742. points: Vector3[];
  40743. dashSize?: number;
  40744. gapSize?: number;
  40745. dashNb?: number;
  40746. updatable?: boolean;
  40747. instance?: LinesMesh;
  40748. }, scene?: Nullable<Scene>): LinesMesh;
  40749. }
  40750. }
  40751. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  40752. import { IDisposable, Scene } from "babylonjs/scene";
  40753. import { Nullable } from "babylonjs/types";
  40754. import { Observable } from "babylonjs/Misc/observable";
  40755. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40756. /**
  40757. * Renders a layer on top of an existing scene
  40758. */
  40759. export class UtilityLayerRenderer implements IDisposable {
  40760. /** the original scene that will be rendered on top of */
  40761. originalScene: Scene;
  40762. private _pointerCaptures;
  40763. private _lastPointerEvents;
  40764. private static _DefaultUtilityLayer;
  40765. private static _DefaultKeepDepthUtilityLayer;
  40766. /**
  40767. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  40768. */
  40769. pickUtilitySceneFirst: boolean;
  40770. /**
  40771. * 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)
  40772. */
  40773. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  40774. /**
  40775. * 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)
  40776. */
  40777. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  40778. /**
  40779. * The scene that is rendered on top of the original scene
  40780. */
  40781. utilityLayerScene: Scene;
  40782. /**
  40783. * If the utility layer should automatically be rendered on top of existing scene
  40784. */
  40785. shouldRender: boolean;
  40786. /**
  40787. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  40788. */
  40789. onlyCheckPointerDownEvents: boolean;
  40790. /**
  40791. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  40792. */
  40793. processAllEvents: boolean;
  40794. /**
  40795. * Observable raised when the pointer move from the utility layer scene to the main scene
  40796. */
  40797. onPointerOutObservable: Observable<number>;
  40798. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  40799. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  40800. private _afterRenderObserver;
  40801. private _sceneDisposeObserver;
  40802. private _originalPointerObserver;
  40803. /**
  40804. * Instantiates a UtilityLayerRenderer
  40805. * @param originalScene the original scene that will be rendered on top of
  40806. * @param handleEvents boolean indicating if the utility layer should handle events
  40807. */
  40808. constructor(
  40809. /** the original scene that will be rendered on top of */
  40810. originalScene: Scene, handleEvents?: boolean);
  40811. private _notifyObservers;
  40812. /**
  40813. * Renders the utility layers scene on top of the original scene
  40814. */
  40815. render(): void;
  40816. /**
  40817. * Disposes of the renderer
  40818. */
  40819. dispose(): void;
  40820. private _updateCamera;
  40821. }
  40822. }
  40823. declare module "babylonjs/Gizmos/gizmo" {
  40824. import { Nullable } from "babylonjs/types";
  40825. import { IDisposable } from "babylonjs/scene";
  40826. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40827. import { Mesh } from "babylonjs/Meshes/mesh";
  40828. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  40829. /**
  40830. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  40831. */
  40832. export class Gizmo implements IDisposable {
  40833. /** The utility layer the gizmo will be added to */
  40834. gizmoLayer: UtilityLayerRenderer;
  40835. /**
  40836. * The root mesh of the gizmo
  40837. */
  40838. _rootMesh: Mesh;
  40839. private _attachedMesh;
  40840. /**
  40841. * Ratio for the scale of the gizmo (Default: 1)
  40842. */
  40843. scaleRatio: number;
  40844. private _tmpMatrix;
  40845. /**
  40846. * If a custom mesh has been set (Default: false)
  40847. */
  40848. protected _customMeshSet: boolean;
  40849. /**
  40850. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  40851. * * When set, interactions will be enabled
  40852. */
  40853. attachedMesh: Nullable<AbstractMesh>;
  40854. /**
  40855. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  40856. * @param mesh The mesh to replace the default mesh of the gizmo
  40857. */
  40858. setCustomMesh(mesh: Mesh): void;
  40859. /**
  40860. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  40861. */
  40862. updateGizmoRotationToMatchAttachedMesh: boolean;
  40863. /**
  40864. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  40865. */
  40866. updateGizmoPositionToMatchAttachedMesh: boolean;
  40867. /**
  40868. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  40869. */
  40870. protected _updateScale: boolean;
  40871. protected _interactionsEnabled: boolean;
  40872. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40873. private _beforeRenderObserver;
  40874. /**
  40875. * Creates a gizmo
  40876. * @param gizmoLayer The utility layer the gizmo will be added to
  40877. */
  40878. constructor(
  40879. /** The utility layer the gizmo will be added to */
  40880. gizmoLayer?: UtilityLayerRenderer);
  40881. private _tempVector;
  40882. /**
  40883. * @hidden
  40884. * Updates the gizmo to match the attached mesh's position/rotation
  40885. */
  40886. protected _update(): void;
  40887. /**
  40888. * Disposes of the gizmo
  40889. */
  40890. dispose(): void;
  40891. }
  40892. }
  40893. declare module "babylonjs/Gizmos/axisDragGizmo" {
  40894. import { Observable } from "babylonjs/Misc/observable";
  40895. import { Nullable } from "babylonjs/types";
  40896. import { Vector3, Color3 } from "babylonjs/Maths/math";
  40897. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40898. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40899. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  40900. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  40901. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  40902. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  40903. import { Scene } from "babylonjs/scene";
  40904. /**
  40905. * Single axis drag gizmo
  40906. */
  40907. export class AxisDragGizmo extends Gizmo {
  40908. /**
  40909. * Drag behavior responsible for the gizmos dragging interactions
  40910. */
  40911. dragBehavior: PointerDragBehavior;
  40912. private _pointerObserver;
  40913. /**
  40914. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40915. */
  40916. snapDistance: number;
  40917. /**
  40918. * Event that fires each time the gizmo snaps to a new location.
  40919. * * snapDistance is the the change in distance
  40920. */
  40921. onSnapObservable: Observable<{
  40922. snapDistance: number;
  40923. }>;
  40924. /** @hidden */
  40925. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  40926. /** @hidden */
  40927. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  40928. /**
  40929. * Creates an AxisDragGizmo
  40930. * @param gizmoLayer The utility layer the gizmo will be added to
  40931. * @param dragAxis The axis which the gizmo will be able to drag on
  40932. * @param color The color of the gizmo
  40933. */
  40934. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  40935. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40936. /**
  40937. * Disposes of the gizmo
  40938. */
  40939. dispose(): void;
  40940. }
  40941. }
  40942. declare module "babylonjs/Debug/axesViewer" {
  40943. import { Vector3 } from "babylonjs/Maths/math";
  40944. import { Nullable } from "babylonjs/types";
  40945. import { Scene } from "babylonjs/scene";
  40946. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40947. /**
  40948. * The Axes viewer will show 3 axes in a specific point in space
  40949. */
  40950. export class AxesViewer {
  40951. private _xAxis;
  40952. private _yAxis;
  40953. private _zAxis;
  40954. private _scaleLinesFactor;
  40955. private _instanced;
  40956. /**
  40957. * Gets the hosting scene
  40958. */
  40959. scene: Scene;
  40960. /**
  40961. * Gets or sets a number used to scale line length
  40962. */
  40963. scaleLines: number;
  40964. /** Gets the node hierarchy used to render x-axis */
  40965. readonly xAxis: TransformNode;
  40966. /** Gets the node hierarchy used to render y-axis */
  40967. readonly yAxis: TransformNode;
  40968. /** Gets the node hierarchy used to render z-axis */
  40969. readonly zAxis: TransformNode;
  40970. /**
  40971. * Creates a new AxesViewer
  40972. * @param scene defines the hosting scene
  40973. * @param scaleLines defines a number used to scale line length (1 by default)
  40974. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  40975. * @param xAxis defines the node hierarchy used to render the x-axis
  40976. * @param yAxis defines the node hierarchy used to render the y-axis
  40977. * @param zAxis defines the node hierarchy used to render the z-axis
  40978. */
  40979. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  40980. /**
  40981. * Force the viewer to update
  40982. * @param position defines the position of the viewer
  40983. * @param xaxis defines the x axis of the viewer
  40984. * @param yaxis defines the y axis of the viewer
  40985. * @param zaxis defines the z axis of the viewer
  40986. */
  40987. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  40988. /**
  40989. * Creates an instance of this axes viewer.
  40990. * @returns a new axes viewer with instanced meshes
  40991. */
  40992. createInstance(): AxesViewer;
  40993. /** Releases resources */
  40994. dispose(): void;
  40995. private static _SetRenderingGroupId;
  40996. }
  40997. }
  40998. declare module "babylonjs/Debug/boneAxesViewer" {
  40999. import { Nullable } from "babylonjs/types";
  41000. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  41001. import { Vector3 } from "babylonjs/Maths/math";
  41002. import { Mesh } from "babylonjs/Meshes/mesh";
  41003. import { Bone } from "babylonjs/Bones/bone";
  41004. import { Scene } from "babylonjs/scene";
  41005. /**
  41006. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  41007. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  41008. */
  41009. export class BoneAxesViewer extends AxesViewer {
  41010. /**
  41011. * Gets or sets the target mesh where to display the axes viewer
  41012. */
  41013. mesh: Nullable<Mesh>;
  41014. /**
  41015. * Gets or sets the target bone where to display the axes viewer
  41016. */
  41017. bone: Nullable<Bone>;
  41018. /** Gets current position */
  41019. pos: Vector3;
  41020. /** Gets direction of X axis */
  41021. xaxis: Vector3;
  41022. /** Gets direction of Y axis */
  41023. yaxis: Vector3;
  41024. /** Gets direction of Z axis */
  41025. zaxis: Vector3;
  41026. /**
  41027. * Creates a new BoneAxesViewer
  41028. * @param scene defines the hosting scene
  41029. * @param bone defines the target bone
  41030. * @param mesh defines the target mesh
  41031. * @param scaleLines defines a scaling factor for line length (1 by default)
  41032. */
  41033. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  41034. /**
  41035. * Force the viewer to update
  41036. */
  41037. update(): void;
  41038. /** Releases resources */
  41039. dispose(): void;
  41040. }
  41041. }
  41042. declare module "babylonjs/Debug/debugLayer" {
  41043. import { Observable } from "babylonjs/Misc/observable";
  41044. import { Scene } from "babylonjs/scene";
  41045. /**
  41046. * Interface used to define scene explorer extensibility option
  41047. */
  41048. export interface IExplorerExtensibilityOption {
  41049. /**
  41050. * Define the option label
  41051. */
  41052. label: string;
  41053. /**
  41054. * Defines the action to execute on click
  41055. */
  41056. action: (entity: any) => void;
  41057. }
  41058. /**
  41059. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  41060. */
  41061. export interface IExplorerExtensibilityGroup {
  41062. /**
  41063. * Defines a predicate to test if a given type mut be extended
  41064. */
  41065. predicate: (entity: any) => boolean;
  41066. /**
  41067. * Gets the list of options added to a type
  41068. */
  41069. entries: IExplorerExtensibilityOption[];
  41070. }
  41071. /**
  41072. * Interface used to define the options to use to create the Inspector
  41073. */
  41074. export interface IInspectorOptions {
  41075. /**
  41076. * Display in overlay mode (default: false)
  41077. */
  41078. overlay?: boolean;
  41079. /**
  41080. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  41081. */
  41082. globalRoot?: HTMLElement;
  41083. /**
  41084. * Display the Scene explorer
  41085. */
  41086. showExplorer?: boolean;
  41087. /**
  41088. * Display the property inspector
  41089. */
  41090. showInspector?: boolean;
  41091. /**
  41092. * Display in embed mode (both panes on the right)
  41093. */
  41094. embedMode?: boolean;
  41095. /**
  41096. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  41097. */
  41098. handleResize?: boolean;
  41099. /**
  41100. * Allow the panes to popup (default: true)
  41101. */
  41102. enablePopup?: boolean;
  41103. /**
  41104. * Allow the panes to be closed by users (default: true)
  41105. */
  41106. enableClose?: boolean;
  41107. /**
  41108. * Optional list of extensibility entries
  41109. */
  41110. explorerExtensibility?: IExplorerExtensibilityGroup[];
  41111. /**
  41112. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  41113. */
  41114. inspectorURL?: string;
  41115. }
  41116. module "babylonjs/scene" {
  41117. interface Scene {
  41118. /**
  41119. * @hidden
  41120. * Backing field
  41121. */
  41122. _debugLayer: DebugLayer;
  41123. /**
  41124. * Gets the debug layer (aka Inspector) associated with the scene
  41125. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41126. */
  41127. debugLayer: DebugLayer;
  41128. }
  41129. }
  41130. /**
  41131. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41132. * what is happening in your scene
  41133. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41134. */
  41135. export class DebugLayer {
  41136. /**
  41137. * Define the url to get the inspector script from.
  41138. * By default it uses the babylonjs CDN.
  41139. * @ignoreNaming
  41140. */
  41141. static InspectorURL: string;
  41142. private _scene;
  41143. private BJSINSPECTOR;
  41144. /**
  41145. * Observable triggered when a property is changed through the inspector.
  41146. */
  41147. onPropertyChangedObservable: Observable<{
  41148. object: any;
  41149. property: string;
  41150. value: any;
  41151. initialValue: any;
  41152. }>;
  41153. /**
  41154. * Instantiates a new debug layer.
  41155. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41156. * what is happening in your scene
  41157. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41158. * @param scene Defines the scene to inspect
  41159. */
  41160. constructor(scene: Scene);
  41161. /** Creates the inspector window. */
  41162. private _createInspector;
  41163. /**
  41164. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  41165. * @param entity defines the entity to select
  41166. * @param lineContainerTitle defines the specific block to highlight
  41167. */
  41168. select(entity: any, lineContainerTitle?: string): void;
  41169. /** Get the inspector from bundle or global */
  41170. private _getGlobalInspector;
  41171. /**
  41172. * Get if the inspector is visible or not.
  41173. * @returns true if visible otherwise, false
  41174. */
  41175. isVisible(): boolean;
  41176. /**
  41177. * Hide the inspector and close its window.
  41178. */
  41179. hide(): void;
  41180. /**
  41181. * Launch the debugLayer.
  41182. * @param config Define the configuration of the inspector
  41183. * @return a promise fulfilled when the debug layer is visible
  41184. */
  41185. show(config?: IInspectorOptions): Promise<DebugLayer>;
  41186. }
  41187. }
  41188. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  41189. import { Nullable } from "babylonjs/types";
  41190. import { Scene } from "babylonjs/scene";
  41191. import { Vector4, Color4 } from "babylonjs/Maths/math";
  41192. import { Mesh } from "babylonjs/Meshes/mesh";
  41193. /**
  41194. * Class containing static functions to help procedurally build meshes
  41195. */
  41196. export class BoxBuilder {
  41197. /**
  41198. * Creates a box mesh
  41199. * * The parameter `size` sets the size (float) of each box side (default 1)
  41200. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  41201. * * 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)
  41202. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  41203. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41204. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41205. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41206. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  41207. * @param name defines the name of the mesh
  41208. * @param options defines the options used to create the mesh
  41209. * @param scene defines the hosting scene
  41210. * @returns the box mesh
  41211. */
  41212. static CreateBox(name: string, options: {
  41213. size?: number;
  41214. width?: number;
  41215. height?: number;
  41216. depth?: number;
  41217. faceUV?: Vector4[];
  41218. faceColors?: Color4[];
  41219. sideOrientation?: number;
  41220. frontUVs?: Vector4;
  41221. backUVs?: Vector4;
  41222. updatable?: boolean;
  41223. }, scene?: Nullable<Scene>): Mesh;
  41224. }
  41225. }
  41226. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  41227. import { Vector4 } from "babylonjs/Maths/math";
  41228. import { Mesh } from "babylonjs/Meshes/mesh";
  41229. /**
  41230. * Class containing static functions to help procedurally build meshes
  41231. */
  41232. export class SphereBuilder {
  41233. /**
  41234. * Creates a sphere mesh
  41235. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  41236. * * 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`)
  41237. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  41238. * * 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
  41239. * * 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)
  41240. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41241. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41242. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41243. * @param name defines the name of the mesh
  41244. * @param options defines the options used to create the mesh
  41245. * @param scene defines the hosting scene
  41246. * @returns the sphere mesh
  41247. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  41248. */
  41249. static CreateSphere(name: string, options: {
  41250. segments?: number;
  41251. diameter?: number;
  41252. diameterX?: number;
  41253. diameterY?: number;
  41254. diameterZ?: number;
  41255. arc?: number;
  41256. slice?: number;
  41257. sideOrientation?: number;
  41258. frontUVs?: Vector4;
  41259. backUVs?: Vector4;
  41260. updatable?: boolean;
  41261. }, scene: any): Mesh;
  41262. }
  41263. }
  41264. declare module "babylonjs/Debug/physicsViewer" {
  41265. import { Nullable } from "babylonjs/types";
  41266. import { Scene } from "babylonjs/scene";
  41267. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41268. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  41269. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  41270. /**
  41271. * Used to show the physics impostor around the specific mesh
  41272. */
  41273. export class PhysicsViewer {
  41274. /** @hidden */
  41275. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  41276. /** @hidden */
  41277. protected _meshes: Array<Nullable<AbstractMesh>>;
  41278. /** @hidden */
  41279. protected _scene: Nullable<Scene>;
  41280. /** @hidden */
  41281. protected _numMeshes: number;
  41282. /** @hidden */
  41283. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  41284. private _renderFunction;
  41285. private _utilityLayer;
  41286. private _debugBoxMesh;
  41287. private _debugSphereMesh;
  41288. private _debugMaterial;
  41289. /**
  41290. * Creates a new PhysicsViewer
  41291. * @param scene defines the hosting scene
  41292. */
  41293. constructor(scene: Scene);
  41294. /** @hidden */
  41295. protected _updateDebugMeshes(): void;
  41296. /**
  41297. * Renders a specified physic impostor
  41298. * @param impostor defines the impostor to render
  41299. * @returns the new debug mesh used to render the impostor
  41300. */
  41301. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  41302. /**
  41303. * Hides a specified physic impostor
  41304. * @param impostor defines the impostor to hide
  41305. */
  41306. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  41307. private _getDebugMaterial;
  41308. private _getDebugBoxMesh;
  41309. private _getDebugSphereMesh;
  41310. private _getDebugMesh;
  41311. /** Releases all resources */
  41312. dispose(): void;
  41313. }
  41314. }
  41315. declare module "babylonjs/Debug/rayHelper" {
  41316. import { Nullable } from "babylonjs/types";
  41317. import { Ray } from "babylonjs/Culling/ray";
  41318. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41319. import { Scene } from "babylonjs/scene";
  41320. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41321. import "babylonjs/Meshes/Builders/linesBuilder";
  41322. /**
  41323. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41324. * in order to better appreciate the issue one might have.
  41325. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41326. */
  41327. export class RayHelper {
  41328. /**
  41329. * Defines the ray we are currently tryin to visualize.
  41330. */
  41331. ray: Nullable<Ray>;
  41332. private _renderPoints;
  41333. private _renderLine;
  41334. private _renderFunction;
  41335. private _scene;
  41336. private _updateToMeshFunction;
  41337. private _attachedToMesh;
  41338. private _meshSpaceDirection;
  41339. private _meshSpaceOrigin;
  41340. /**
  41341. * Helper function to create a colored helper in a scene in one line.
  41342. * @param ray Defines the ray we are currently tryin to visualize
  41343. * @param scene Defines the scene the ray is used in
  41344. * @param color Defines the color we want to see the ray in
  41345. * @returns The newly created ray helper.
  41346. */
  41347. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  41348. /**
  41349. * Instantiate a new ray helper.
  41350. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41351. * in order to better appreciate the issue one might have.
  41352. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41353. * @param ray Defines the ray we are currently tryin to visualize
  41354. */
  41355. constructor(ray: Ray);
  41356. /**
  41357. * Shows the ray we are willing to debug.
  41358. * @param scene Defines the scene the ray needs to be rendered in
  41359. * @param color Defines the color the ray needs to be rendered in
  41360. */
  41361. show(scene: Scene, color?: Color3): void;
  41362. /**
  41363. * Hides the ray we are debugging.
  41364. */
  41365. hide(): void;
  41366. private _render;
  41367. /**
  41368. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  41369. * @param mesh Defines the mesh we want the helper attached to
  41370. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  41371. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  41372. * @param length Defines the length of the ray
  41373. */
  41374. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  41375. /**
  41376. * Detach the ray helper from the mesh it has previously been attached to.
  41377. */
  41378. detachFromMesh(): void;
  41379. private _updateToMesh;
  41380. /**
  41381. * Dispose the helper and release its associated resources.
  41382. */
  41383. dispose(): void;
  41384. }
  41385. }
  41386. declare module "babylonjs/Debug/skeletonViewer" {
  41387. import { Color3 } from "babylonjs/Maths/math";
  41388. import { Scene } from "babylonjs/scene";
  41389. import { Nullable } from "babylonjs/types";
  41390. import { Skeleton } from "babylonjs/Bones/skeleton";
  41391. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41392. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  41393. /**
  41394. * Class used to render a debug view of a given skeleton
  41395. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  41396. */
  41397. export class SkeletonViewer {
  41398. /** defines the skeleton to render */
  41399. skeleton: Skeleton;
  41400. /** defines the mesh attached to the skeleton */
  41401. mesh: AbstractMesh;
  41402. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41403. autoUpdateBonesMatrices: boolean;
  41404. /** defines the rendering group id to use with the viewer */
  41405. renderingGroupId: number;
  41406. /** Gets or sets the color used to render the skeleton */
  41407. color: Color3;
  41408. private _scene;
  41409. private _debugLines;
  41410. private _debugMesh;
  41411. private _isEnabled;
  41412. private _renderFunction;
  41413. private _utilityLayer;
  41414. /**
  41415. * Returns the mesh used to render the bones
  41416. */
  41417. readonly debugMesh: Nullable<LinesMesh>;
  41418. /**
  41419. * Creates a new SkeletonViewer
  41420. * @param skeleton defines the skeleton to render
  41421. * @param mesh defines the mesh attached to the skeleton
  41422. * @param scene defines the hosting scene
  41423. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  41424. * @param renderingGroupId defines the rendering group id to use with the viewer
  41425. */
  41426. constructor(
  41427. /** defines the skeleton to render */
  41428. skeleton: Skeleton,
  41429. /** defines the mesh attached to the skeleton */
  41430. mesh: AbstractMesh, scene: Scene,
  41431. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41432. autoUpdateBonesMatrices?: boolean,
  41433. /** defines the rendering group id to use with the viewer */
  41434. renderingGroupId?: number);
  41435. /** Gets or sets a boolean indicating if the viewer is enabled */
  41436. isEnabled: boolean;
  41437. private _getBonePosition;
  41438. private _getLinesForBonesWithLength;
  41439. private _getLinesForBonesNoLength;
  41440. /** Update the viewer to sync with current skeleton state */
  41441. update(): void;
  41442. /** Release associated resources */
  41443. dispose(): void;
  41444. }
  41445. }
  41446. declare module "babylonjs/Debug/index" {
  41447. export * from "babylonjs/Debug/axesViewer";
  41448. export * from "babylonjs/Debug/boneAxesViewer";
  41449. export * from "babylonjs/Debug/debugLayer";
  41450. export * from "babylonjs/Debug/physicsViewer";
  41451. export * from "babylonjs/Debug/rayHelper";
  41452. export * from "babylonjs/Debug/skeletonViewer";
  41453. }
  41454. declare module "babylonjs/Engines/nullEngine" {
  41455. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  41456. import { Scene } from "babylonjs/scene";
  41457. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  41458. import { Engine } from "babylonjs/Engines/engine";
  41459. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  41460. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  41461. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41462. import { Effect } from "babylonjs/Materials/effect";
  41463. /**
  41464. * Options to create the null engine
  41465. */
  41466. export class NullEngineOptions {
  41467. /**
  41468. * Render width (Default: 512)
  41469. */
  41470. renderWidth: number;
  41471. /**
  41472. * Render height (Default: 256)
  41473. */
  41474. renderHeight: number;
  41475. /**
  41476. * Texture size (Default: 512)
  41477. */
  41478. textureSize: number;
  41479. /**
  41480. * If delta time between frames should be constant
  41481. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41482. */
  41483. deterministicLockstep: boolean;
  41484. /**
  41485. * Maximum about of steps between frames (Default: 4)
  41486. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41487. */
  41488. lockstepMaxSteps: number;
  41489. }
  41490. /**
  41491. * The null engine class provides support for headless version of babylon.js.
  41492. * This can be used in server side scenario or for testing purposes
  41493. */
  41494. export class NullEngine extends Engine {
  41495. private _options;
  41496. /**
  41497. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41498. */
  41499. isDeterministicLockStep(): boolean;
  41500. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  41501. getLockstepMaxSteps(): number;
  41502. /**
  41503. * Sets hardware scaling, used to save performance if needed
  41504. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  41505. */
  41506. getHardwareScalingLevel(): number;
  41507. constructor(options?: NullEngineOptions);
  41508. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41509. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  41510. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41511. getRenderWidth(useScreen?: boolean): number;
  41512. getRenderHeight(useScreen?: boolean): number;
  41513. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  41514. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  41515. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  41516. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  41517. bindSamplers(effect: Effect): void;
  41518. enableEffect(effect: Effect): void;
  41519. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41520. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  41521. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  41522. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  41523. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  41524. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  41525. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  41526. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  41527. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  41528. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  41529. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  41530. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  41531. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  41532. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  41533. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  41534. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41535. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41536. setFloat(uniform: WebGLUniformLocation, value: number): void;
  41537. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  41538. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  41539. setBool(uniform: WebGLUniformLocation, bool: number): void;
  41540. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  41541. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  41542. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  41543. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  41544. bindBuffers(vertexBuffers: {
  41545. [key: string]: VertexBuffer;
  41546. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  41547. wipeCaches(bruteForce?: boolean): void;
  41548. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  41549. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  41550. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41551. /** @hidden */
  41552. _createTexture(): WebGLTexture;
  41553. /** @hidden */
  41554. _releaseTexture(texture: InternalTexture): void;
  41555. 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;
  41556. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  41557. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  41558. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  41559. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  41560. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41561. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  41562. areAllEffectsReady(): boolean;
  41563. /**
  41564. * @hidden
  41565. * Get the current error code of the webGL context
  41566. * @returns the error code
  41567. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41568. */
  41569. getError(): number;
  41570. /** @hidden */
  41571. _getUnpackAlignement(): number;
  41572. /** @hidden */
  41573. _unpackFlipY(value: boolean): void;
  41574. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  41575. /**
  41576. * Updates a dynamic vertex buffer.
  41577. * @param vertexBuffer the vertex buffer to update
  41578. * @param data the data used to update the vertex buffer
  41579. * @param byteOffset the byte offset of the data (optional)
  41580. * @param byteLength the byte length of the data (optional)
  41581. */
  41582. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  41583. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  41584. /** @hidden */
  41585. _bindTexture(channel: number, texture: InternalTexture): void;
  41586. /** @hidden */
  41587. _releaseBuffer(buffer: WebGLBuffer): boolean;
  41588. releaseEffects(): void;
  41589. displayLoadingUI(): void;
  41590. hideLoadingUI(): void;
  41591. /** @hidden */
  41592. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41593. /** @hidden */
  41594. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41595. /** @hidden */
  41596. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41597. /** @hidden */
  41598. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  41599. }
  41600. }
  41601. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  41602. import { Nullable, int } from "babylonjs/types";
  41603. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  41604. /** @hidden */
  41605. export class _OcclusionDataStorage {
  41606. /** @hidden */
  41607. occlusionInternalRetryCounter: number;
  41608. /** @hidden */
  41609. isOcclusionQueryInProgress: boolean;
  41610. /** @hidden */
  41611. isOccluded: boolean;
  41612. /** @hidden */
  41613. occlusionRetryCount: number;
  41614. /** @hidden */
  41615. occlusionType: number;
  41616. /** @hidden */
  41617. occlusionQueryAlgorithmType: number;
  41618. }
  41619. module "babylonjs/Engines/engine" {
  41620. interface Engine {
  41621. /**
  41622. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  41623. * @return the new query
  41624. */
  41625. createQuery(): WebGLQuery;
  41626. /**
  41627. * Delete and release a webGL query
  41628. * @param query defines the query to delete
  41629. * @return the current engine
  41630. */
  41631. deleteQuery(query: WebGLQuery): Engine;
  41632. /**
  41633. * Check if a given query has resolved and got its value
  41634. * @param query defines the query to check
  41635. * @returns true if the query got its value
  41636. */
  41637. isQueryResultAvailable(query: WebGLQuery): boolean;
  41638. /**
  41639. * Gets the value of a given query
  41640. * @param query defines the query to check
  41641. * @returns the value of the query
  41642. */
  41643. getQueryResult(query: WebGLQuery): number;
  41644. /**
  41645. * Initiates an occlusion query
  41646. * @param algorithmType defines the algorithm to use
  41647. * @param query defines the query to use
  41648. * @returns the current engine
  41649. * @see http://doc.babylonjs.com/features/occlusionquery
  41650. */
  41651. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  41652. /**
  41653. * Ends an occlusion query
  41654. * @see http://doc.babylonjs.com/features/occlusionquery
  41655. * @param algorithmType defines the algorithm to use
  41656. * @returns the current engine
  41657. */
  41658. endOcclusionQuery(algorithmType: number): Engine;
  41659. /**
  41660. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  41661. * Please note that only one query can be issued at a time
  41662. * @returns a time token used to track the time span
  41663. */
  41664. startTimeQuery(): Nullable<_TimeToken>;
  41665. /**
  41666. * Ends a time query
  41667. * @param token defines the token used to measure the time span
  41668. * @returns the time spent (in ns)
  41669. */
  41670. endTimeQuery(token: _TimeToken): int;
  41671. /** @hidden */
  41672. _currentNonTimestampToken: Nullable<_TimeToken>;
  41673. /** @hidden */
  41674. _createTimeQuery(): WebGLQuery;
  41675. /** @hidden */
  41676. _deleteTimeQuery(query: WebGLQuery): void;
  41677. /** @hidden */
  41678. _getGlAlgorithmType(algorithmType: number): number;
  41679. /** @hidden */
  41680. _getTimeQueryResult(query: WebGLQuery): any;
  41681. /** @hidden */
  41682. _getTimeQueryAvailability(query: WebGLQuery): any;
  41683. }
  41684. }
  41685. module "babylonjs/Meshes/abstractMesh" {
  41686. interface AbstractMesh {
  41687. /**
  41688. * Backing filed
  41689. * @hidden
  41690. */
  41691. __occlusionDataStorage: _OcclusionDataStorage;
  41692. /**
  41693. * Access property
  41694. * @hidden
  41695. */
  41696. _occlusionDataStorage: _OcclusionDataStorage;
  41697. /**
  41698. * 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.
  41699. * The default value is -1 which means don't break the query and wait till the result
  41700. * @see http://doc.babylonjs.com/features/occlusionquery
  41701. */
  41702. occlusionRetryCount: number;
  41703. /**
  41704. * 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:
  41705. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  41706. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  41707. * * 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.
  41708. * @see http://doc.babylonjs.com/features/occlusionquery
  41709. */
  41710. occlusionType: number;
  41711. /**
  41712. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  41713. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  41714. * * 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.
  41715. * @see http://doc.babylonjs.com/features/occlusionquery
  41716. */
  41717. occlusionQueryAlgorithmType: number;
  41718. /**
  41719. * 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
  41720. * @see http://doc.babylonjs.com/features/occlusionquery
  41721. */
  41722. isOccluded: boolean;
  41723. /**
  41724. * Flag to check the progress status of the query
  41725. * @see http://doc.babylonjs.com/features/occlusionquery
  41726. */
  41727. isOcclusionQueryInProgress: boolean;
  41728. }
  41729. }
  41730. }
  41731. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  41732. import { Nullable } from "babylonjs/types";
  41733. /** @hidden */
  41734. export var _forceTransformFeedbackToBundle: boolean;
  41735. module "babylonjs/Engines/engine" {
  41736. interface Engine {
  41737. /**
  41738. * Creates a webGL transform feedback object
  41739. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  41740. * @returns the webGL transform feedback object
  41741. */
  41742. createTransformFeedback(): WebGLTransformFeedback;
  41743. /**
  41744. * Delete a webGL transform feedback object
  41745. * @param value defines the webGL transform feedback object to delete
  41746. */
  41747. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  41748. /**
  41749. * Bind a webGL transform feedback object to the webgl context
  41750. * @param value defines the webGL transform feedback object to bind
  41751. */
  41752. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  41753. /**
  41754. * Begins a transform feedback operation
  41755. * @param usePoints defines if points or triangles must be used
  41756. */
  41757. beginTransformFeedback(usePoints: boolean): void;
  41758. /**
  41759. * Ends a transform feedback operation
  41760. */
  41761. endTransformFeedback(): void;
  41762. /**
  41763. * Specify the varyings to use with transform feedback
  41764. * @param program defines the associated webGL program
  41765. * @param value defines the list of strings representing the varying names
  41766. */
  41767. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  41768. /**
  41769. * Bind a webGL buffer for a transform feedback operation
  41770. * @param value defines the webGL buffer to bind
  41771. */
  41772. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  41773. }
  41774. }
  41775. }
  41776. declare module "babylonjs/Engines/Extensions/index" {
  41777. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  41778. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  41779. }
  41780. declare module "babylonjs/Engines/index" {
  41781. export * from "babylonjs/Engines/constants";
  41782. export * from "babylonjs/Engines/engine";
  41783. export * from "babylonjs/Engines/engineStore";
  41784. export * from "babylonjs/Engines/nullEngine";
  41785. export * from "babylonjs/Engines/Extensions/index";
  41786. }
  41787. declare module "babylonjs/Events/clipboardEvents" {
  41788. /**
  41789. * Gather the list of clipboard event types as constants.
  41790. */
  41791. export class ClipboardEventTypes {
  41792. /**
  41793. * The clipboard event is fired when a copy command is active (pressed).
  41794. */
  41795. static readonly COPY: number;
  41796. /**
  41797. * The clipboard event is fired when a cut command is active (pressed).
  41798. */
  41799. static readonly CUT: number;
  41800. /**
  41801. * The clipboard event is fired when a paste command is active (pressed).
  41802. */
  41803. static readonly PASTE: number;
  41804. }
  41805. /**
  41806. * This class is used to store clipboard related info for the onClipboardObservable event.
  41807. */
  41808. export class ClipboardInfo {
  41809. /**
  41810. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41811. */
  41812. type: number;
  41813. /**
  41814. * Defines the related dom event
  41815. */
  41816. event: ClipboardEvent;
  41817. /**
  41818. *Creates an instance of ClipboardInfo.
  41819. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  41820. * @param event Defines the related dom event
  41821. */
  41822. constructor(
  41823. /**
  41824. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41825. */
  41826. type: number,
  41827. /**
  41828. * Defines the related dom event
  41829. */
  41830. event: ClipboardEvent);
  41831. /**
  41832. * Get the clipboard event's type from the keycode.
  41833. * @param keyCode Defines the keyCode for the current keyboard event.
  41834. * @return {number}
  41835. */
  41836. static GetTypeFromCharacter(keyCode: number): number;
  41837. }
  41838. }
  41839. declare module "babylonjs/Events/index" {
  41840. export * from "babylonjs/Events/keyboardEvents";
  41841. export * from "babylonjs/Events/pointerEvents";
  41842. export * from "babylonjs/Events/clipboardEvents";
  41843. }
  41844. declare module "babylonjs/Loading/sceneLoader" {
  41845. import { Observable } from "babylonjs/Misc/observable";
  41846. import { Nullable } from "babylonjs/types";
  41847. import { Scene } from "babylonjs/scene";
  41848. import { Engine } from "babylonjs/Engines/engine";
  41849. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41850. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  41851. import { AssetContainer } from "babylonjs/assetContainer";
  41852. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  41853. import { Skeleton } from "babylonjs/Bones/skeleton";
  41854. /**
  41855. * Class used to represent data loading progression
  41856. */
  41857. export class SceneLoaderProgressEvent {
  41858. /** defines if data length to load can be evaluated */
  41859. readonly lengthComputable: boolean;
  41860. /** defines the loaded data length */
  41861. readonly loaded: number;
  41862. /** defines the data length to load */
  41863. readonly total: number;
  41864. /**
  41865. * Create a new progress event
  41866. * @param lengthComputable defines if data length to load can be evaluated
  41867. * @param loaded defines the loaded data length
  41868. * @param total defines the data length to load
  41869. */
  41870. constructor(
  41871. /** defines if data length to load can be evaluated */
  41872. lengthComputable: boolean,
  41873. /** defines the loaded data length */
  41874. loaded: number,
  41875. /** defines the data length to load */
  41876. total: number);
  41877. /**
  41878. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41879. * @param event defines the source event
  41880. * @returns a new SceneLoaderProgressEvent
  41881. */
  41882. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41883. }
  41884. /**
  41885. * Interface used by SceneLoader plugins to define supported file extensions
  41886. */
  41887. export interface ISceneLoaderPluginExtensions {
  41888. /**
  41889. * Defines the list of supported extensions
  41890. */
  41891. [extension: string]: {
  41892. isBinary: boolean;
  41893. };
  41894. }
  41895. /**
  41896. * Interface used by SceneLoader plugin factory
  41897. */
  41898. export interface ISceneLoaderPluginFactory {
  41899. /**
  41900. * Defines the name of the factory
  41901. */
  41902. name: string;
  41903. /**
  41904. * Function called to create a new plugin
  41905. * @return the new plugin
  41906. */
  41907. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41908. /**
  41909. * Boolean indicating if the plugin can direct load specific data
  41910. */
  41911. canDirectLoad?: (data: string) => boolean;
  41912. }
  41913. /**
  41914. * Interface used to define a SceneLoader plugin
  41915. */
  41916. export interface ISceneLoaderPlugin {
  41917. /**
  41918. * The friendly name of this plugin.
  41919. */
  41920. name: string;
  41921. /**
  41922. * The file extensions supported by this plugin.
  41923. */
  41924. extensions: string | ISceneLoaderPluginExtensions;
  41925. /**
  41926. * Import meshes into a scene.
  41927. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41928. * @param scene The scene to import into
  41929. * @param data The data to import
  41930. * @param rootUrl The root url for scene and resources
  41931. * @param meshes The meshes array to import into
  41932. * @param particleSystems The particle systems array to import into
  41933. * @param skeletons The skeletons array to import into
  41934. * @param onError The callback when import fails
  41935. * @returns True if successful or false otherwise
  41936. */
  41937. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41938. /**
  41939. * Load into a scene.
  41940. * @param scene The scene to load into
  41941. * @param data The data to import
  41942. * @param rootUrl The root url for scene and resources
  41943. * @param onError The callback when import fails
  41944. * @returns true if successful or false otherwise
  41945. */
  41946. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41947. /**
  41948. * The callback that returns true if the data can be directly loaded.
  41949. */
  41950. canDirectLoad?: (data: string) => boolean;
  41951. /**
  41952. * The callback that allows custom handling of the root url based on the response url.
  41953. */
  41954. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41955. /**
  41956. * Load into an asset container.
  41957. * @param scene The scene to load into
  41958. * @param data The data to import
  41959. * @param rootUrl The root url for scene and resources
  41960. * @param onError The callback when import fails
  41961. * @returns The loaded asset container
  41962. */
  41963. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41964. }
  41965. /**
  41966. * Interface used to define an async SceneLoader plugin
  41967. */
  41968. export interface ISceneLoaderPluginAsync {
  41969. /**
  41970. * The friendly name of this plugin.
  41971. */
  41972. name: string;
  41973. /**
  41974. * The file extensions supported by this plugin.
  41975. */
  41976. extensions: string | ISceneLoaderPluginExtensions;
  41977. /**
  41978. * Import meshes into a scene.
  41979. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41980. * @param scene The scene to import into
  41981. * @param data The data to import
  41982. * @param rootUrl The root url for scene and resources
  41983. * @param onProgress The callback when the load progresses
  41984. * @param fileName Defines the name of the file to load
  41985. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41986. */
  41987. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41988. meshes: AbstractMesh[];
  41989. particleSystems: IParticleSystem[];
  41990. skeletons: Skeleton[];
  41991. animationGroups: AnimationGroup[];
  41992. }>;
  41993. /**
  41994. * Load into a scene.
  41995. * @param scene The scene to load into
  41996. * @param data The data to import
  41997. * @param rootUrl The root url for scene and resources
  41998. * @param onProgress The callback when the load progresses
  41999. * @param fileName Defines the name of the file to load
  42000. * @returns Nothing
  42001. */
  42002. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42003. /**
  42004. * The callback that returns true if the data can be directly loaded.
  42005. */
  42006. canDirectLoad?: (data: string) => boolean;
  42007. /**
  42008. * The callback that allows custom handling of the root url based on the response url.
  42009. */
  42010. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42011. /**
  42012. * Load into an asset container.
  42013. * @param scene The scene to load into
  42014. * @param data The data to import
  42015. * @param rootUrl The root url for scene and resources
  42016. * @param onProgress The callback when the load progresses
  42017. * @param fileName Defines the name of the file to load
  42018. * @returns The loaded asset container
  42019. */
  42020. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42021. }
  42022. /**
  42023. * Class used to load scene from various file formats using registered plugins
  42024. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42025. */
  42026. export class SceneLoader {
  42027. /**
  42028. * No logging while loading
  42029. */
  42030. static readonly NO_LOGGING: number;
  42031. /**
  42032. * Minimal logging while loading
  42033. */
  42034. static readonly MINIMAL_LOGGING: number;
  42035. /**
  42036. * Summary logging while loading
  42037. */
  42038. static readonly SUMMARY_LOGGING: number;
  42039. /**
  42040. * Detailled logging while loading
  42041. */
  42042. static readonly DETAILED_LOGGING: number;
  42043. /**
  42044. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42045. */
  42046. static ForceFullSceneLoadingForIncremental: boolean;
  42047. /**
  42048. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42049. */
  42050. static ShowLoadingScreen: boolean;
  42051. /**
  42052. * Defines the current logging level (while loading the scene)
  42053. * @ignorenaming
  42054. */
  42055. static loggingLevel: number;
  42056. /**
  42057. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42058. */
  42059. static CleanBoneMatrixWeights: boolean;
  42060. /**
  42061. * Event raised when a plugin is used to load a scene
  42062. */
  42063. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42064. private static _registeredPlugins;
  42065. private static _getDefaultPlugin;
  42066. private static _getPluginForExtension;
  42067. private static _getPluginForDirectLoad;
  42068. private static _getPluginForFilename;
  42069. private static _getDirectLoad;
  42070. private static _loadData;
  42071. private static _getFileInfo;
  42072. /**
  42073. * Gets a plugin that can load the given extension
  42074. * @param extension defines the extension to load
  42075. * @returns a plugin or null if none works
  42076. */
  42077. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42078. /**
  42079. * Gets a boolean indicating that the given extension can be loaded
  42080. * @param extension defines the extension to load
  42081. * @returns true if the extension is supported
  42082. */
  42083. static IsPluginForExtensionAvailable(extension: string): boolean;
  42084. /**
  42085. * Adds a new plugin to the list of registered plugins
  42086. * @param plugin defines the plugin to add
  42087. */
  42088. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42089. /**
  42090. * Import meshes into a scene
  42091. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42092. * @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)
  42093. * @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)
  42094. * @param scene the instance of BABYLON.Scene to append to
  42095. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42096. * @param onProgress a callback with a progress event for each file being loaded
  42097. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42098. * @param pluginExtension the extension used to determine the plugin
  42099. * @returns The loaded plugin
  42100. */
  42101. 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>;
  42102. /**
  42103. * Import meshes into a scene
  42104. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42105. * @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)
  42106. * @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)
  42107. * @param scene the instance of BABYLON.Scene to append to
  42108. * @param onProgress a callback with a progress event for each file being loaded
  42109. * @param pluginExtension the extension used to determine the plugin
  42110. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42111. */
  42112. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42113. meshes: AbstractMesh[];
  42114. particleSystems: IParticleSystem[];
  42115. skeletons: Skeleton[];
  42116. animationGroups: AnimationGroup[];
  42117. }>;
  42118. /**
  42119. * Load a scene
  42120. * @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)
  42121. * @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)
  42122. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42123. * @param onSuccess a callback with the scene when import succeeds
  42124. * @param onProgress a callback with a progress event for each file being loaded
  42125. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42126. * @param pluginExtension the extension used to determine the plugin
  42127. * @returns The loaded plugin
  42128. */
  42129. 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>;
  42130. /**
  42131. * Load a scene
  42132. * @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)
  42133. * @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)
  42134. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42135. * @param onProgress a callback with a progress event for each file being loaded
  42136. * @param pluginExtension the extension used to determine the plugin
  42137. * @returns The loaded scene
  42138. */
  42139. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42140. /**
  42141. * Append a scene
  42142. * @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)
  42143. * @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)
  42144. * @param scene is the instance of BABYLON.Scene to append to
  42145. * @param onSuccess a callback with the scene when import succeeds
  42146. * @param onProgress a callback with a progress event for each file being loaded
  42147. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42148. * @param pluginExtension the extension used to determine the plugin
  42149. * @returns The loaded plugin
  42150. */
  42151. 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>;
  42152. /**
  42153. * Append a scene
  42154. * @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)
  42155. * @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)
  42156. * @param scene is the instance of BABYLON.Scene to append to
  42157. * @param onProgress a callback with a progress event for each file being loaded
  42158. * @param pluginExtension the extension used to determine the plugin
  42159. * @returns The given scene
  42160. */
  42161. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42162. /**
  42163. * Load a scene into an asset container
  42164. * @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)
  42165. * @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)
  42166. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42167. * @param onSuccess a callback with the scene when import succeeds
  42168. * @param onProgress a callback with a progress event for each file being loaded
  42169. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42170. * @param pluginExtension the extension used to determine the plugin
  42171. * @returns The loaded plugin
  42172. */
  42173. 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>;
  42174. /**
  42175. * Load a scene into an asset container
  42176. * @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)
  42177. * @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)
  42178. * @param scene is the instance of Scene to append to
  42179. * @param onProgress a callback with a progress event for each file being loaded
  42180. * @param pluginExtension the extension used to determine the plugin
  42181. * @returns The loaded asset container
  42182. */
  42183. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42184. }
  42185. }
  42186. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  42187. import { Scene } from "babylonjs/scene";
  42188. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42189. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42190. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42191. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42192. /**
  42193. * Google Daydream controller
  42194. */
  42195. export class DaydreamController extends WebVRController {
  42196. /**
  42197. * Base Url for the controller model.
  42198. */
  42199. static MODEL_BASE_URL: string;
  42200. /**
  42201. * File name for the controller model.
  42202. */
  42203. static MODEL_FILENAME: string;
  42204. /**
  42205. * Gamepad Id prefix used to identify Daydream Controller.
  42206. */
  42207. static readonly GAMEPAD_ID_PREFIX: string;
  42208. /**
  42209. * Creates a new DaydreamController from a gamepad
  42210. * @param vrGamepad the gamepad that the controller should be created from
  42211. */
  42212. constructor(vrGamepad: any);
  42213. /**
  42214. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42215. * @param scene scene in which to add meshes
  42216. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42217. */
  42218. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42219. /**
  42220. * Called once for each button that changed state since the last frame
  42221. * @param buttonIdx Which button index changed
  42222. * @param state New state of the button
  42223. * @param changes Which properties on the state changed since last frame
  42224. */
  42225. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42226. }
  42227. }
  42228. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  42229. import { Scene } from "babylonjs/scene";
  42230. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42231. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42232. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42233. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42234. /**
  42235. * Gear VR Controller
  42236. */
  42237. export class GearVRController extends WebVRController {
  42238. /**
  42239. * Base Url for the controller model.
  42240. */
  42241. static MODEL_BASE_URL: string;
  42242. /**
  42243. * File name for the controller model.
  42244. */
  42245. static MODEL_FILENAME: string;
  42246. /**
  42247. * Gamepad Id prefix used to identify this controller.
  42248. */
  42249. static readonly GAMEPAD_ID_PREFIX: string;
  42250. private readonly _buttonIndexToObservableNameMap;
  42251. /**
  42252. * Creates a new GearVRController from a gamepad
  42253. * @param vrGamepad the gamepad that the controller should be created from
  42254. */
  42255. constructor(vrGamepad: any);
  42256. /**
  42257. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42258. * @param scene scene in which to add meshes
  42259. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42260. */
  42261. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42262. /**
  42263. * Called once for each button that changed state since the last frame
  42264. * @param buttonIdx Which button index changed
  42265. * @param state New state of the button
  42266. * @param changes Which properties on the state changed since last frame
  42267. */
  42268. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42269. }
  42270. }
  42271. declare module "babylonjs/Gamepads/Controllers/genericController" {
  42272. import { Scene } from "babylonjs/scene";
  42273. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42274. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42275. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42276. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42277. /**
  42278. * Generic Controller
  42279. */
  42280. export class GenericController extends WebVRController {
  42281. /**
  42282. * Base Url for the controller model.
  42283. */
  42284. static readonly MODEL_BASE_URL: string;
  42285. /**
  42286. * File name for the controller model.
  42287. */
  42288. static readonly MODEL_FILENAME: string;
  42289. /**
  42290. * Creates a new GenericController from a gamepad
  42291. * @param vrGamepad the gamepad that the controller should be created from
  42292. */
  42293. constructor(vrGamepad: any);
  42294. /**
  42295. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42296. * @param scene scene in which to add meshes
  42297. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42298. */
  42299. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42300. /**
  42301. * Called once for each button that changed state since the last frame
  42302. * @param buttonIdx Which button index changed
  42303. * @param state New state of the button
  42304. * @param changes Which properties on the state changed since last frame
  42305. */
  42306. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42307. }
  42308. }
  42309. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  42310. import { Observable } from "babylonjs/Misc/observable";
  42311. import { Scene } from "babylonjs/scene";
  42312. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42313. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42314. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42315. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42316. /**
  42317. * Oculus Touch Controller
  42318. */
  42319. export class OculusTouchController extends WebVRController {
  42320. /**
  42321. * Base Url for the controller model.
  42322. */
  42323. static MODEL_BASE_URL: string;
  42324. /**
  42325. * File name for the left controller model.
  42326. */
  42327. static MODEL_LEFT_FILENAME: string;
  42328. /**
  42329. * File name for the right controller model.
  42330. */
  42331. static MODEL_RIGHT_FILENAME: string;
  42332. /**
  42333. * Fired when the secondary trigger on this controller is modified
  42334. */
  42335. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42336. /**
  42337. * Fired when the thumb rest on this controller is modified
  42338. */
  42339. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42340. /**
  42341. * Creates a new OculusTouchController from a gamepad
  42342. * @param vrGamepad the gamepad that the controller should be created from
  42343. */
  42344. constructor(vrGamepad: any);
  42345. /**
  42346. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42347. * @param scene scene in which to add meshes
  42348. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42349. */
  42350. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42351. /**
  42352. * Fired when the A button on this controller is modified
  42353. */
  42354. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42355. /**
  42356. * Fired when the B button on this controller is modified
  42357. */
  42358. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42359. /**
  42360. * Fired when the X button on this controller is modified
  42361. */
  42362. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42363. /**
  42364. * Fired when the Y button on this controller is modified
  42365. */
  42366. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42367. /**
  42368. * Called once for each button that changed state since the last frame
  42369. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42370. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42371. * 2) secondary trigger (same)
  42372. * 3) A (right) X (left), touch, pressed = value
  42373. * 4) B / Y
  42374. * 5) thumb rest
  42375. * @param buttonIdx Which button index changed
  42376. * @param state New state of the button
  42377. * @param changes Which properties on the state changed since last frame
  42378. */
  42379. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42380. }
  42381. }
  42382. declare module "babylonjs/Gamepads/Controllers/viveController" {
  42383. import { Scene } from "babylonjs/scene";
  42384. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42385. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42386. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42387. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42388. import { Observable } from "babylonjs/Misc/observable";
  42389. /**
  42390. * Vive Controller
  42391. */
  42392. export class ViveController extends WebVRController {
  42393. /**
  42394. * Base Url for the controller model.
  42395. */
  42396. static MODEL_BASE_URL: string;
  42397. /**
  42398. * File name for the controller model.
  42399. */
  42400. static MODEL_FILENAME: string;
  42401. /**
  42402. * Creates a new ViveController from a gamepad
  42403. * @param vrGamepad the gamepad that the controller should be created from
  42404. */
  42405. constructor(vrGamepad: any);
  42406. /**
  42407. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42408. * @param scene scene in which to add meshes
  42409. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42410. */
  42411. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42412. /**
  42413. * Fired when the left button on this controller is modified
  42414. */
  42415. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42416. /**
  42417. * Fired when the right button on this controller is modified
  42418. */
  42419. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42420. /**
  42421. * Fired when the menu button on this controller is modified
  42422. */
  42423. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42424. /**
  42425. * Called once for each button that changed state since the last frame
  42426. * Vive mapping:
  42427. * 0: touchpad
  42428. * 1: trigger
  42429. * 2: left AND right buttons
  42430. * 3: menu button
  42431. * @param buttonIdx Which button index changed
  42432. * @param state New state of the button
  42433. * @param changes Which properties on the state changed since last frame
  42434. */
  42435. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42436. }
  42437. }
  42438. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  42439. import { Observable } from "babylonjs/Misc/observable";
  42440. import { Scene } from "babylonjs/scene";
  42441. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42442. import { Ray } from "babylonjs/Culling/ray";
  42443. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42444. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42445. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42446. /**
  42447. * Defines the WindowsMotionController object that the state of the windows motion controller
  42448. */
  42449. export class WindowsMotionController extends WebVRController {
  42450. /**
  42451. * The base url used to load the left and right controller models
  42452. */
  42453. static MODEL_BASE_URL: string;
  42454. /**
  42455. * The name of the left controller model file
  42456. */
  42457. static MODEL_LEFT_FILENAME: string;
  42458. /**
  42459. * The name of the right controller model file
  42460. */
  42461. static MODEL_RIGHT_FILENAME: string;
  42462. /**
  42463. * The controller name prefix for this controller type
  42464. */
  42465. static readonly GAMEPAD_ID_PREFIX: string;
  42466. /**
  42467. * The controller id pattern for this controller type
  42468. */
  42469. private static readonly GAMEPAD_ID_PATTERN;
  42470. private _loadedMeshInfo;
  42471. private readonly _mapping;
  42472. /**
  42473. * Fired when the trackpad on this controller is clicked
  42474. */
  42475. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42476. /**
  42477. * Fired when the trackpad on this controller is modified
  42478. */
  42479. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42480. /**
  42481. * The current x and y values of this controller's trackpad
  42482. */
  42483. trackpad: StickValues;
  42484. /**
  42485. * Creates a new WindowsMotionController from a gamepad
  42486. * @param vrGamepad the gamepad that the controller should be created from
  42487. */
  42488. constructor(vrGamepad: any);
  42489. /**
  42490. * Fired when the trigger on this controller is modified
  42491. */
  42492. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42493. /**
  42494. * Fired when the menu button on this controller is modified
  42495. */
  42496. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42497. /**
  42498. * Fired when the grip button on this controller is modified
  42499. */
  42500. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42501. /**
  42502. * Fired when the thumbstick button on this controller is modified
  42503. */
  42504. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42505. /**
  42506. * Fired when the touchpad button on this controller is modified
  42507. */
  42508. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42509. /**
  42510. * Fired when the touchpad values on this controller are modified
  42511. */
  42512. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42513. private _updateTrackpad;
  42514. /**
  42515. * Called once per frame by the engine.
  42516. */
  42517. update(): void;
  42518. /**
  42519. * Called once for each button that changed state since the last frame
  42520. * @param buttonIdx Which button index changed
  42521. * @param state New state of the button
  42522. * @param changes Which properties on the state changed since last frame
  42523. */
  42524. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42525. /**
  42526. * Moves the buttons on the controller mesh based on their current state
  42527. * @param buttonName the name of the button to move
  42528. * @param buttonValue the value of the button which determines the buttons new position
  42529. */
  42530. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42531. /**
  42532. * Moves the axis on the controller mesh based on its current state
  42533. * @param axis the index of the axis
  42534. * @param axisValue the value of the axis which determines the meshes new position
  42535. * @hidden
  42536. */
  42537. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42538. /**
  42539. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42540. * @param scene scene in which to add meshes
  42541. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42542. */
  42543. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42544. /**
  42545. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42546. * can be transformed by button presses and axes values, based on this._mapping.
  42547. *
  42548. * @param scene scene in which the meshes exist
  42549. * @param meshes list of meshes that make up the controller model to process
  42550. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42551. */
  42552. private processModel;
  42553. private createMeshInfo;
  42554. /**
  42555. * Gets the ray of the controller in the direction the controller is pointing
  42556. * @param length the length the resulting ray should be
  42557. * @returns a ray in the direction the controller is pointing
  42558. */
  42559. getForwardRay(length?: number): Ray;
  42560. /**
  42561. * Disposes of the controller
  42562. */
  42563. dispose(): void;
  42564. }
  42565. }
  42566. declare module "babylonjs/Gamepads/Controllers/index" {
  42567. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  42568. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  42569. export * from "babylonjs/Gamepads/Controllers/genericController";
  42570. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  42571. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42572. export * from "babylonjs/Gamepads/Controllers/viveController";
  42573. export * from "babylonjs/Gamepads/Controllers/webVRController";
  42574. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  42575. }
  42576. declare module "babylonjs/Gamepads/index" {
  42577. export * from "babylonjs/Gamepads/Controllers/index";
  42578. export * from "babylonjs/Gamepads/gamepad";
  42579. export * from "babylonjs/Gamepads/gamepadManager";
  42580. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  42581. export * from "babylonjs/Gamepads/xboxGamepad";
  42582. }
  42583. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  42584. import { Observable } from "babylonjs/Misc/observable";
  42585. import { Nullable } from "babylonjs/types";
  42586. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42587. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42588. import { Mesh } from "babylonjs/Meshes/mesh";
  42589. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42590. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42591. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42592. /**
  42593. * Single axis scale gizmo
  42594. */
  42595. export class AxisScaleGizmo extends Gizmo {
  42596. private _coloredMaterial;
  42597. /**
  42598. * Drag behavior responsible for the gizmos dragging interactions
  42599. */
  42600. dragBehavior: PointerDragBehavior;
  42601. private _pointerObserver;
  42602. /**
  42603. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42604. */
  42605. snapDistance: number;
  42606. /**
  42607. * Event that fires each time the gizmo snaps to a new location.
  42608. * * snapDistance is the the change in distance
  42609. */
  42610. onSnapObservable: Observable<{
  42611. snapDistance: number;
  42612. }>;
  42613. /**
  42614. * If the scaling operation should be done on all axis (default: false)
  42615. */
  42616. uniformScaling: boolean;
  42617. /**
  42618. * Creates an AxisScaleGizmo
  42619. * @param gizmoLayer The utility layer the gizmo will be added to
  42620. * @param dragAxis The axis which the gizmo will be able to scale on
  42621. * @param color The color of the gizmo
  42622. */
  42623. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42624. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42625. /**
  42626. * Disposes of the gizmo
  42627. */
  42628. dispose(): void;
  42629. /**
  42630. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42631. * @param mesh The mesh to replace the default mesh of the gizmo
  42632. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  42633. */
  42634. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  42635. }
  42636. }
  42637. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  42638. import { Observable } from "babylonjs/Misc/observable";
  42639. import { Nullable } from "babylonjs/types";
  42640. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42641. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42642. import { Mesh } from "babylonjs/Meshes/mesh";
  42643. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42644. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42645. import "babylonjs/Meshes/Builders/boxBuilder";
  42646. /**
  42647. * Bounding box gizmo
  42648. */
  42649. export class BoundingBoxGizmo extends Gizmo {
  42650. private _lineBoundingBox;
  42651. private _rotateSpheresParent;
  42652. private _scaleBoxesParent;
  42653. private _boundingDimensions;
  42654. private _renderObserver;
  42655. private _pointerObserver;
  42656. private _scaleDragSpeed;
  42657. private _tmpQuaternion;
  42658. private _tmpVector;
  42659. private _tmpRotationMatrix;
  42660. /**
  42661. * 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)
  42662. */
  42663. ignoreChildren: boolean;
  42664. /**
  42665. * 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)
  42666. */
  42667. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  42668. /**
  42669. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  42670. */
  42671. rotationSphereSize: number;
  42672. /**
  42673. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  42674. */
  42675. scaleBoxSize: number;
  42676. /**
  42677. * 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)
  42678. */
  42679. fixedDragMeshScreenSize: boolean;
  42680. /**
  42681. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  42682. */
  42683. fixedDragMeshScreenSizeDistanceFactor: number;
  42684. /**
  42685. * Fired when a rotation sphere or scale box is dragged
  42686. */
  42687. onDragStartObservable: Observable<{}>;
  42688. /**
  42689. * Fired when a scale box is dragged
  42690. */
  42691. onScaleBoxDragObservable: Observable<{}>;
  42692. /**
  42693. * Fired when a scale box drag is ended
  42694. */
  42695. onScaleBoxDragEndObservable: Observable<{}>;
  42696. /**
  42697. * Fired when a rotation sphere is dragged
  42698. */
  42699. onRotationSphereDragObservable: Observable<{}>;
  42700. /**
  42701. * Fired when a rotation sphere drag is ended
  42702. */
  42703. onRotationSphereDragEndObservable: Observable<{}>;
  42704. /**
  42705. * 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)
  42706. */
  42707. scalePivot: Nullable<Vector3>;
  42708. private _anchorMesh;
  42709. private _existingMeshScale;
  42710. private _dragMesh;
  42711. private pointerDragBehavior;
  42712. private coloredMaterial;
  42713. private hoverColoredMaterial;
  42714. /**
  42715. * Sets the color of the bounding box gizmo
  42716. * @param color the color to set
  42717. */
  42718. setColor(color: Color3): void;
  42719. /**
  42720. * Creates an BoundingBoxGizmo
  42721. * @param gizmoLayer The utility layer the gizmo will be added to
  42722. * @param color The color of the gizmo
  42723. */
  42724. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42725. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42726. private _selectNode;
  42727. /**
  42728. * Updates the bounding box information for the Gizmo
  42729. */
  42730. updateBoundingBox(): void;
  42731. private _updateRotationSpheres;
  42732. private _updateScaleBoxes;
  42733. /**
  42734. * Enables rotation on the specified axis and disables rotation on the others
  42735. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  42736. */
  42737. setEnabledRotationAxis(axis: string): void;
  42738. /**
  42739. * Enables/disables scaling
  42740. * @param enable if scaling should be enabled
  42741. */
  42742. setEnabledScaling(enable: boolean): void;
  42743. private _updateDummy;
  42744. /**
  42745. * Enables a pointer drag behavior on the bounding box of the gizmo
  42746. */
  42747. enableDragBehavior(): void;
  42748. /**
  42749. * Disposes of the gizmo
  42750. */
  42751. dispose(): void;
  42752. /**
  42753. * 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)
  42754. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  42755. * @returns the bounding box mesh with the passed in mesh as a child
  42756. */
  42757. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  42758. /**
  42759. * CustomMeshes are not supported by this gizmo
  42760. * @param mesh The mesh to replace the default mesh of the gizmo
  42761. */
  42762. setCustomMesh(mesh: Mesh): void;
  42763. }
  42764. }
  42765. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  42766. import { Observable } from "babylonjs/Misc/observable";
  42767. import { Nullable } from "babylonjs/types";
  42768. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42769. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42770. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42771. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42772. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42773. import "babylonjs/Meshes/Builders/linesBuilder";
  42774. /**
  42775. * Single plane rotation gizmo
  42776. */
  42777. export class PlaneRotationGizmo extends Gizmo {
  42778. /**
  42779. * Drag behavior responsible for the gizmos dragging interactions
  42780. */
  42781. dragBehavior: PointerDragBehavior;
  42782. private _pointerObserver;
  42783. /**
  42784. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  42785. */
  42786. snapDistance: number;
  42787. /**
  42788. * Event that fires each time the gizmo snaps to a new location.
  42789. * * snapDistance is the the change in distance
  42790. */
  42791. onSnapObservable: Observable<{
  42792. snapDistance: number;
  42793. }>;
  42794. /**
  42795. * Creates a PlaneRotationGizmo
  42796. * @param gizmoLayer The utility layer the gizmo will be added to
  42797. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  42798. * @param color The color of the gizmo
  42799. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42800. */
  42801. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42802. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42803. /**
  42804. * Disposes of the gizmo
  42805. */
  42806. dispose(): void;
  42807. }
  42808. }
  42809. declare module "babylonjs/Gizmos/rotationGizmo" {
  42810. import { Observable } from "babylonjs/Misc/observable";
  42811. import { Nullable } from "babylonjs/types";
  42812. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42813. import { Mesh } from "babylonjs/Meshes/mesh";
  42814. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42815. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  42816. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42817. /**
  42818. * Gizmo that enables rotating a mesh along 3 axis
  42819. */
  42820. export class RotationGizmo extends Gizmo {
  42821. /**
  42822. * Internal gizmo used for interactions on the x axis
  42823. */
  42824. xGizmo: PlaneRotationGizmo;
  42825. /**
  42826. * Internal gizmo used for interactions on the y axis
  42827. */
  42828. yGizmo: PlaneRotationGizmo;
  42829. /**
  42830. * Internal gizmo used for interactions on the z axis
  42831. */
  42832. zGizmo: PlaneRotationGizmo;
  42833. /** Fires an event when any of it's sub gizmos are dragged */
  42834. onDragStartObservable: Observable<{}>;
  42835. /** Fires an event when any of it's sub gizmos are released from dragging */
  42836. onDragEndObservable: Observable<{}>;
  42837. attachedMesh: Nullable<AbstractMesh>;
  42838. /**
  42839. * Creates a RotationGizmo
  42840. * @param gizmoLayer The utility layer the gizmo will be added to
  42841. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42842. */
  42843. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42844. updateGizmoRotationToMatchAttachedMesh: boolean;
  42845. /**
  42846. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42847. */
  42848. snapDistance: number;
  42849. /**
  42850. * Ratio for the scale of the gizmo (Default: 1)
  42851. */
  42852. scaleRatio: number;
  42853. /**
  42854. * Disposes of the gizmo
  42855. */
  42856. dispose(): void;
  42857. /**
  42858. * CustomMeshes are not supported by this gizmo
  42859. * @param mesh The mesh to replace the default mesh of the gizmo
  42860. */
  42861. setCustomMesh(mesh: Mesh): void;
  42862. }
  42863. }
  42864. declare module "babylonjs/Gizmos/positionGizmo" {
  42865. import { Observable } from "babylonjs/Misc/observable";
  42866. import { Nullable } from "babylonjs/types";
  42867. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42868. import { Mesh } from "babylonjs/Meshes/mesh";
  42869. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42870. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  42871. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42872. /**
  42873. * Gizmo that enables dragging a mesh along 3 axis
  42874. */
  42875. export class PositionGizmo extends Gizmo {
  42876. /**
  42877. * Internal gizmo used for interactions on the x axis
  42878. */
  42879. xGizmo: AxisDragGizmo;
  42880. /**
  42881. * Internal gizmo used for interactions on the y axis
  42882. */
  42883. yGizmo: AxisDragGizmo;
  42884. /**
  42885. * Internal gizmo used for interactions on the z axis
  42886. */
  42887. zGizmo: AxisDragGizmo;
  42888. /** Fires an event when any of it's sub gizmos are dragged */
  42889. onDragStartObservable: Observable<{}>;
  42890. /** Fires an event when any of it's sub gizmos are released from dragging */
  42891. onDragEndObservable: Observable<{}>;
  42892. attachedMesh: Nullable<AbstractMesh>;
  42893. /**
  42894. * Creates a PositionGizmo
  42895. * @param gizmoLayer The utility layer the gizmo will be added to
  42896. */
  42897. constructor(gizmoLayer?: UtilityLayerRenderer);
  42898. updateGizmoRotationToMatchAttachedMesh: boolean;
  42899. /**
  42900. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42901. */
  42902. snapDistance: number;
  42903. /**
  42904. * Ratio for the scale of the gizmo (Default: 1)
  42905. */
  42906. scaleRatio: number;
  42907. /**
  42908. * Disposes of the gizmo
  42909. */
  42910. dispose(): void;
  42911. /**
  42912. * CustomMeshes are not supported by this gizmo
  42913. * @param mesh The mesh to replace the default mesh of the gizmo
  42914. */
  42915. setCustomMesh(mesh: Mesh): void;
  42916. }
  42917. }
  42918. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  42919. import { Scene } from "babylonjs/scene";
  42920. import { Color4, Vector4 } from "babylonjs/Maths/math";
  42921. import { Mesh } from "babylonjs/Meshes/mesh";
  42922. /**
  42923. * Class containing static functions to help procedurally build meshes
  42924. */
  42925. export class PolyhedronBuilder {
  42926. /**
  42927. * Creates a polyhedron mesh
  42928. * * 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
  42929. * * The parameter `size` (positive float, default 1) sets the polygon size
  42930. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  42931. * * 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`
  42932. * * 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
  42933. * * 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)`)
  42934. * * 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
  42935. * * 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
  42936. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42937. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42938. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42939. * @param name defines the name of the mesh
  42940. * @param options defines the options used to create the mesh
  42941. * @param scene defines the hosting scene
  42942. * @returns the polyhedron mesh
  42943. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  42944. */
  42945. static CreatePolyhedron(name: string, options: {
  42946. type?: number;
  42947. size?: number;
  42948. sizeX?: number;
  42949. sizeY?: number;
  42950. sizeZ?: number;
  42951. custom?: any;
  42952. faceUV?: Vector4[];
  42953. faceColors?: Color4[];
  42954. flat?: boolean;
  42955. updatable?: boolean;
  42956. sideOrientation?: number;
  42957. frontUVs?: Vector4;
  42958. backUVs?: Vector4;
  42959. }, scene: Scene): Mesh;
  42960. }
  42961. }
  42962. declare module "babylonjs/Gizmos/scaleGizmo" {
  42963. import { Observable } from "babylonjs/Misc/observable";
  42964. import { Nullable } from "babylonjs/types";
  42965. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42966. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42967. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  42968. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42969. /**
  42970. * Gizmo that enables scaling a mesh along 3 axis
  42971. */
  42972. export class ScaleGizmo extends Gizmo {
  42973. /**
  42974. * Internal gizmo used for interactions on the x axis
  42975. */
  42976. xGizmo: AxisScaleGizmo;
  42977. /**
  42978. * Internal gizmo used for interactions on the y axis
  42979. */
  42980. yGizmo: AxisScaleGizmo;
  42981. /**
  42982. * Internal gizmo used for interactions on the z axis
  42983. */
  42984. zGizmo: AxisScaleGizmo;
  42985. /**
  42986. * Internal gizmo used to scale all axis equally
  42987. */
  42988. uniformScaleGizmo: AxisScaleGizmo;
  42989. /** Fires an event when any of it's sub gizmos are dragged */
  42990. onDragStartObservable: Observable<{}>;
  42991. /** Fires an event when any of it's sub gizmos are released from dragging */
  42992. onDragEndObservable: Observable<{}>;
  42993. attachedMesh: Nullable<AbstractMesh>;
  42994. /**
  42995. * Creates a ScaleGizmo
  42996. * @param gizmoLayer The utility layer the gizmo will be added to
  42997. */
  42998. constructor(gizmoLayer?: UtilityLayerRenderer);
  42999. updateGizmoRotationToMatchAttachedMesh: boolean;
  43000. /**
  43001. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43002. */
  43003. snapDistance: number;
  43004. /**
  43005. * Ratio for the scale of the gizmo (Default: 1)
  43006. */
  43007. scaleRatio: number;
  43008. /**
  43009. * Disposes of the gizmo
  43010. */
  43011. dispose(): void;
  43012. }
  43013. }
  43014. declare module "babylonjs/Gizmos/gizmoManager" {
  43015. import { Observable } from "babylonjs/Misc/observable";
  43016. import { Nullable } from "babylonjs/types";
  43017. import { Scene, IDisposable } from "babylonjs/scene";
  43018. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43019. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  43020. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  43021. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  43022. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  43023. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  43024. /**
  43025. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  43026. */
  43027. export class GizmoManager implements IDisposable {
  43028. private scene;
  43029. /**
  43030. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  43031. */
  43032. gizmos: {
  43033. positionGizmo: Nullable<PositionGizmo>;
  43034. rotationGizmo: Nullable<RotationGizmo>;
  43035. scaleGizmo: Nullable<ScaleGizmo>;
  43036. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  43037. };
  43038. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  43039. clearGizmoOnEmptyPointerEvent: boolean;
  43040. /** Fires an event when the manager is attached to a mesh */
  43041. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  43042. private _gizmosEnabled;
  43043. private _pointerObserver;
  43044. private _attachedMesh;
  43045. private _boundingBoxColor;
  43046. private _defaultUtilityLayer;
  43047. private _defaultKeepDepthUtilityLayer;
  43048. /**
  43049. * When bounding box gizmo is enabled, this can be used to track drag/end events
  43050. */
  43051. boundingBoxDragBehavior: SixDofDragBehavior;
  43052. /**
  43053. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  43054. */
  43055. attachableMeshes: Nullable<Array<AbstractMesh>>;
  43056. /**
  43057. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  43058. */
  43059. usePointerToAttachGizmos: boolean;
  43060. /**
  43061. * Instatiates a gizmo manager
  43062. * @param scene the scene to overlay the gizmos on top of
  43063. */
  43064. constructor(scene: Scene);
  43065. /**
  43066. * Attaches a set of gizmos to the specified mesh
  43067. * @param mesh The mesh the gizmo's should be attached to
  43068. */
  43069. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  43070. /**
  43071. * If the position gizmo is enabled
  43072. */
  43073. positionGizmoEnabled: boolean;
  43074. /**
  43075. * If the rotation gizmo is enabled
  43076. */
  43077. rotationGizmoEnabled: boolean;
  43078. /**
  43079. * If the scale gizmo is enabled
  43080. */
  43081. scaleGizmoEnabled: boolean;
  43082. /**
  43083. * If the boundingBox gizmo is enabled
  43084. */
  43085. boundingBoxGizmoEnabled: boolean;
  43086. /**
  43087. * Disposes of the gizmo manager
  43088. */
  43089. dispose(): void;
  43090. }
  43091. }
  43092. declare module "babylonjs/Gizmos/lightGizmo" {
  43093. import { Nullable } from "babylonjs/types";
  43094. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43095. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43096. import { Light } from "babylonjs/Lights/light";
  43097. /**
  43098. * Gizmo that enables viewing a light
  43099. */
  43100. export class LightGizmo extends Gizmo {
  43101. private _box;
  43102. /**
  43103. * Creates a LightGizmo
  43104. * @param gizmoLayer The utility layer the gizmo will be added to
  43105. */
  43106. constructor(gizmoLayer?: UtilityLayerRenderer);
  43107. private _light;
  43108. /**
  43109. * The light that the gizmo is attached to
  43110. */
  43111. light: Nullable<Light>;
  43112. /**
  43113. * @hidden
  43114. * Updates the gizmo to match the attached mesh's position/rotation
  43115. */
  43116. protected _update(): void;
  43117. }
  43118. }
  43119. declare module "babylonjs/Gizmos/index" {
  43120. export * from "babylonjs/Gizmos/axisDragGizmo";
  43121. export * from "babylonjs/Gizmos/axisScaleGizmo";
  43122. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  43123. export * from "babylonjs/Gizmos/gizmo";
  43124. export * from "babylonjs/Gizmos/gizmoManager";
  43125. export * from "babylonjs/Gizmos/planeRotationGizmo";
  43126. export * from "babylonjs/Gizmos/positionGizmo";
  43127. export * from "babylonjs/Gizmos/rotationGizmo";
  43128. export * from "babylonjs/Gizmos/scaleGizmo";
  43129. export * from "babylonjs/Gizmos/lightGizmo";
  43130. }
  43131. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  43132. /** @hidden */
  43133. export var backgroundFragmentDeclaration: {
  43134. name: string;
  43135. shader: string;
  43136. };
  43137. }
  43138. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  43139. /** @hidden */
  43140. export var backgroundUboDeclaration: {
  43141. name: string;
  43142. shader: string;
  43143. };
  43144. }
  43145. declare module "babylonjs/Shaders/background.fragment" {
  43146. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  43147. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43148. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  43149. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43150. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43151. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43152. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43153. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  43154. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  43155. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43156. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  43157. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  43158. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  43159. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  43160. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  43161. /** @hidden */
  43162. export var backgroundPixelShader: {
  43163. name: string;
  43164. shader: string;
  43165. };
  43166. }
  43167. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  43168. /** @hidden */
  43169. export var backgroundVertexDeclaration: {
  43170. name: string;
  43171. shader: string;
  43172. };
  43173. }
  43174. declare module "babylonjs/Shaders/background.vertex" {
  43175. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  43176. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43177. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43178. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  43179. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  43180. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  43181. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  43182. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43183. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43184. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  43185. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  43186. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  43187. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  43188. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  43189. /** @hidden */
  43190. export var backgroundVertexShader: {
  43191. name: string;
  43192. shader: string;
  43193. };
  43194. }
  43195. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  43196. import { Nullable, int, float } from "babylonjs/types";
  43197. import { Scene } from "babylonjs/scene";
  43198. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  43199. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43200. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43201. import { Mesh } from "babylonjs/Meshes/mesh";
  43202. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  43203. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43204. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43205. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43206. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  43207. import "babylonjs/Shaders/background.fragment";
  43208. import "babylonjs/Shaders/background.vertex";
  43209. /**
  43210. * Background material used to create an efficient environement around your scene.
  43211. */
  43212. export class BackgroundMaterial extends PushMaterial {
  43213. /**
  43214. * Standard reflectance value at parallel view angle.
  43215. */
  43216. static StandardReflectance0: number;
  43217. /**
  43218. * Standard reflectance value at grazing angle.
  43219. */
  43220. static StandardReflectance90: number;
  43221. protected _primaryColor: Color3;
  43222. /**
  43223. * Key light Color (multiply against the environement texture)
  43224. */
  43225. primaryColor: Color3;
  43226. protected __perceptualColor: Nullable<Color3>;
  43227. /**
  43228. * Experimental Internal Use Only.
  43229. *
  43230. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43231. * This acts as a helper to set the primary color to a more "human friendly" value.
  43232. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43233. * output color as close as possible from the chosen value.
  43234. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43235. * part of lighting setup.)
  43236. */
  43237. _perceptualColor: Nullable<Color3>;
  43238. protected _primaryColorShadowLevel: float;
  43239. /**
  43240. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43241. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43242. */
  43243. primaryColorShadowLevel: float;
  43244. protected _primaryColorHighlightLevel: float;
  43245. /**
  43246. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43247. * The primary color is used at the level chosen to define what the white area would look.
  43248. */
  43249. primaryColorHighlightLevel: float;
  43250. protected _reflectionTexture: Nullable<BaseTexture>;
  43251. /**
  43252. * Reflection Texture used in the material.
  43253. * Should be author in a specific way for the best result (refer to the documentation).
  43254. */
  43255. reflectionTexture: Nullable<BaseTexture>;
  43256. protected _reflectionBlur: float;
  43257. /**
  43258. * Reflection Texture level of blur.
  43259. *
  43260. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43261. * texture twice.
  43262. */
  43263. reflectionBlur: float;
  43264. protected _diffuseTexture: Nullable<BaseTexture>;
  43265. /**
  43266. * Diffuse Texture used in the material.
  43267. * Should be author in a specific way for the best result (refer to the documentation).
  43268. */
  43269. diffuseTexture: Nullable<BaseTexture>;
  43270. protected _shadowLights: Nullable<IShadowLight[]>;
  43271. /**
  43272. * Specify the list of lights casting shadow on the material.
  43273. * All scene shadow lights will be included if null.
  43274. */
  43275. shadowLights: Nullable<IShadowLight[]>;
  43276. protected _shadowLevel: float;
  43277. /**
  43278. * Helps adjusting the shadow to a softer level if required.
  43279. * 0 means black shadows and 1 means no shadows.
  43280. */
  43281. shadowLevel: float;
  43282. protected _sceneCenter: Vector3;
  43283. /**
  43284. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43285. * It is usually zero but might be interesting to modify according to your setup.
  43286. */
  43287. sceneCenter: Vector3;
  43288. protected _opacityFresnel: boolean;
  43289. /**
  43290. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43291. * This helps ensuring a nice transition when the camera goes under the ground.
  43292. */
  43293. opacityFresnel: boolean;
  43294. protected _reflectionFresnel: boolean;
  43295. /**
  43296. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  43297. * This helps adding a mirror texture on the ground.
  43298. */
  43299. reflectionFresnel: boolean;
  43300. protected _reflectionFalloffDistance: number;
  43301. /**
  43302. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43303. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  43304. */
  43305. reflectionFalloffDistance: number;
  43306. protected _reflectionAmount: number;
  43307. /**
  43308. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  43309. */
  43310. reflectionAmount: number;
  43311. protected _reflectionReflectance0: number;
  43312. /**
  43313. * This specifies the weight of the reflection at grazing angle.
  43314. */
  43315. reflectionReflectance0: number;
  43316. protected _reflectionReflectance90: number;
  43317. /**
  43318. * This specifies the weight of the reflection at a perpendicular point of view.
  43319. */
  43320. reflectionReflectance90: number;
  43321. /**
  43322. * Sets the reflection reflectance fresnel values according to the default standard
  43323. * empirically know to work well :-)
  43324. */
  43325. reflectionStandardFresnelWeight: number;
  43326. protected _useRGBColor: boolean;
  43327. /**
  43328. * Helps to directly use the maps channels instead of their level.
  43329. */
  43330. useRGBColor: boolean;
  43331. protected _enableNoise: boolean;
  43332. /**
  43333. * This helps reducing the banding effect that could occur on the background.
  43334. */
  43335. enableNoise: boolean;
  43336. /**
  43337. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43338. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  43339. * Recommended to be keep at 1.0 except for special cases.
  43340. */
  43341. fovMultiplier: number;
  43342. private _fovMultiplier;
  43343. /**
  43344. * Enable the FOV adjustment feature controlled by fovMultiplier.
  43345. */
  43346. useEquirectangularFOV: boolean;
  43347. private _maxSimultaneousLights;
  43348. /**
  43349. * Number of Simultaneous lights allowed on the material.
  43350. */
  43351. maxSimultaneousLights: int;
  43352. /**
  43353. * Default configuration related to image processing available in the Background Material.
  43354. */
  43355. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43356. /**
  43357. * Keep track of the image processing observer to allow dispose and replace.
  43358. */
  43359. private _imageProcessingObserver;
  43360. /**
  43361. * Attaches a new image processing configuration to the PBR Material.
  43362. * @param configuration (if null the scene configuration will be use)
  43363. */
  43364. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43365. /**
  43366. * Gets the image processing configuration used either in this material.
  43367. */
  43368. /**
  43369. * Sets the Default image processing configuration used either in the this material.
  43370. *
  43371. * If sets to null, the scene one is in use.
  43372. */
  43373. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  43374. /**
  43375. * Gets wether the color curves effect is enabled.
  43376. */
  43377. /**
  43378. * Sets wether the color curves effect is enabled.
  43379. */
  43380. cameraColorCurvesEnabled: boolean;
  43381. /**
  43382. * Gets wether the color grading effect is enabled.
  43383. */
  43384. /**
  43385. * Gets wether the color grading effect is enabled.
  43386. */
  43387. cameraColorGradingEnabled: boolean;
  43388. /**
  43389. * Gets wether tonemapping is enabled or not.
  43390. */
  43391. /**
  43392. * Sets wether tonemapping is enabled or not
  43393. */
  43394. cameraToneMappingEnabled: boolean;
  43395. /**
  43396. * The camera exposure used on this material.
  43397. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43398. * This corresponds to a photographic exposure.
  43399. */
  43400. /**
  43401. * The camera exposure used on this material.
  43402. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43403. * This corresponds to a photographic exposure.
  43404. */
  43405. cameraExposure: float;
  43406. /**
  43407. * Gets The camera contrast used on this material.
  43408. */
  43409. /**
  43410. * Sets The camera contrast used on this material.
  43411. */
  43412. cameraContrast: float;
  43413. /**
  43414. * Gets the Color Grading 2D Lookup Texture.
  43415. */
  43416. /**
  43417. * Sets the Color Grading 2D Lookup Texture.
  43418. */
  43419. cameraColorGradingTexture: Nullable<BaseTexture>;
  43420. /**
  43421. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43422. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43423. * 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;
  43424. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43425. */
  43426. /**
  43427. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43428. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43429. * 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;
  43430. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43431. */
  43432. cameraColorCurves: Nullable<ColorCurves>;
  43433. /**
  43434. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  43435. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  43436. */
  43437. switchToBGR: boolean;
  43438. private _renderTargets;
  43439. private _reflectionControls;
  43440. private _white;
  43441. private _primaryShadowColor;
  43442. private _primaryHighlightColor;
  43443. /**
  43444. * Instantiates a Background Material in the given scene
  43445. * @param name The friendly name of the material
  43446. * @param scene The scene to add the material to
  43447. */
  43448. constructor(name: string, scene: Scene);
  43449. /**
  43450. * Gets a boolean indicating that current material needs to register RTT
  43451. */
  43452. readonly hasRenderTargetTextures: boolean;
  43453. /**
  43454. * The entire material has been created in order to prevent overdraw.
  43455. * @returns false
  43456. */
  43457. needAlphaTesting(): boolean;
  43458. /**
  43459. * The entire material has been created in order to prevent overdraw.
  43460. * @returns true if blending is enable
  43461. */
  43462. needAlphaBlending(): boolean;
  43463. /**
  43464. * Checks wether the material is ready to be rendered for a given mesh.
  43465. * @param mesh The mesh to render
  43466. * @param subMesh The submesh to check against
  43467. * @param useInstances Specify wether or not the material is used with instances
  43468. * @returns true if all the dependencies are ready (Textures, Effects...)
  43469. */
  43470. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43471. /**
  43472. * Compute the primary color according to the chosen perceptual color.
  43473. */
  43474. private _computePrimaryColorFromPerceptualColor;
  43475. /**
  43476. * Compute the highlights and shadow colors according to their chosen levels.
  43477. */
  43478. private _computePrimaryColors;
  43479. /**
  43480. * Build the uniform buffer used in the material.
  43481. */
  43482. buildUniformLayout(): void;
  43483. /**
  43484. * Unbind the material.
  43485. */
  43486. unbind(): void;
  43487. /**
  43488. * Bind only the world matrix to the material.
  43489. * @param world The world matrix to bind.
  43490. */
  43491. bindOnlyWorldMatrix(world: Matrix): void;
  43492. /**
  43493. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  43494. * @param world The world matrix to bind.
  43495. * @param subMesh The submesh to bind for.
  43496. */
  43497. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43498. /**
  43499. * Dispose the material.
  43500. * @param forceDisposeEffect Force disposal of the associated effect.
  43501. * @param forceDisposeTextures Force disposal of the associated textures.
  43502. */
  43503. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43504. /**
  43505. * Clones the material.
  43506. * @param name The cloned name.
  43507. * @returns The cloned material.
  43508. */
  43509. clone(name: string): BackgroundMaterial;
  43510. /**
  43511. * Serializes the current material to its JSON representation.
  43512. * @returns The JSON representation.
  43513. */
  43514. serialize(): any;
  43515. /**
  43516. * Gets the class name of the material
  43517. * @returns "BackgroundMaterial"
  43518. */
  43519. getClassName(): string;
  43520. /**
  43521. * Parse a JSON input to create back a background material.
  43522. * @param source The JSON data to parse
  43523. * @param scene The scene to create the parsed material in
  43524. * @param rootUrl The root url of the assets the material depends upon
  43525. * @returns the instantiated BackgroundMaterial.
  43526. */
  43527. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  43528. }
  43529. }
  43530. declare module "babylonjs/Helpers/environmentHelper" {
  43531. import { Observable } from "babylonjs/Misc/observable";
  43532. import { Nullable } from "babylonjs/types";
  43533. import { Scene } from "babylonjs/scene";
  43534. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43535. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43536. import { Mesh } from "babylonjs/Meshes/mesh";
  43537. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43538. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  43539. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  43540. import "babylonjs/Meshes/Builders/planeBuilder";
  43541. import "babylonjs/Meshes/Builders/boxBuilder";
  43542. /**
  43543. * Represents the different options available during the creation of
  43544. * a Environment helper.
  43545. *
  43546. * This can control the default ground, skybox and image processing setup of your scene.
  43547. */
  43548. export interface IEnvironmentHelperOptions {
  43549. /**
  43550. * Specifies wether or not to create a ground.
  43551. * True by default.
  43552. */
  43553. createGround: boolean;
  43554. /**
  43555. * Specifies the ground size.
  43556. * 15 by default.
  43557. */
  43558. groundSize: number;
  43559. /**
  43560. * The texture used on the ground for the main color.
  43561. * Comes from the BabylonJS CDN by default.
  43562. *
  43563. * Remarks: Can be either a texture or a url.
  43564. */
  43565. groundTexture: string | BaseTexture;
  43566. /**
  43567. * The color mixed in the ground texture by default.
  43568. * BabylonJS clearColor by default.
  43569. */
  43570. groundColor: Color3;
  43571. /**
  43572. * Specifies the ground opacity.
  43573. * 1 by default.
  43574. */
  43575. groundOpacity: number;
  43576. /**
  43577. * Enables the ground to receive shadows.
  43578. * True by default.
  43579. */
  43580. enableGroundShadow: boolean;
  43581. /**
  43582. * Helps preventing the shadow to be fully black on the ground.
  43583. * 0.5 by default.
  43584. */
  43585. groundShadowLevel: number;
  43586. /**
  43587. * Creates a mirror texture attach to the ground.
  43588. * false by default.
  43589. */
  43590. enableGroundMirror: boolean;
  43591. /**
  43592. * Specifies the ground mirror size ratio.
  43593. * 0.3 by default as the default kernel is 64.
  43594. */
  43595. groundMirrorSizeRatio: number;
  43596. /**
  43597. * Specifies the ground mirror blur kernel size.
  43598. * 64 by default.
  43599. */
  43600. groundMirrorBlurKernel: number;
  43601. /**
  43602. * Specifies the ground mirror visibility amount.
  43603. * 1 by default
  43604. */
  43605. groundMirrorAmount: number;
  43606. /**
  43607. * Specifies the ground mirror reflectance weight.
  43608. * This uses the standard weight of the background material to setup the fresnel effect
  43609. * of the mirror.
  43610. * 1 by default.
  43611. */
  43612. groundMirrorFresnelWeight: number;
  43613. /**
  43614. * Specifies the ground mirror Falloff distance.
  43615. * This can helps reducing the size of the reflection.
  43616. * 0 by Default.
  43617. */
  43618. groundMirrorFallOffDistance: number;
  43619. /**
  43620. * Specifies the ground mirror texture type.
  43621. * Unsigned Int by Default.
  43622. */
  43623. groundMirrorTextureType: number;
  43624. /**
  43625. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  43626. * the shown objects.
  43627. */
  43628. groundYBias: number;
  43629. /**
  43630. * Specifies wether or not to create a skybox.
  43631. * True by default.
  43632. */
  43633. createSkybox: boolean;
  43634. /**
  43635. * Specifies the skybox size.
  43636. * 20 by default.
  43637. */
  43638. skyboxSize: number;
  43639. /**
  43640. * The texture used on the skybox for the main color.
  43641. * Comes from the BabylonJS CDN by default.
  43642. *
  43643. * Remarks: Can be either a texture or a url.
  43644. */
  43645. skyboxTexture: string | BaseTexture;
  43646. /**
  43647. * The color mixed in the skybox texture by default.
  43648. * BabylonJS clearColor by default.
  43649. */
  43650. skyboxColor: Color3;
  43651. /**
  43652. * The background rotation around the Y axis of the scene.
  43653. * This helps aligning the key lights of your scene with the background.
  43654. * 0 by default.
  43655. */
  43656. backgroundYRotation: number;
  43657. /**
  43658. * Compute automatically the size of the elements to best fit with the scene.
  43659. */
  43660. sizeAuto: boolean;
  43661. /**
  43662. * Default position of the rootMesh if autoSize is not true.
  43663. */
  43664. rootPosition: Vector3;
  43665. /**
  43666. * Sets up the image processing in the scene.
  43667. * true by default.
  43668. */
  43669. setupImageProcessing: boolean;
  43670. /**
  43671. * The texture used as your environment texture in the scene.
  43672. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  43673. *
  43674. * Remarks: Can be either a texture or a url.
  43675. */
  43676. environmentTexture: string | BaseTexture;
  43677. /**
  43678. * The value of the exposure to apply to the scene.
  43679. * 0.6 by default if setupImageProcessing is true.
  43680. */
  43681. cameraExposure: number;
  43682. /**
  43683. * The value of the contrast to apply to the scene.
  43684. * 1.6 by default if setupImageProcessing is true.
  43685. */
  43686. cameraContrast: number;
  43687. /**
  43688. * Specifies wether or not tonemapping should be enabled in the scene.
  43689. * true by default if setupImageProcessing is true.
  43690. */
  43691. toneMappingEnabled: boolean;
  43692. }
  43693. /**
  43694. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  43695. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  43696. * It also helps with the default setup of your imageProcessing configuration.
  43697. */
  43698. export class EnvironmentHelper {
  43699. /**
  43700. * Default ground texture URL.
  43701. */
  43702. private static _groundTextureCDNUrl;
  43703. /**
  43704. * Default skybox texture URL.
  43705. */
  43706. private static _skyboxTextureCDNUrl;
  43707. /**
  43708. * Default environment texture URL.
  43709. */
  43710. private static _environmentTextureCDNUrl;
  43711. /**
  43712. * Creates the default options for the helper.
  43713. */
  43714. private static _getDefaultOptions;
  43715. private _rootMesh;
  43716. /**
  43717. * Gets the root mesh created by the helper.
  43718. */
  43719. readonly rootMesh: Mesh;
  43720. private _skybox;
  43721. /**
  43722. * Gets the skybox created by the helper.
  43723. */
  43724. readonly skybox: Nullable<Mesh>;
  43725. private _skyboxTexture;
  43726. /**
  43727. * Gets the skybox texture created by the helper.
  43728. */
  43729. readonly skyboxTexture: Nullable<BaseTexture>;
  43730. private _skyboxMaterial;
  43731. /**
  43732. * Gets the skybox material created by the helper.
  43733. */
  43734. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  43735. private _ground;
  43736. /**
  43737. * Gets the ground mesh created by the helper.
  43738. */
  43739. readonly ground: Nullable<Mesh>;
  43740. private _groundTexture;
  43741. /**
  43742. * Gets the ground texture created by the helper.
  43743. */
  43744. readonly groundTexture: Nullable<BaseTexture>;
  43745. private _groundMirror;
  43746. /**
  43747. * Gets the ground mirror created by the helper.
  43748. */
  43749. readonly groundMirror: Nullable<MirrorTexture>;
  43750. /**
  43751. * Gets the ground mirror render list to helps pushing the meshes
  43752. * you wish in the ground reflection.
  43753. */
  43754. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  43755. private _groundMaterial;
  43756. /**
  43757. * Gets the ground material created by the helper.
  43758. */
  43759. readonly groundMaterial: Nullable<BackgroundMaterial>;
  43760. /**
  43761. * Stores the creation options.
  43762. */
  43763. private readonly _scene;
  43764. private _options;
  43765. /**
  43766. * This observable will be notified with any error during the creation of the environment,
  43767. * mainly texture creation errors.
  43768. */
  43769. onErrorObservable: Observable<{
  43770. message?: string;
  43771. exception?: any;
  43772. }>;
  43773. /**
  43774. * constructor
  43775. * @param options Defines the options we want to customize the helper
  43776. * @param scene The scene to add the material to
  43777. */
  43778. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  43779. /**
  43780. * Updates the background according to the new options
  43781. * @param options
  43782. */
  43783. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  43784. /**
  43785. * Sets the primary color of all the available elements.
  43786. * @param color the main color to affect to the ground and the background
  43787. */
  43788. setMainColor(color: Color3): void;
  43789. /**
  43790. * Setup the image processing according to the specified options.
  43791. */
  43792. private _setupImageProcessing;
  43793. /**
  43794. * Setup the environment texture according to the specified options.
  43795. */
  43796. private _setupEnvironmentTexture;
  43797. /**
  43798. * Setup the background according to the specified options.
  43799. */
  43800. private _setupBackground;
  43801. /**
  43802. * Get the scene sizes according to the setup.
  43803. */
  43804. private _getSceneSize;
  43805. /**
  43806. * Setup the ground according to the specified options.
  43807. */
  43808. private _setupGround;
  43809. /**
  43810. * Setup the ground material according to the specified options.
  43811. */
  43812. private _setupGroundMaterial;
  43813. /**
  43814. * Setup the ground diffuse texture according to the specified options.
  43815. */
  43816. private _setupGroundDiffuseTexture;
  43817. /**
  43818. * Setup the ground mirror texture according to the specified options.
  43819. */
  43820. private _setupGroundMirrorTexture;
  43821. /**
  43822. * Setup the ground to receive the mirror texture.
  43823. */
  43824. private _setupMirrorInGroundMaterial;
  43825. /**
  43826. * Setup the skybox according to the specified options.
  43827. */
  43828. private _setupSkybox;
  43829. /**
  43830. * Setup the skybox material according to the specified options.
  43831. */
  43832. private _setupSkyboxMaterial;
  43833. /**
  43834. * Setup the skybox reflection texture according to the specified options.
  43835. */
  43836. private _setupSkyboxReflectionTexture;
  43837. private _errorHandler;
  43838. /**
  43839. * Dispose all the elements created by the Helper.
  43840. */
  43841. dispose(): void;
  43842. }
  43843. }
  43844. declare module "babylonjs/Helpers/photoDome" {
  43845. import { Observable } from "babylonjs/Misc/observable";
  43846. import { Nullable } from "babylonjs/types";
  43847. import { Scene } from "babylonjs/scene";
  43848. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43849. import { Mesh } from "babylonjs/Meshes/mesh";
  43850. import { Texture } from "babylonjs/Materials/Textures/texture";
  43851. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  43852. import "babylonjs/Meshes/Builders/sphereBuilder";
  43853. /**
  43854. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  43855. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  43856. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  43857. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  43858. */
  43859. export class PhotoDome extends TransformNode {
  43860. private _useDirectMapping;
  43861. /**
  43862. * The texture being displayed on the sphere
  43863. */
  43864. protected _photoTexture: Texture;
  43865. /**
  43866. * Gets or sets the texture being displayed on the sphere
  43867. */
  43868. photoTexture: Texture;
  43869. /**
  43870. * Observable raised when an error occured while loading the 360 image
  43871. */
  43872. onLoadErrorObservable: Observable<string>;
  43873. /**
  43874. * The skybox material
  43875. */
  43876. protected _material: BackgroundMaterial;
  43877. /**
  43878. * The surface used for the skybox
  43879. */
  43880. protected _mesh: Mesh;
  43881. /**
  43882. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43883. * Also see the options.resolution property.
  43884. */
  43885. fovMultiplier: number;
  43886. /**
  43887. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  43888. * @param name Element's name, child elements will append suffixes for their own names.
  43889. * @param urlsOfPhoto defines the url of the photo to display
  43890. * @param options defines an object containing optional or exposed sub element properties
  43891. * @param onError defines a callback called when an error occured while loading the texture
  43892. */
  43893. constructor(name: string, urlOfPhoto: string, options: {
  43894. resolution?: number;
  43895. size?: number;
  43896. useDirectMapping?: boolean;
  43897. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  43898. /**
  43899. * Releases resources associated with this node.
  43900. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  43901. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  43902. */
  43903. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  43904. }
  43905. }
  43906. declare module "babylonjs/Misc/textureTools" {
  43907. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43908. import { Texture } from "babylonjs/Materials/Textures/texture";
  43909. import { Scene } from "babylonjs/scene";
  43910. /**
  43911. * Class used to host texture specific utilities
  43912. */
  43913. export class TextureTools {
  43914. /**
  43915. * Uses the GPU to create a copy texture rescaled at a given size
  43916. * @param texture Texture to copy from
  43917. * @param width defines the desired width
  43918. * @param height defines the desired height
  43919. * @param useBilinearMode defines if bilinear mode has to be used
  43920. * @return the generated texture
  43921. */
  43922. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  43923. /**
  43924. * Gets an environment BRDF texture for a given scene
  43925. * @param scene defines the hosting scene
  43926. * @returns the environment BRDF texture
  43927. */
  43928. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  43929. private static _environmentBRDFBase64Texture;
  43930. }
  43931. }
  43932. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  43933. import { Nullable } from "babylonjs/types";
  43934. import { IAnimatable } from "babylonjs/Misc/tools";
  43935. import { Color3 } from "babylonjs/Maths/math";
  43936. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43937. import { EffectFallbacks } from "babylonjs/Materials/effect";
  43938. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  43939. import { Engine } from "babylonjs/Engines/engine";
  43940. import { Scene } from "babylonjs/scene";
  43941. /**
  43942. * @hidden
  43943. */
  43944. export interface IMaterialClearCoatDefines {
  43945. CLEARCOAT: boolean;
  43946. CLEARCOAT_DEFAULTIOR: boolean;
  43947. CLEARCOAT_TEXTURE: boolean;
  43948. CLEARCOAT_TEXTUREDIRECTUV: number;
  43949. CLEARCOAT_BUMP: boolean;
  43950. CLEARCOAT_BUMPDIRECTUV: number;
  43951. CLEARCOAT_TINT: boolean;
  43952. CLEARCOAT_TINT_TEXTURE: boolean;
  43953. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  43954. /** @hidden */
  43955. _areTexturesDirty: boolean;
  43956. }
  43957. /**
  43958. * Define the code related to the clear coat parameters of the pbr material.
  43959. */
  43960. export class PBRClearCoatConfiguration {
  43961. /**
  43962. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  43963. * The default fits with a polyurethane material.
  43964. */
  43965. private static readonly _DefaultIndiceOfRefraction;
  43966. private _isEnabled;
  43967. /**
  43968. * Defines if the clear coat is enabled in the material.
  43969. */
  43970. isEnabled: boolean;
  43971. /**
  43972. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  43973. */
  43974. intensity: number;
  43975. /**
  43976. * Defines the clear coat layer roughness.
  43977. */
  43978. roughness: number;
  43979. private _indiceOfRefraction;
  43980. /**
  43981. * Defines the indice of refraction of the clear coat.
  43982. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  43983. * The default fits with a polyurethane material.
  43984. * Changing the default value is more performance intensive.
  43985. */
  43986. indiceOfRefraction: number;
  43987. private _texture;
  43988. /**
  43989. * Stores the clear coat values in a texture.
  43990. */
  43991. texture: Nullable<BaseTexture>;
  43992. private _bumpTexture;
  43993. /**
  43994. * Define the clear coat specific bump texture.
  43995. */
  43996. bumpTexture: Nullable<BaseTexture>;
  43997. private _isTintEnabled;
  43998. /**
  43999. * Defines if the clear coat tint is enabled in the material.
  44000. */
  44001. isTintEnabled: boolean;
  44002. /**
  44003. * Defines if the clear coat tint is enabled in the material.
  44004. * This is only use if tint is enabled
  44005. */
  44006. tintColor: Color3;
  44007. /**
  44008. * Defines if the distance at which the tint color should be found in the
  44009. * clear coat media.
  44010. * This is only use if tint is enabled
  44011. */
  44012. tintColorAtDistance: number;
  44013. /**
  44014. * Defines the clear coat layer thickness.
  44015. * This is only use if tint is enabled
  44016. */
  44017. tintThickness: number;
  44018. private _tintTexture;
  44019. /**
  44020. * Stores the clear tint values in a texture.
  44021. * rgb is tint
  44022. * a is a thickness factor
  44023. */
  44024. tintTexture: Nullable<BaseTexture>;
  44025. /** @hidden */
  44026. private _internalMarkAllSubMeshesAsTexturesDirty;
  44027. /** @hidden */
  44028. _markAllSubMeshesAsTexturesDirty(): void;
  44029. /**
  44030. * Instantiate a new istance of clear coat configuration.
  44031. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44032. */
  44033. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44034. /**
  44035. * Specifies that the submesh is ready to be used.
  44036. * @param defines the list of "defines" to update.
  44037. * @param scene defines the scene the material belongs to.
  44038. * @param engine defines the engine the material belongs to.
  44039. * @param disableBumpMap defines wether the material disables bump or not.
  44040. * @returns - boolean indicating that the submesh is ready or not.
  44041. */
  44042. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  44043. /**
  44044. * Checks to see if a texture is used in the material.
  44045. * @param defines the list of "defines" to update.
  44046. * @param scene defines the scene to the material belongs to.
  44047. */
  44048. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  44049. /**
  44050. * Binds the material data.
  44051. * @param uniformBuffer defines the Uniform buffer to fill in.
  44052. * @param scene defines the scene the material belongs to.
  44053. * @param engine defines the engine the material belongs to.
  44054. * @param disableBumpMap defines wether the material disables bump or not.
  44055. * @param isFrozen defines wether the material is frozen or not.
  44056. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44057. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44058. */
  44059. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  44060. /**
  44061. * Checks to see if a texture is used in the material.
  44062. * @param texture - Base texture to use.
  44063. * @returns - Boolean specifying if a texture is used in the material.
  44064. */
  44065. hasTexture(texture: BaseTexture): boolean;
  44066. /**
  44067. * Returns an array of the actively used textures.
  44068. * @param activeTextures Array of BaseTextures
  44069. */
  44070. getActiveTextures(activeTextures: BaseTexture[]): void;
  44071. /**
  44072. * Returns the animatable textures.
  44073. * @param animatables Array of animatable textures.
  44074. */
  44075. getAnimatables(animatables: IAnimatable[]): void;
  44076. /**
  44077. * Disposes the resources of the material.
  44078. * @param forceDisposeTextures - Forces the disposal of all textures.
  44079. */
  44080. dispose(forceDisposeTextures?: boolean): void;
  44081. /**
  44082. * Get the current class name of the texture useful for serialization or dynamic coding.
  44083. * @returns "PBRClearCoatConfiguration"
  44084. */
  44085. getClassName(): string;
  44086. /**
  44087. * Makes a duplicate of the current configuration into another one.
  44088. * @param clearCoatConfiguration define the config where to copy the info
  44089. */
  44090. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  44091. /**
  44092. * Serializes this clear coat configuration.
  44093. * @returns - An object with the serialized config.
  44094. */
  44095. serialize(): any;
  44096. /**
  44097. * Parses a Clear Coat Configuration from a serialized object.
  44098. * @param source - Serialized object.
  44099. */
  44100. parse(source: any): void;
  44101. /**
  44102. * Add fallbacks to the effect fallbacks list.
  44103. * @param defines defines the Base texture to use.
  44104. * @param fallbacks defines the current fallback list.
  44105. * @param currentRank defines the current fallback rank.
  44106. * @returns the new fallback rank.
  44107. */
  44108. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44109. /**
  44110. * Add the required uniforms to the current list.
  44111. * @param uniforms defines the current uniform list.
  44112. */
  44113. static AddUniforms(uniforms: string[]): void;
  44114. /**
  44115. * Add the required samplers to the current list.
  44116. * @param samplers defines the current sampler list.
  44117. */
  44118. static AddSamplers(samplers: string[]): void;
  44119. /**
  44120. * Add the required uniforms to the current buffer.
  44121. * @param uniformBuffer defines the current uniform buffer.
  44122. */
  44123. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44124. }
  44125. }
  44126. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  44127. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44128. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44129. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44130. /**
  44131. * @hidden
  44132. */
  44133. export interface IMaterialAnisotropicDefines {
  44134. ANISOTROPIC: boolean;
  44135. MAINUV1: boolean;
  44136. _areMiscDirty: boolean;
  44137. _needUVs: boolean;
  44138. }
  44139. /**
  44140. * Define the code related to the anisotropic parameters of the pbr material.
  44141. */
  44142. export class PBRAnisotropicConfiguration {
  44143. private _isEnabled;
  44144. /**
  44145. * Defines if the anisotropy is enabled in the material.
  44146. */
  44147. isEnabled: boolean;
  44148. /**
  44149. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  44150. */
  44151. intensity: number;
  44152. /**
  44153. * Defines if the effect is along the tangents or bitangents.
  44154. * By default, the effect is "strectching" the highlights along the tangents.
  44155. */
  44156. followTangents: boolean;
  44157. /** @hidden */
  44158. private _internalMarkAllSubMeshesAsMiscDirty;
  44159. /** @hidden */
  44160. _markAllSubMeshesAsMiscDirty(): void;
  44161. /**
  44162. * Instantiate a new istance of clear coat configuration.
  44163. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  44164. */
  44165. constructor(markAllSubMeshesAsMiscDirty: () => void);
  44166. /**
  44167. * Checks to see if a texture is used in the material.
  44168. * @param defines the list of "defines" to update.
  44169. * @param mesh the mesh we are preparing the defines for.
  44170. */
  44171. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh): void;
  44172. /**
  44173. * Binds the material data.
  44174. * @param uniformBuffer defines the Uniform buffer to fill in.
  44175. * @param isFrozen defines wether the material is frozen or not.
  44176. */
  44177. bindForSubMesh(uniformBuffer: UniformBuffer, isFrozen: boolean): void;
  44178. /**
  44179. * Get the current class name of the texture useful for serialization or dynamic coding.
  44180. * @returns "PBRAnisotropicConfiguration"
  44181. */
  44182. getClassName(): string;
  44183. /**
  44184. * Makes a duplicate of the current configuration into another one.
  44185. * @param anisotropicConfiguration define the config where to copy the info
  44186. */
  44187. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  44188. /**
  44189. * Serializes this clear coat configuration.
  44190. * @returns - An object with the serialized config.
  44191. */
  44192. serialize(): any;
  44193. /**
  44194. * Parses a Clear Coat Configuration from a serialized object.
  44195. * @param source - Serialized object.
  44196. */
  44197. parse(source: any): void;
  44198. /**
  44199. * Add fallbacks to the effect fallbacks list.
  44200. * @param defines defines the Base texture to use.
  44201. * @param fallbacks defines the current fallback list.
  44202. * @param currentRank defines the current fallback rank.
  44203. * @returns the new fallback rank.
  44204. */
  44205. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44206. /**
  44207. * Add the required uniforms to the current list.
  44208. * @param uniforms defines the current uniform list.
  44209. */
  44210. static AddUniforms(uniforms: string[]): void;
  44211. /**
  44212. * Add the required uniforms to the current buffer.
  44213. * @param uniformBuffer defines the current uniform buffer.
  44214. */
  44215. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44216. }
  44217. }
  44218. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  44219. /** @hidden */
  44220. export var pbrFragmentDeclaration: {
  44221. name: string;
  44222. shader: string;
  44223. };
  44224. }
  44225. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  44226. /** @hidden */
  44227. export var pbrUboDeclaration: {
  44228. name: string;
  44229. shader: string;
  44230. };
  44231. }
  44232. declare module "babylonjs/Shaders/ShadersInclude/pbrFunctions" {
  44233. /** @hidden */
  44234. export var pbrFunctions: {
  44235. name: string;
  44236. shader: string;
  44237. };
  44238. }
  44239. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  44240. /** @hidden */
  44241. export var harmonicsFunctions: {
  44242. name: string;
  44243. shader: string;
  44244. };
  44245. }
  44246. declare module "babylonjs/Shaders/ShadersInclude/pbrPreLightingFunctions" {
  44247. /** @hidden */
  44248. export var pbrPreLightingFunctions: {
  44249. name: string;
  44250. shader: string;
  44251. };
  44252. }
  44253. declare module "babylonjs/Shaders/ShadersInclude/pbrFalloffLightingFunctions" {
  44254. /** @hidden */
  44255. export var pbrFalloffLightingFunctions: {
  44256. name: string;
  44257. shader: string;
  44258. };
  44259. }
  44260. declare module "babylonjs/Shaders/ShadersInclude/pbrLightingFunctions" {
  44261. /** @hidden */
  44262. export var pbrLightingFunctions: {
  44263. name: string;
  44264. shader: string;
  44265. };
  44266. }
  44267. declare module "babylonjs/Shaders/pbr.fragment" {
  44268. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  44269. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  44270. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44271. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44272. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  44273. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  44274. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44275. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  44276. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  44277. import "babylonjs/Shaders/ShadersInclude/pbrFunctions";
  44278. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  44279. import "babylonjs/Shaders/ShadersInclude/pbrPreLightingFunctions";
  44280. import "babylonjs/Shaders/ShadersInclude/pbrFalloffLightingFunctions";
  44281. import "babylonjs/Shaders/ShadersInclude/pbrLightingFunctions";
  44282. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  44283. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  44284. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  44285. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  44286. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  44287. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  44288. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  44289. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  44290. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  44291. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  44292. /** @hidden */
  44293. export var pbrPixelShader: {
  44294. name: string;
  44295. shader: string;
  44296. };
  44297. }
  44298. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  44299. /** @hidden */
  44300. export var pbrVertexDeclaration: {
  44301. name: string;
  44302. shader: string;
  44303. };
  44304. }
  44305. declare module "babylonjs/Shaders/pbr.vertex" {
  44306. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  44307. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  44308. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44309. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  44310. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  44311. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  44312. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  44313. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  44314. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  44315. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44316. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44317. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  44318. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  44319. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  44320. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  44321. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  44322. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  44323. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  44324. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  44325. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  44326. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  44327. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  44328. /** @hidden */
  44329. export var pbrVertexShader: {
  44330. name: string;
  44331. shader: string;
  44332. };
  44333. }
  44334. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  44335. import { IAnimatable } from "babylonjs/Misc/tools";
  44336. import { Nullable } from "babylonjs/types";
  44337. import { Scene } from "babylonjs/scene";
  44338. import { Matrix, Color3 } from "babylonjs/Maths/math";
  44339. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44340. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44341. import { Mesh } from "babylonjs/Meshes/mesh";
  44342. import { PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  44343. import { PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  44344. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44345. import { Material } from "babylonjs/Materials/material";
  44346. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  44347. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44348. import "babylonjs/Shaders/pbr.fragment";
  44349. import "babylonjs/Shaders/pbr.vertex";
  44350. /**
  44351. * The Physically based material base class of BJS.
  44352. *
  44353. * This offers the main features of a standard PBR material.
  44354. * For more information, please refer to the documentation :
  44355. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44356. */
  44357. export abstract class PBRBaseMaterial extends PushMaterial {
  44358. /**
  44359. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44360. */
  44361. static readonly PBRMATERIAL_OPAQUE: number;
  44362. /**
  44363. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44364. */
  44365. static readonly PBRMATERIAL_ALPHATEST: number;
  44366. /**
  44367. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44368. */
  44369. static readonly PBRMATERIAL_ALPHABLEND: number;
  44370. /**
  44371. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44372. * They are also discarded below the alpha cutoff threshold to improve performances.
  44373. */
  44374. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44375. /**
  44376. * Defines the default value of how much AO map is occluding the analytical lights
  44377. * (point spot...).
  44378. */
  44379. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44380. /**
  44381. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  44382. */
  44383. static readonly LIGHTFALLOFF_PHYSICAL: number;
  44384. /**
  44385. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  44386. * to enhance interoperability with other engines.
  44387. */
  44388. static readonly LIGHTFALLOFF_GLTF: number;
  44389. /**
  44390. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  44391. * to enhance interoperability with other materials.
  44392. */
  44393. static readonly LIGHTFALLOFF_STANDARD: number;
  44394. /**
  44395. * Intensity of the direct lights e.g. the four lights available in your scene.
  44396. * This impacts both the direct diffuse and specular highlights.
  44397. */
  44398. protected _directIntensity: number;
  44399. /**
  44400. * Intensity of the emissive part of the material.
  44401. * This helps controlling the emissive effect without modifying the emissive color.
  44402. */
  44403. protected _emissiveIntensity: number;
  44404. /**
  44405. * Intensity of the environment e.g. how much the environment will light the object
  44406. * either through harmonics for rough material or through the refelction for shiny ones.
  44407. */
  44408. protected _environmentIntensity: number;
  44409. /**
  44410. * This is a special control allowing the reduction of the specular highlights coming from the
  44411. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44412. */
  44413. protected _specularIntensity: number;
  44414. /**
  44415. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  44416. */
  44417. private _lightingInfos;
  44418. /**
  44419. * Debug Control allowing disabling the bump map on this material.
  44420. */
  44421. protected _disableBumpMap: boolean;
  44422. /**
  44423. * AKA Diffuse Texture in standard nomenclature.
  44424. */
  44425. protected _albedoTexture: BaseTexture;
  44426. /**
  44427. * AKA Occlusion Texture in other nomenclature.
  44428. */
  44429. protected _ambientTexture: BaseTexture;
  44430. /**
  44431. * AKA Occlusion Texture Intensity in other nomenclature.
  44432. */
  44433. protected _ambientTextureStrength: number;
  44434. /**
  44435. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44436. * 1 means it completely occludes it
  44437. * 0 mean it has no impact
  44438. */
  44439. protected _ambientTextureImpactOnAnalyticalLights: number;
  44440. /**
  44441. * Stores the alpha values in a texture.
  44442. */
  44443. protected _opacityTexture: BaseTexture;
  44444. /**
  44445. * Stores the reflection values in a texture.
  44446. */
  44447. protected _reflectionTexture: BaseTexture;
  44448. /**
  44449. * Stores the refraction values in a texture.
  44450. */
  44451. protected _refractionTexture: BaseTexture;
  44452. /**
  44453. * Stores the emissive values in a texture.
  44454. */
  44455. protected _emissiveTexture: BaseTexture;
  44456. /**
  44457. * AKA Specular texture in other nomenclature.
  44458. */
  44459. protected _reflectivityTexture: BaseTexture;
  44460. /**
  44461. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44462. */
  44463. protected _metallicTexture: BaseTexture;
  44464. /**
  44465. * Specifies the metallic scalar of the metallic/roughness workflow.
  44466. * Can also be used to scale the metalness values of the metallic texture.
  44467. */
  44468. protected _metallic: Nullable<number>;
  44469. /**
  44470. * Specifies the roughness scalar of the metallic/roughness workflow.
  44471. * Can also be used to scale the roughness values of the metallic texture.
  44472. */
  44473. protected _roughness: Nullable<number>;
  44474. /**
  44475. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44476. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44477. */
  44478. protected _microSurfaceTexture: BaseTexture;
  44479. /**
  44480. * Stores surface normal data used to displace a mesh in a texture.
  44481. */
  44482. protected _bumpTexture: BaseTexture;
  44483. /**
  44484. * Stores the pre-calculated light information of a mesh in a texture.
  44485. */
  44486. protected _lightmapTexture: BaseTexture;
  44487. /**
  44488. * The color of a material in ambient lighting.
  44489. */
  44490. protected _ambientColor: Color3;
  44491. /**
  44492. * AKA Diffuse Color in other nomenclature.
  44493. */
  44494. protected _albedoColor: Color3;
  44495. /**
  44496. * AKA Specular Color in other nomenclature.
  44497. */
  44498. protected _reflectivityColor: Color3;
  44499. /**
  44500. * The color applied when light is reflected from a material.
  44501. */
  44502. protected _reflectionColor: Color3;
  44503. /**
  44504. * The color applied when light is emitted from a material.
  44505. */
  44506. protected _emissiveColor: Color3;
  44507. /**
  44508. * AKA Glossiness in other nomenclature.
  44509. */
  44510. protected _microSurface: number;
  44511. /**
  44512. * source material index of refraction (IOR)' / 'destination material IOR.
  44513. */
  44514. protected _indexOfRefraction: number;
  44515. /**
  44516. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44517. */
  44518. protected _invertRefractionY: boolean;
  44519. /**
  44520. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44521. * Materials half opaque for instance using refraction could benefit from this control.
  44522. */
  44523. protected _linkRefractionWithTransparency: boolean;
  44524. /**
  44525. * Specifies that the material will use the light map as a show map.
  44526. */
  44527. protected _useLightmapAsShadowmap: boolean;
  44528. /**
  44529. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44530. * makes the reflect vector face the model (under horizon).
  44531. */
  44532. protected _useHorizonOcclusion: boolean;
  44533. /**
  44534. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44535. * too much the area relying on ambient texture to define their ambient occlusion.
  44536. */
  44537. protected _useRadianceOcclusion: boolean;
  44538. /**
  44539. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44540. */
  44541. protected _useAlphaFromAlbedoTexture: boolean;
  44542. /**
  44543. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  44544. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44545. */
  44546. protected _useSpecularOverAlpha: boolean;
  44547. /**
  44548. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44549. */
  44550. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44551. /**
  44552. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44553. */
  44554. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  44555. /**
  44556. * Specifies if the metallic texture contains the roughness information in its green channel.
  44557. */
  44558. protected _useRoughnessFromMetallicTextureGreen: boolean;
  44559. /**
  44560. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44561. */
  44562. protected _useMetallnessFromMetallicTextureBlue: boolean;
  44563. /**
  44564. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44565. */
  44566. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  44567. /**
  44568. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44569. */
  44570. protected _useAmbientInGrayScale: boolean;
  44571. /**
  44572. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44573. * The material will try to infer what glossiness each pixel should be.
  44574. */
  44575. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  44576. /**
  44577. * Defines the falloff type used in this material.
  44578. * It by default is Physical.
  44579. */
  44580. protected _lightFalloff: number;
  44581. /**
  44582. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44583. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44584. */
  44585. protected _useRadianceOverAlpha: boolean;
  44586. /**
  44587. * Allows using an object space normal map (instead of tangent space).
  44588. */
  44589. protected _useObjectSpaceNormalMap: boolean;
  44590. /**
  44591. * Allows using the bump map in parallax mode.
  44592. */
  44593. protected _useParallax: boolean;
  44594. /**
  44595. * Allows using the bump map in parallax occlusion mode.
  44596. */
  44597. protected _useParallaxOcclusion: boolean;
  44598. /**
  44599. * Controls the scale bias of the parallax mode.
  44600. */
  44601. protected _parallaxScaleBias: number;
  44602. /**
  44603. * If sets to true, disables all the lights affecting the material.
  44604. */
  44605. protected _disableLighting: boolean;
  44606. /**
  44607. * Number of Simultaneous lights allowed on the material.
  44608. */
  44609. protected _maxSimultaneousLights: number;
  44610. /**
  44611. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44612. */
  44613. protected _invertNormalMapX: boolean;
  44614. /**
  44615. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44616. */
  44617. protected _invertNormalMapY: boolean;
  44618. /**
  44619. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44620. */
  44621. protected _twoSidedLighting: boolean;
  44622. /**
  44623. * Defines the alpha limits in alpha test mode.
  44624. */
  44625. protected _alphaCutOff: number;
  44626. /**
  44627. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44628. */
  44629. protected _forceAlphaTest: boolean;
  44630. /**
  44631. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44632. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44633. */
  44634. protected _useAlphaFresnel: boolean;
  44635. /**
  44636. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44637. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44638. */
  44639. protected _useLinearAlphaFresnel: boolean;
  44640. /**
  44641. * The transparency mode of the material.
  44642. */
  44643. protected _transparencyMode: Nullable<number>;
  44644. /**
  44645. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  44646. * from cos thetav and roughness:
  44647. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  44648. */
  44649. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  44650. /**
  44651. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44652. */
  44653. protected _forceIrradianceInFragment: boolean;
  44654. /**
  44655. * Force normal to face away from face.
  44656. */
  44657. protected _forceNormalForward: boolean;
  44658. /**
  44659. * Enables specular anti aliasing in the PBR shader.
  44660. * It will both interacts on the Geometry for analytical and IBL lighting.
  44661. * It also prefilter the roughness map based on the bump values.
  44662. */
  44663. protected _enableSpecularAntiAliasing: boolean;
  44664. /**
  44665. * Default configuration related to image processing available in the PBR Material.
  44666. */
  44667. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44668. /**
  44669. * Keep track of the image processing observer to allow dispose and replace.
  44670. */
  44671. private _imageProcessingObserver;
  44672. /**
  44673. * Attaches a new image processing configuration to the PBR Material.
  44674. * @param configuration
  44675. */
  44676. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44677. /**
  44678. * Stores the available render targets.
  44679. */
  44680. private _renderTargets;
  44681. /**
  44682. * Sets the global ambient color for the material used in lighting calculations.
  44683. */
  44684. private _globalAmbientColor;
  44685. /**
  44686. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  44687. */
  44688. private _useLogarithmicDepth;
  44689. /**
  44690. * If set to true, no lighting calculations will be applied.
  44691. */
  44692. private _unlit;
  44693. /**
  44694. * Defines the clear coat layer parameters for the material.
  44695. */
  44696. readonly clearCoat: PBRClearCoatConfiguration;
  44697. /**
  44698. * Defines the anisotropic parameters for the material.
  44699. */
  44700. readonly anisotropy: PBRAnisotropicConfiguration;
  44701. /**
  44702. * Instantiates a new PBRMaterial instance.
  44703. *
  44704. * @param name The material name
  44705. * @param scene The scene the material will be use in.
  44706. */
  44707. constructor(name: string, scene: Scene);
  44708. /**
  44709. * Gets a boolean indicating that current material needs to register RTT
  44710. */
  44711. readonly hasRenderTargetTextures: boolean;
  44712. /**
  44713. * Gets the name of the material class.
  44714. */
  44715. getClassName(): string;
  44716. /**
  44717. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44718. */
  44719. /**
  44720. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44721. */
  44722. useLogarithmicDepth: boolean;
  44723. /**
  44724. * Gets the current transparency mode.
  44725. */
  44726. /**
  44727. * Sets the transparency mode of the material.
  44728. *
  44729. * | Value | Type | Description |
  44730. * | ----- | ----------------------------------- | ----------- |
  44731. * | 0 | OPAQUE | |
  44732. * | 1 | ALPHATEST | |
  44733. * | 2 | ALPHABLEND | |
  44734. * | 3 | ALPHATESTANDBLEND | |
  44735. *
  44736. */
  44737. transparencyMode: Nullable<number>;
  44738. /**
  44739. * Returns true if alpha blending should be disabled.
  44740. */
  44741. private readonly _disableAlphaBlending;
  44742. /**
  44743. * Specifies whether or not this material should be rendered in alpha blend mode.
  44744. */
  44745. needAlphaBlending(): boolean;
  44746. /**
  44747. * Specifies if the mesh will require alpha blending.
  44748. * @param mesh - BJS mesh.
  44749. */
  44750. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  44751. /**
  44752. * Specifies whether or not this material should be rendered in alpha test mode.
  44753. */
  44754. needAlphaTesting(): boolean;
  44755. /**
  44756. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  44757. */
  44758. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  44759. /**
  44760. * Gets the texture used for the alpha test.
  44761. */
  44762. getAlphaTestTexture(): BaseTexture;
  44763. /**
  44764. * Specifies that the submesh is ready to be used.
  44765. * @param mesh - BJS mesh.
  44766. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  44767. * @param useInstances - Specifies that instances should be used.
  44768. * @returns - boolean indicating that the submesh is ready or not.
  44769. */
  44770. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44771. /**
  44772. * Specifies if the material uses metallic roughness workflow.
  44773. * @returns boolean specifiying if the material uses metallic roughness workflow.
  44774. */
  44775. isMetallicWorkflow(): boolean;
  44776. private _prepareEffect;
  44777. private _prepareDefines;
  44778. /**
  44779. * Force shader compilation
  44780. */
  44781. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  44782. clipPlane: boolean;
  44783. }>): void;
  44784. /**
  44785. * Initializes the uniform buffer layout for the shader.
  44786. */
  44787. buildUniformLayout(): void;
  44788. /**
  44789. * Unbinds the textures.
  44790. */
  44791. unbind(): void;
  44792. /**
  44793. * Binds the submesh data.
  44794. * @param world - The world matrix.
  44795. * @param mesh - The BJS mesh.
  44796. * @param subMesh - A submesh of the BJS mesh.
  44797. */
  44798. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44799. /**
  44800. * Returns the animatable textures.
  44801. * @returns - Array of animatable textures.
  44802. */
  44803. getAnimatables(): IAnimatable[];
  44804. /**
  44805. * Returns the texture used for reflections.
  44806. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  44807. */
  44808. private _getReflectionTexture;
  44809. /**
  44810. * Returns the texture used for refraction or null if none is used.
  44811. * @returns - Refection texture if present. If no refraction texture and refraction
  44812. * is linked with transparency, returns environment texture. Otherwise, returns null.
  44813. */
  44814. private _getRefractionTexture;
  44815. /**
  44816. * Returns an array of the actively used textures.
  44817. * @returns - Array of BaseTextures
  44818. */
  44819. getActiveTextures(): BaseTexture[];
  44820. /**
  44821. * Checks to see if a texture is used in the material.
  44822. * @param texture - Base texture to use.
  44823. * @returns - Boolean specifying if a texture is used in the material.
  44824. */
  44825. hasTexture(texture: BaseTexture): boolean;
  44826. /**
  44827. * Disposes the resources of the material.
  44828. * @param forceDisposeEffect - Forces the disposal of effects.
  44829. * @param forceDisposeTextures - Forces the disposal of all textures.
  44830. */
  44831. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44832. }
  44833. }
  44834. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  44835. import { Nullable } from "babylonjs/types";
  44836. import { Scene } from "babylonjs/scene";
  44837. import { Color3 } from "babylonjs/Maths/math";
  44838. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44839. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  44840. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44841. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  44842. /**
  44843. * The Physically based material of BJS.
  44844. *
  44845. * This offers the main features of a standard PBR material.
  44846. * For more information, please refer to the documentation :
  44847. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44848. */
  44849. export class PBRMaterial extends PBRBaseMaterial {
  44850. /**
  44851. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44852. */
  44853. static readonly PBRMATERIAL_OPAQUE: number;
  44854. /**
  44855. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44856. */
  44857. static readonly PBRMATERIAL_ALPHATEST: number;
  44858. /**
  44859. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44860. */
  44861. static readonly PBRMATERIAL_ALPHABLEND: number;
  44862. /**
  44863. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44864. * They are also discarded below the alpha cutoff threshold to improve performances.
  44865. */
  44866. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44867. /**
  44868. * Defines the default value of how much AO map is occluding the analytical lights
  44869. * (point spot...).
  44870. */
  44871. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44872. /**
  44873. * Intensity of the direct lights e.g. the four lights available in your scene.
  44874. * This impacts both the direct diffuse and specular highlights.
  44875. */
  44876. directIntensity: number;
  44877. /**
  44878. * Intensity of the emissive part of the material.
  44879. * This helps controlling the emissive effect without modifying the emissive color.
  44880. */
  44881. emissiveIntensity: number;
  44882. /**
  44883. * Intensity of the environment e.g. how much the environment will light the object
  44884. * either through harmonics for rough material or through the refelction for shiny ones.
  44885. */
  44886. environmentIntensity: number;
  44887. /**
  44888. * This is a special control allowing the reduction of the specular highlights coming from the
  44889. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44890. */
  44891. specularIntensity: number;
  44892. /**
  44893. * Debug Control allowing disabling the bump map on this material.
  44894. */
  44895. disableBumpMap: boolean;
  44896. /**
  44897. * AKA Diffuse Texture in standard nomenclature.
  44898. */
  44899. albedoTexture: BaseTexture;
  44900. /**
  44901. * AKA Occlusion Texture in other nomenclature.
  44902. */
  44903. ambientTexture: BaseTexture;
  44904. /**
  44905. * AKA Occlusion Texture Intensity in other nomenclature.
  44906. */
  44907. ambientTextureStrength: number;
  44908. /**
  44909. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44910. * 1 means it completely occludes it
  44911. * 0 mean it has no impact
  44912. */
  44913. ambientTextureImpactOnAnalyticalLights: number;
  44914. /**
  44915. * Stores the alpha values in a texture.
  44916. */
  44917. opacityTexture: BaseTexture;
  44918. /**
  44919. * Stores the reflection values in a texture.
  44920. */
  44921. reflectionTexture: Nullable<BaseTexture>;
  44922. /**
  44923. * Stores the emissive values in a texture.
  44924. */
  44925. emissiveTexture: BaseTexture;
  44926. /**
  44927. * AKA Specular texture in other nomenclature.
  44928. */
  44929. reflectivityTexture: BaseTexture;
  44930. /**
  44931. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44932. */
  44933. metallicTexture: BaseTexture;
  44934. /**
  44935. * Specifies the metallic scalar of the metallic/roughness workflow.
  44936. * Can also be used to scale the metalness values of the metallic texture.
  44937. */
  44938. metallic: Nullable<number>;
  44939. /**
  44940. * Specifies the roughness scalar of the metallic/roughness workflow.
  44941. * Can also be used to scale the roughness values of the metallic texture.
  44942. */
  44943. roughness: Nullable<number>;
  44944. /**
  44945. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44946. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44947. */
  44948. microSurfaceTexture: BaseTexture;
  44949. /**
  44950. * Stores surface normal data used to displace a mesh in a texture.
  44951. */
  44952. bumpTexture: BaseTexture;
  44953. /**
  44954. * Stores the pre-calculated light information of a mesh in a texture.
  44955. */
  44956. lightmapTexture: BaseTexture;
  44957. /**
  44958. * Stores the refracted light information in a texture.
  44959. */
  44960. refractionTexture: BaseTexture;
  44961. /**
  44962. * The color of a material in ambient lighting.
  44963. */
  44964. ambientColor: Color3;
  44965. /**
  44966. * AKA Diffuse Color in other nomenclature.
  44967. */
  44968. albedoColor: Color3;
  44969. /**
  44970. * AKA Specular Color in other nomenclature.
  44971. */
  44972. reflectivityColor: Color3;
  44973. /**
  44974. * The color reflected from the material.
  44975. */
  44976. reflectionColor: Color3;
  44977. /**
  44978. * The color emitted from the material.
  44979. */
  44980. emissiveColor: Color3;
  44981. /**
  44982. * AKA Glossiness in other nomenclature.
  44983. */
  44984. microSurface: number;
  44985. /**
  44986. * source material index of refraction (IOR)' / 'destination material IOR.
  44987. */
  44988. indexOfRefraction: number;
  44989. /**
  44990. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44991. */
  44992. invertRefractionY: boolean;
  44993. /**
  44994. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44995. * Materials half opaque for instance using refraction could benefit from this control.
  44996. */
  44997. linkRefractionWithTransparency: boolean;
  44998. /**
  44999. * If true, the light map contains occlusion information instead of lighting info.
  45000. */
  45001. useLightmapAsShadowmap: boolean;
  45002. /**
  45003. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45004. */
  45005. useAlphaFromAlbedoTexture: boolean;
  45006. /**
  45007. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45008. */
  45009. forceAlphaTest: boolean;
  45010. /**
  45011. * Defines the alpha limits in alpha test mode.
  45012. */
  45013. alphaCutOff: number;
  45014. /**
  45015. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45016. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45017. */
  45018. useSpecularOverAlpha: boolean;
  45019. /**
  45020. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45021. */
  45022. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45023. /**
  45024. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45025. */
  45026. useRoughnessFromMetallicTextureAlpha: boolean;
  45027. /**
  45028. * Specifies if the metallic texture contains the roughness information in its green channel.
  45029. */
  45030. useRoughnessFromMetallicTextureGreen: boolean;
  45031. /**
  45032. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45033. */
  45034. useMetallnessFromMetallicTextureBlue: boolean;
  45035. /**
  45036. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45037. */
  45038. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45039. /**
  45040. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45041. */
  45042. useAmbientInGrayScale: boolean;
  45043. /**
  45044. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45045. * The material will try to infer what glossiness each pixel should be.
  45046. */
  45047. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45048. /**
  45049. * BJS is using an harcoded light falloff based on a manually sets up range.
  45050. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45051. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45052. */
  45053. /**
  45054. * BJS is using an harcoded light falloff based on a manually sets up range.
  45055. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45056. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45057. */
  45058. usePhysicalLightFalloff: boolean;
  45059. /**
  45060. * In order to support the falloff compatibility with gltf, a special mode has been added
  45061. * to reproduce the gltf light falloff.
  45062. */
  45063. /**
  45064. * In order to support the falloff compatibility with gltf, a special mode has been added
  45065. * to reproduce the gltf light falloff.
  45066. */
  45067. useGLTFLightFalloff: boolean;
  45068. /**
  45069. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45070. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45071. */
  45072. useRadianceOverAlpha: boolean;
  45073. /**
  45074. * Allows using an object space normal map (instead of tangent space).
  45075. */
  45076. useObjectSpaceNormalMap: boolean;
  45077. /**
  45078. * Allows using the bump map in parallax mode.
  45079. */
  45080. useParallax: boolean;
  45081. /**
  45082. * Allows using the bump map in parallax occlusion mode.
  45083. */
  45084. useParallaxOcclusion: boolean;
  45085. /**
  45086. * Controls the scale bias of the parallax mode.
  45087. */
  45088. parallaxScaleBias: number;
  45089. /**
  45090. * If sets to true, disables all the lights affecting the material.
  45091. */
  45092. disableLighting: boolean;
  45093. /**
  45094. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45095. */
  45096. forceIrradianceInFragment: boolean;
  45097. /**
  45098. * Number of Simultaneous lights allowed on the material.
  45099. */
  45100. maxSimultaneousLights: number;
  45101. /**
  45102. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45103. */
  45104. invertNormalMapX: boolean;
  45105. /**
  45106. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45107. */
  45108. invertNormalMapY: boolean;
  45109. /**
  45110. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45111. */
  45112. twoSidedLighting: boolean;
  45113. /**
  45114. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45115. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45116. */
  45117. useAlphaFresnel: boolean;
  45118. /**
  45119. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45120. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45121. */
  45122. useLinearAlphaFresnel: boolean;
  45123. /**
  45124. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45125. * And/Or occlude the blended part.
  45126. */
  45127. environmentBRDFTexture: Nullable<BaseTexture>;
  45128. /**
  45129. * Force normal to face away from face.
  45130. */
  45131. forceNormalForward: boolean;
  45132. /**
  45133. * Enables specular anti aliasing in the PBR shader.
  45134. * It will both interacts on the Geometry for analytical and IBL lighting.
  45135. * It also prefilter the roughness map based on the bump values.
  45136. */
  45137. enableSpecularAntiAliasing: boolean;
  45138. /**
  45139. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45140. * makes the reflect vector face the model (under horizon).
  45141. */
  45142. useHorizonOcclusion: boolean;
  45143. /**
  45144. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45145. * too much the area relying on ambient texture to define their ambient occlusion.
  45146. */
  45147. useRadianceOcclusion: boolean;
  45148. /**
  45149. * If set to true, no lighting calculations will be applied.
  45150. */
  45151. unlit: boolean;
  45152. /**
  45153. * Gets the image processing configuration used either in this material.
  45154. */
  45155. /**
  45156. * Sets the Default image processing configuration used either in the this material.
  45157. *
  45158. * If sets to null, the scene one is in use.
  45159. */
  45160. imageProcessingConfiguration: ImageProcessingConfiguration;
  45161. /**
  45162. * Gets wether the color curves effect is enabled.
  45163. */
  45164. /**
  45165. * Sets wether the color curves effect is enabled.
  45166. */
  45167. cameraColorCurvesEnabled: boolean;
  45168. /**
  45169. * Gets wether the color grading effect is enabled.
  45170. */
  45171. /**
  45172. * Gets wether the color grading effect is enabled.
  45173. */
  45174. cameraColorGradingEnabled: boolean;
  45175. /**
  45176. * Gets wether tonemapping is enabled or not.
  45177. */
  45178. /**
  45179. * Sets wether tonemapping is enabled or not
  45180. */
  45181. cameraToneMappingEnabled: boolean;
  45182. /**
  45183. * The camera exposure used on this material.
  45184. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45185. * This corresponds to a photographic exposure.
  45186. */
  45187. /**
  45188. * The camera exposure used on this material.
  45189. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45190. * This corresponds to a photographic exposure.
  45191. */
  45192. cameraExposure: number;
  45193. /**
  45194. * Gets The camera contrast used on this material.
  45195. */
  45196. /**
  45197. * Sets The camera contrast used on this material.
  45198. */
  45199. cameraContrast: number;
  45200. /**
  45201. * Gets the Color Grading 2D Lookup Texture.
  45202. */
  45203. /**
  45204. * Sets the Color Grading 2D Lookup Texture.
  45205. */
  45206. cameraColorGradingTexture: Nullable<BaseTexture>;
  45207. /**
  45208. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45209. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45210. * 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;
  45211. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45212. */
  45213. /**
  45214. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45215. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45216. * 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;
  45217. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45218. */
  45219. cameraColorCurves: Nullable<ColorCurves>;
  45220. /**
  45221. * Instantiates a new PBRMaterial instance.
  45222. *
  45223. * @param name The material name
  45224. * @param scene The scene the material will be use in.
  45225. */
  45226. constructor(name: string, scene: Scene);
  45227. /**
  45228. * Returns the name of this material class.
  45229. */
  45230. getClassName(): string;
  45231. /**
  45232. * Makes a duplicate of the current material.
  45233. * @param name - name to use for the new material.
  45234. */
  45235. clone(name: string): PBRMaterial;
  45236. /**
  45237. * Serializes this PBR Material.
  45238. * @returns - An object with the serialized material.
  45239. */
  45240. serialize(): any;
  45241. /**
  45242. * Parses a PBR Material from a serialized object.
  45243. * @param source - Serialized object.
  45244. * @param scene - BJS scene instance.
  45245. * @param rootUrl - url for the scene object
  45246. * @returns - PBRMaterial
  45247. */
  45248. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  45249. }
  45250. }
  45251. declare module "babylonjs/Helpers/sceneHelpers" {
  45252. import { Nullable } from "babylonjs/types";
  45253. import { Mesh } from "babylonjs/Meshes/mesh";
  45254. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45255. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  45256. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  45257. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  45258. import "babylonjs/Meshes/Builders/boxBuilder";
  45259. /** @hidden */
  45260. export var _forceSceneHelpersToBundle: boolean;
  45261. module "babylonjs/scene" {
  45262. interface Scene {
  45263. /**
  45264. * Creates a default light for the scene.
  45265. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  45266. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  45267. */
  45268. createDefaultLight(replace?: boolean): void;
  45269. /**
  45270. * Creates a default camera for the scene.
  45271. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  45272. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45273. * @param replace has default false, when true replaces the active camera in the scene
  45274. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  45275. */
  45276. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45277. /**
  45278. * Creates a default camera and a default light.
  45279. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  45280. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45281. * @param replace has the default false, when true replaces the active camera/light in the scene
  45282. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  45283. */
  45284. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45285. /**
  45286. * Creates a new sky box
  45287. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  45288. * @param environmentTexture defines the texture to use as environment texture
  45289. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  45290. * @param scale defines the overall scale of the skybox
  45291. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  45292. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  45293. * @returns a new mesh holding the sky box
  45294. */
  45295. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  45296. /**
  45297. * Creates a new environment
  45298. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  45299. * @param options defines the options you can use to configure the environment
  45300. * @returns the new EnvironmentHelper
  45301. */
  45302. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  45303. /**
  45304. * Creates a new VREXperienceHelper
  45305. * @see http://doc.babylonjs.com/how_to/webvr_helper
  45306. * @param webVROptions defines the options used to create the new VREXperienceHelper
  45307. * @returns a new VREXperienceHelper
  45308. */
  45309. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  45310. /**
  45311. * Creates a new XREXperienceHelper
  45312. * @see http://doc.babylonjs.com/how_to/webxr
  45313. * @returns a promise for a new XREXperienceHelper
  45314. */
  45315. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  45316. }
  45317. }
  45318. }
  45319. declare module "babylonjs/Helpers/videoDome" {
  45320. import { Scene } from "babylonjs/scene";
  45321. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45322. import { Mesh } from "babylonjs/Meshes/mesh";
  45323. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  45324. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45325. import "babylonjs/Meshes/Builders/sphereBuilder";
  45326. /**
  45327. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  45328. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  45329. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  45330. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45331. */
  45332. export class VideoDome extends TransformNode {
  45333. private _useDirectMapping;
  45334. /**
  45335. * The video texture being displayed on the sphere
  45336. */
  45337. protected _videoTexture: VideoTexture;
  45338. /**
  45339. * Gets the video texture being displayed on the sphere
  45340. */
  45341. readonly videoTexture: VideoTexture;
  45342. /**
  45343. * The skybox material
  45344. */
  45345. protected _material: BackgroundMaterial;
  45346. /**
  45347. * The surface used for the skybox
  45348. */
  45349. protected _mesh: Mesh;
  45350. /**
  45351. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45352. * Also see the options.resolution property.
  45353. */
  45354. fovMultiplier: number;
  45355. /**
  45356. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  45357. * @param name Element's name, child elements will append suffixes for their own names.
  45358. * @param urlsOrVideo defines the url(s) or the video element to use
  45359. * @param options An object containing optional or exposed sub element properties
  45360. */
  45361. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  45362. resolution?: number;
  45363. clickToPlay?: boolean;
  45364. autoPlay?: boolean;
  45365. loop?: boolean;
  45366. size?: number;
  45367. poster?: string;
  45368. useDirectMapping?: boolean;
  45369. }, scene: Scene);
  45370. /**
  45371. * Releases resources associated with this node.
  45372. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45373. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45374. */
  45375. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45376. }
  45377. }
  45378. declare module "babylonjs/Helpers/index" {
  45379. export * from "babylonjs/Helpers/environmentHelper";
  45380. export * from "babylonjs/Helpers/photoDome";
  45381. export * from "babylonjs/Helpers/sceneHelpers";
  45382. export * from "babylonjs/Helpers/videoDome";
  45383. }
  45384. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  45385. import { PerfCounter } from "babylonjs/Misc/tools";
  45386. import { IDisposable } from "babylonjs/scene";
  45387. import { Engine } from "babylonjs/Engines/engine";
  45388. /**
  45389. * This class can be used to get instrumentation data from a Babylon engine
  45390. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45391. */
  45392. export class EngineInstrumentation implements IDisposable {
  45393. /**
  45394. * Define the instrumented engine.
  45395. */
  45396. engine: Engine;
  45397. private _captureGPUFrameTime;
  45398. private _gpuFrameTimeToken;
  45399. private _gpuFrameTime;
  45400. private _captureShaderCompilationTime;
  45401. private _shaderCompilationTime;
  45402. private _onBeginFrameObserver;
  45403. private _onEndFrameObserver;
  45404. private _onBeforeShaderCompilationObserver;
  45405. private _onAfterShaderCompilationObserver;
  45406. /**
  45407. * Gets the perf counter used for GPU frame time
  45408. */
  45409. readonly gpuFrameTimeCounter: PerfCounter;
  45410. /**
  45411. * Gets the GPU frame time capture status
  45412. */
  45413. /**
  45414. * Enable or disable the GPU frame time capture
  45415. */
  45416. captureGPUFrameTime: boolean;
  45417. /**
  45418. * Gets the perf counter used for shader compilation time
  45419. */
  45420. readonly shaderCompilationTimeCounter: PerfCounter;
  45421. /**
  45422. * Gets the shader compilation time capture status
  45423. */
  45424. /**
  45425. * Enable or disable the shader compilation time capture
  45426. */
  45427. captureShaderCompilationTime: boolean;
  45428. /**
  45429. * Instantiates a new engine instrumentation.
  45430. * This class can be used to get instrumentation data from a Babylon engine
  45431. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45432. * @param engine Defines the engine to instrument
  45433. */
  45434. constructor(
  45435. /**
  45436. * Define the instrumented engine.
  45437. */
  45438. engine: Engine);
  45439. /**
  45440. * Dispose and release associated resources.
  45441. */
  45442. dispose(): void;
  45443. }
  45444. }
  45445. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  45446. import { PerfCounter } from "babylonjs/Misc/tools";
  45447. import { Scene, IDisposable } from "babylonjs/scene";
  45448. /**
  45449. * This class can be used to get instrumentation data from a Babylon engine
  45450. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45451. */
  45452. export class SceneInstrumentation implements IDisposable {
  45453. /**
  45454. * Defines the scene to instrument
  45455. */
  45456. scene: Scene;
  45457. private _captureActiveMeshesEvaluationTime;
  45458. private _activeMeshesEvaluationTime;
  45459. private _captureRenderTargetsRenderTime;
  45460. private _renderTargetsRenderTime;
  45461. private _captureFrameTime;
  45462. private _frameTime;
  45463. private _captureRenderTime;
  45464. private _renderTime;
  45465. private _captureInterFrameTime;
  45466. private _interFrameTime;
  45467. private _captureParticlesRenderTime;
  45468. private _particlesRenderTime;
  45469. private _captureSpritesRenderTime;
  45470. private _spritesRenderTime;
  45471. private _capturePhysicsTime;
  45472. private _physicsTime;
  45473. private _captureAnimationsTime;
  45474. private _animationsTime;
  45475. private _captureCameraRenderTime;
  45476. private _cameraRenderTime;
  45477. private _onBeforeActiveMeshesEvaluationObserver;
  45478. private _onAfterActiveMeshesEvaluationObserver;
  45479. private _onBeforeRenderTargetsRenderObserver;
  45480. private _onAfterRenderTargetsRenderObserver;
  45481. private _onAfterRenderObserver;
  45482. private _onBeforeDrawPhaseObserver;
  45483. private _onAfterDrawPhaseObserver;
  45484. private _onBeforeAnimationsObserver;
  45485. private _onBeforeParticlesRenderingObserver;
  45486. private _onAfterParticlesRenderingObserver;
  45487. private _onBeforeSpritesRenderingObserver;
  45488. private _onAfterSpritesRenderingObserver;
  45489. private _onBeforePhysicsObserver;
  45490. private _onAfterPhysicsObserver;
  45491. private _onAfterAnimationsObserver;
  45492. private _onBeforeCameraRenderObserver;
  45493. private _onAfterCameraRenderObserver;
  45494. /**
  45495. * Gets the perf counter used for active meshes evaluation time
  45496. */
  45497. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  45498. /**
  45499. * Gets the active meshes evaluation time capture status
  45500. */
  45501. /**
  45502. * Enable or disable the active meshes evaluation time capture
  45503. */
  45504. captureActiveMeshesEvaluationTime: boolean;
  45505. /**
  45506. * Gets the perf counter used for render targets render time
  45507. */
  45508. readonly renderTargetsRenderTimeCounter: PerfCounter;
  45509. /**
  45510. * Gets the render targets render time capture status
  45511. */
  45512. /**
  45513. * Enable or disable the render targets render time capture
  45514. */
  45515. captureRenderTargetsRenderTime: boolean;
  45516. /**
  45517. * Gets the perf counter used for particles render time
  45518. */
  45519. readonly particlesRenderTimeCounter: PerfCounter;
  45520. /**
  45521. * Gets the particles render time capture status
  45522. */
  45523. /**
  45524. * Enable or disable the particles render time capture
  45525. */
  45526. captureParticlesRenderTime: boolean;
  45527. /**
  45528. * Gets the perf counter used for sprites render time
  45529. */
  45530. readonly spritesRenderTimeCounter: PerfCounter;
  45531. /**
  45532. * Gets the sprites render time capture status
  45533. */
  45534. /**
  45535. * Enable or disable the sprites render time capture
  45536. */
  45537. captureSpritesRenderTime: boolean;
  45538. /**
  45539. * Gets the perf counter used for physics time
  45540. */
  45541. readonly physicsTimeCounter: PerfCounter;
  45542. /**
  45543. * Gets the physics time capture status
  45544. */
  45545. /**
  45546. * Enable or disable the physics time capture
  45547. */
  45548. capturePhysicsTime: boolean;
  45549. /**
  45550. * Gets the perf counter used for animations time
  45551. */
  45552. readonly animationsTimeCounter: PerfCounter;
  45553. /**
  45554. * Gets the animations time capture status
  45555. */
  45556. /**
  45557. * Enable or disable the animations time capture
  45558. */
  45559. captureAnimationsTime: boolean;
  45560. /**
  45561. * Gets the perf counter used for frame time capture
  45562. */
  45563. readonly frameTimeCounter: PerfCounter;
  45564. /**
  45565. * Gets the frame time capture status
  45566. */
  45567. /**
  45568. * Enable or disable the frame time capture
  45569. */
  45570. captureFrameTime: boolean;
  45571. /**
  45572. * Gets the perf counter used for inter-frames time capture
  45573. */
  45574. readonly interFrameTimeCounter: PerfCounter;
  45575. /**
  45576. * Gets the inter-frames time capture status
  45577. */
  45578. /**
  45579. * Enable or disable the inter-frames time capture
  45580. */
  45581. captureInterFrameTime: boolean;
  45582. /**
  45583. * Gets the perf counter used for render time capture
  45584. */
  45585. readonly renderTimeCounter: PerfCounter;
  45586. /**
  45587. * Gets the render time capture status
  45588. */
  45589. /**
  45590. * Enable or disable the render time capture
  45591. */
  45592. captureRenderTime: boolean;
  45593. /**
  45594. * Gets the perf counter used for camera render time capture
  45595. */
  45596. readonly cameraRenderTimeCounter: PerfCounter;
  45597. /**
  45598. * Gets the camera render time capture status
  45599. */
  45600. /**
  45601. * Enable or disable the camera render time capture
  45602. */
  45603. captureCameraRenderTime: boolean;
  45604. /**
  45605. * Gets the perf counter used for draw calls
  45606. */
  45607. readonly drawCallsCounter: PerfCounter;
  45608. /**
  45609. * Gets the perf counter used for texture collisions
  45610. */
  45611. readonly textureCollisionsCounter: PerfCounter;
  45612. /**
  45613. * Instantiates a new scene instrumentation.
  45614. * This class can be used to get instrumentation data from a Babylon engine
  45615. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45616. * @param scene Defines the scene to instrument
  45617. */
  45618. constructor(
  45619. /**
  45620. * Defines the scene to instrument
  45621. */
  45622. scene: Scene);
  45623. /**
  45624. * Dispose and release associated resources.
  45625. */
  45626. dispose(): void;
  45627. }
  45628. }
  45629. declare module "babylonjs/Instrumentation/index" {
  45630. export * from "babylonjs/Instrumentation/engineInstrumentation";
  45631. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  45632. export * from "babylonjs/Instrumentation/timeToken";
  45633. }
  45634. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  45635. /** @hidden */
  45636. export var glowMapGenerationPixelShader: {
  45637. name: string;
  45638. shader: string;
  45639. };
  45640. }
  45641. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  45642. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45643. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  45644. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  45645. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45646. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  45647. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45648. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45649. /** @hidden */
  45650. export var glowMapGenerationVertexShader: {
  45651. name: string;
  45652. shader: string;
  45653. };
  45654. }
  45655. declare module "babylonjs/Layers/effectLayer" {
  45656. import { Observable } from "babylonjs/Misc/observable";
  45657. import { Nullable } from "babylonjs/types";
  45658. import { Camera } from "babylonjs/Cameras/camera";
  45659. import { Scene } from "babylonjs/scene";
  45660. import { Color4, ISize } from "babylonjs/Maths/math";
  45661. import { Engine } from "babylonjs/Engines/engine";
  45662. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45663. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45664. import { Mesh } from "babylonjs/Meshes/mesh";
  45665. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  45666. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45667. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45668. import { Effect } from "babylonjs/Materials/effect";
  45669. import { Material } from "babylonjs/Materials/material";
  45670. import "babylonjs/Shaders/glowMapGeneration.fragment";
  45671. import "babylonjs/Shaders/glowMapGeneration.vertex";
  45672. /**
  45673. * Effect layer options. This helps customizing the behaviour
  45674. * of the effect layer.
  45675. */
  45676. export interface IEffectLayerOptions {
  45677. /**
  45678. * Multiplication factor apply to the canvas size to compute the render target size
  45679. * used to generated the objects (the smaller the faster).
  45680. */
  45681. mainTextureRatio: number;
  45682. /**
  45683. * Enforces a fixed size texture to ensure effect stability across devices.
  45684. */
  45685. mainTextureFixedSize?: number;
  45686. /**
  45687. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  45688. */
  45689. alphaBlendingMode: number;
  45690. /**
  45691. * The camera attached to the layer.
  45692. */
  45693. camera: Nullable<Camera>;
  45694. /**
  45695. * The rendering group to draw the layer in.
  45696. */
  45697. renderingGroupId: number;
  45698. }
  45699. /**
  45700. * The effect layer Helps adding post process effect blended with the main pass.
  45701. *
  45702. * This can be for instance use to generate glow or higlight effects on the scene.
  45703. *
  45704. * The effect layer class can not be used directly and is intented to inherited from to be
  45705. * customized per effects.
  45706. */
  45707. export abstract class EffectLayer {
  45708. private _vertexBuffers;
  45709. private _indexBuffer;
  45710. private _cachedDefines;
  45711. private _effectLayerMapGenerationEffect;
  45712. private _effectLayerOptions;
  45713. private _mergeEffect;
  45714. protected _scene: Scene;
  45715. protected _engine: Engine;
  45716. protected _maxSize: number;
  45717. protected _mainTextureDesiredSize: ISize;
  45718. protected _mainTexture: RenderTargetTexture;
  45719. protected _shouldRender: boolean;
  45720. protected _postProcesses: PostProcess[];
  45721. protected _textures: BaseTexture[];
  45722. protected _emissiveTextureAndColor: {
  45723. texture: Nullable<BaseTexture>;
  45724. color: Color4;
  45725. };
  45726. /**
  45727. * The name of the layer
  45728. */
  45729. name: string;
  45730. /**
  45731. * The clear color of the texture used to generate the glow map.
  45732. */
  45733. neutralColor: Color4;
  45734. /**
  45735. * Specifies wether the highlight layer is enabled or not.
  45736. */
  45737. isEnabled: boolean;
  45738. /**
  45739. * Gets the camera attached to the layer.
  45740. */
  45741. readonly camera: Nullable<Camera>;
  45742. /**
  45743. * Gets the rendering group id the layer should render in.
  45744. */
  45745. readonly renderingGroupId: number;
  45746. /**
  45747. * An event triggered when the effect layer has been disposed.
  45748. */
  45749. onDisposeObservable: Observable<EffectLayer>;
  45750. /**
  45751. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  45752. */
  45753. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  45754. /**
  45755. * An event triggered when the generated texture is being merged in the scene.
  45756. */
  45757. onBeforeComposeObservable: Observable<EffectLayer>;
  45758. /**
  45759. * An event triggered when the generated texture has been merged in the scene.
  45760. */
  45761. onAfterComposeObservable: Observable<EffectLayer>;
  45762. /**
  45763. * An event triggered when the efffect layer changes its size.
  45764. */
  45765. onSizeChangedObservable: Observable<EffectLayer>;
  45766. /** @hidden */
  45767. static _SceneComponentInitialization: (scene: Scene) => void;
  45768. /**
  45769. * Instantiates a new effect Layer and references it in the scene.
  45770. * @param name The name of the layer
  45771. * @param scene The scene to use the layer in
  45772. */
  45773. constructor(
  45774. /** The Friendly of the effect in the scene */
  45775. name: string, scene: Scene);
  45776. /**
  45777. * Get the effect name of the layer.
  45778. * @return The effect name
  45779. */
  45780. abstract getEffectName(): string;
  45781. /**
  45782. * Checks for the readiness of the element composing the layer.
  45783. * @param subMesh the mesh to check for
  45784. * @param useInstances specify wether or not to use instances to render the mesh
  45785. * @return true if ready otherwise, false
  45786. */
  45787. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  45788. /**
  45789. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  45790. * @returns true if the effect requires stencil during the main canvas render pass.
  45791. */
  45792. abstract needStencil(): boolean;
  45793. /**
  45794. * Create the merge effect. This is the shader use to blit the information back
  45795. * to the main canvas at the end of the scene rendering.
  45796. * @returns The effect containing the shader used to merge the effect on the main canvas
  45797. */
  45798. protected abstract _createMergeEffect(): Effect;
  45799. /**
  45800. * Creates the render target textures and post processes used in the effect layer.
  45801. */
  45802. protected abstract _createTextureAndPostProcesses(): void;
  45803. /**
  45804. * Implementation specific of rendering the generating effect on the main canvas.
  45805. * @param effect The effect used to render through
  45806. */
  45807. protected abstract _internalRender(effect: Effect): void;
  45808. /**
  45809. * Sets the required values for both the emissive texture and and the main color.
  45810. */
  45811. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  45812. /**
  45813. * Free any resources and references associated to a mesh.
  45814. * Internal use
  45815. * @param mesh The mesh to free.
  45816. */
  45817. abstract _disposeMesh(mesh: Mesh): void;
  45818. /**
  45819. * Serializes this layer (Glow or Highlight for example)
  45820. * @returns a serialized layer object
  45821. */
  45822. abstract serialize?(): any;
  45823. /**
  45824. * Initializes the effect layer with the required options.
  45825. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  45826. */
  45827. protected _init(options: Partial<IEffectLayerOptions>): void;
  45828. /**
  45829. * Generates the index buffer of the full screen quad blending to the main canvas.
  45830. */
  45831. private _generateIndexBuffer;
  45832. /**
  45833. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  45834. */
  45835. private _genrateVertexBuffer;
  45836. /**
  45837. * Sets the main texture desired size which is the closest power of two
  45838. * of the engine canvas size.
  45839. */
  45840. private _setMainTextureSize;
  45841. /**
  45842. * Creates the main texture for the effect layer.
  45843. */
  45844. protected _createMainTexture(): void;
  45845. /**
  45846. * Adds specific effects defines.
  45847. * @param defines The defines to add specifics to.
  45848. */
  45849. protected _addCustomEffectDefines(defines: string[]): void;
  45850. /**
  45851. * Checks for the readiness of the element composing the layer.
  45852. * @param subMesh the mesh to check for
  45853. * @param useInstances specify wether or not to use instances to render the mesh
  45854. * @param emissiveTexture the associated emissive texture used to generate the glow
  45855. * @return true if ready otherwise, false
  45856. */
  45857. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  45858. /**
  45859. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  45860. */
  45861. render(): void;
  45862. /**
  45863. * Determine if a given mesh will be used in the current effect.
  45864. * @param mesh mesh to test
  45865. * @returns true if the mesh will be used
  45866. */
  45867. hasMesh(mesh: AbstractMesh): boolean;
  45868. /**
  45869. * Returns true if the layer contains information to display, otherwise false.
  45870. * @returns true if the glow layer should be rendered
  45871. */
  45872. shouldRender(): boolean;
  45873. /**
  45874. * Returns true if the mesh should render, otherwise false.
  45875. * @param mesh The mesh to render
  45876. * @returns true if it should render otherwise false
  45877. */
  45878. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  45879. /**
  45880. * Returns true if the mesh can be rendered, otherwise false.
  45881. * @param mesh The mesh to render
  45882. * @param material The material used on the mesh
  45883. * @returns true if it can be rendered otherwise false
  45884. */
  45885. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  45886. /**
  45887. * Returns true if the mesh should render, otherwise false.
  45888. * @param mesh The mesh to render
  45889. * @returns true if it should render otherwise false
  45890. */
  45891. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  45892. /**
  45893. * Renders the submesh passed in parameter to the generation map.
  45894. */
  45895. protected _renderSubMesh(subMesh: SubMesh): void;
  45896. /**
  45897. * Rebuild the required buffers.
  45898. * @hidden Internal use only.
  45899. */
  45900. _rebuild(): void;
  45901. /**
  45902. * Dispose only the render target textures and post process.
  45903. */
  45904. private _disposeTextureAndPostProcesses;
  45905. /**
  45906. * Dispose the highlight layer and free resources.
  45907. */
  45908. dispose(): void;
  45909. /**
  45910. * Gets the class name of the effect layer
  45911. * @returns the string with the class name of the effect layer
  45912. */
  45913. getClassName(): string;
  45914. /**
  45915. * Creates an effect layer from parsed effect layer data
  45916. * @param parsedEffectLayer defines effect layer data
  45917. * @param scene defines the current scene
  45918. * @param rootUrl defines the root URL containing the effect layer information
  45919. * @returns a parsed effect Layer
  45920. */
  45921. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  45922. }
  45923. }
  45924. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  45925. import { Scene } from "babylonjs/scene";
  45926. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  45927. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  45928. import { AbstractScene } from "babylonjs/abstractScene";
  45929. module "babylonjs/abstractScene" {
  45930. interface AbstractScene {
  45931. /**
  45932. * The list of effect layers (highlights/glow) added to the scene
  45933. * @see http://doc.babylonjs.com/how_to/highlight_layer
  45934. * @see http://doc.babylonjs.com/how_to/glow_layer
  45935. */
  45936. effectLayers: Array<EffectLayer>;
  45937. /**
  45938. * Removes the given effect layer from this scene.
  45939. * @param toRemove defines the effect layer to remove
  45940. * @returns the index of the removed effect layer
  45941. */
  45942. removeEffectLayer(toRemove: EffectLayer): number;
  45943. /**
  45944. * Adds the given effect layer to this scene
  45945. * @param newEffectLayer defines the effect layer to add
  45946. */
  45947. addEffectLayer(newEffectLayer: EffectLayer): void;
  45948. }
  45949. }
  45950. /**
  45951. * Defines the layer scene component responsible to manage any effect layers
  45952. * in a given scene.
  45953. */
  45954. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  45955. /**
  45956. * The component name helpfull to identify the component in the list of scene components.
  45957. */
  45958. readonly name: string;
  45959. /**
  45960. * The scene the component belongs to.
  45961. */
  45962. scene: Scene;
  45963. private _engine;
  45964. private _renderEffects;
  45965. private _needStencil;
  45966. private _previousStencilState;
  45967. /**
  45968. * Creates a new instance of the component for the given scene
  45969. * @param scene Defines the scene to register the component in
  45970. */
  45971. constructor(scene: Scene);
  45972. /**
  45973. * Registers the component in a given scene
  45974. */
  45975. register(): void;
  45976. /**
  45977. * Rebuilds the elements related to this component in case of
  45978. * context lost for instance.
  45979. */
  45980. rebuild(): void;
  45981. /**
  45982. * Serializes the component data to the specified json object
  45983. * @param serializationObject The object to serialize to
  45984. */
  45985. serialize(serializationObject: any): void;
  45986. /**
  45987. * Adds all the element from the container to the scene
  45988. * @param container the container holding the elements
  45989. */
  45990. addFromContainer(container: AbstractScene): void;
  45991. /**
  45992. * Removes all the elements in the container from the scene
  45993. * @param container contains the elements to remove
  45994. */
  45995. removeFromContainer(container: AbstractScene): void;
  45996. /**
  45997. * Disposes the component and the associated ressources.
  45998. */
  45999. dispose(): void;
  46000. private _isReadyForMesh;
  46001. private _renderMainTexture;
  46002. private _setStencil;
  46003. private _setStencilBack;
  46004. private _draw;
  46005. private _drawCamera;
  46006. private _drawRenderingGroup;
  46007. }
  46008. }
  46009. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  46010. /** @hidden */
  46011. export var glowMapMergePixelShader: {
  46012. name: string;
  46013. shader: string;
  46014. };
  46015. }
  46016. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  46017. /** @hidden */
  46018. export var glowMapMergeVertexShader: {
  46019. name: string;
  46020. shader: string;
  46021. };
  46022. }
  46023. declare module "babylonjs/Layers/glowLayer" {
  46024. import { Nullable } from "babylonjs/types";
  46025. import { Camera } from "babylonjs/Cameras/camera";
  46026. import { Scene } from "babylonjs/scene";
  46027. import { Color4 } from "babylonjs/Maths/math";
  46028. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46029. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46030. import { Mesh } from "babylonjs/Meshes/mesh";
  46031. import { Texture } from "babylonjs/Materials/Textures/texture";
  46032. import { Effect } from "babylonjs/Materials/effect";
  46033. import { Material } from "babylonjs/Materials/material";
  46034. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  46035. import "babylonjs/Shaders/glowMapMerge.fragment";
  46036. import "babylonjs/Shaders/glowMapMerge.vertex";
  46037. module "babylonjs/abstractScene" {
  46038. interface AbstractScene {
  46039. /**
  46040. * Return a the first highlight layer of the scene with a given name.
  46041. * @param name The name of the highlight layer to look for.
  46042. * @return The highlight layer if found otherwise null.
  46043. */
  46044. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  46045. }
  46046. }
  46047. /**
  46048. * Glow layer options. This helps customizing the behaviour
  46049. * of the glow layer.
  46050. */
  46051. export interface IGlowLayerOptions {
  46052. /**
  46053. * Multiplication factor apply to the canvas size to compute the render target size
  46054. * used to generated the glowing objects (the smaller the faster).
  46055. */
  46056. mainTextureRatio: number;
  46057. /**
  46058. * Enforces a fixed size texture to ensure resize independant blur.
  46059. */
  46060. mainTextureFixedSize?: number;
  46061. /**
  46062. * How big is the kernel of the blur texture.
  46063. */
  46064. blurKernelSize: number;
  46065. /**
  46066. * The camera attached to the layer.
  46067. */
  46068. camera: Nullable<Camera>;
  46069. /**
  46070. * Enable MSAA by chosing the number of samples.
  46071. */
  46072. mainTextureSamples?: number;
  46073. /**
  46074. * The rendering group to draw the layer in.
  46075. */
  46076. renderingGroupId: number;
  46077. }
  46078. /**
  46079. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  46080. *
  46081. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46082. * glowy meshes to your scene.
  46083. *
  46084. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  46085. */
  46086. export class GlowLayer extends EffectLayer {
  46087. /**
  46088. * Effect Name of the layer.
  46089. */
  46090. static readonly EffectName: string;
  46091. /**
  46092. * The default blur kernel size used for the glow.
  46093. */
  46094. static DefaultBlurKernelSize: number;
  46095. /**
  46096. * The default texture size ratio used for the glow.
  46097. */
  46098. static DefaultTextureRatio: number;
  46099. /**
  46100. * Sets the kernel size of the blur.
  46101. */
  46102. /**
  46103. * Gets the kernel size of the blur.
  46104. */
  46105. blurKernelSize: number;
  46106. /**
  46107. * Sets the glow intensity.
  46108. */
  46109. /**
  46110. * Gets the glow intensity.
  46111. */
  46112. intensity: number;
  46113. private _options;
  46114. private _intensity;
  46115. private _horizontalBlurPostprocess1;
  46116. private _verticalBlurPostprocess1;
  46117. private _horizontalBlurPostprocess2;
  46118. private _verticalBlurPostprocess2;
  46119. private _blurTexture1;
  46120. private _blurTexture2;
  46121. private _postProcesses1;
  46122. private _postProcesses2;
  46123. private _includedOnlyMeshes;
  46124. private _excludedMeshes;
  46125. /**
  46126. * Callback used to let the user override the color selection on a per mesh basis
  46127. */
  46128. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  46129. /**
  46130. * Callback used to let the user override the texture selection on a per mesh basis
  46131. */
  46132. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  46133. /**
  46134. * Instantiates a new glow Layer and references it to the scene.
  46135. * @param name The name of the layer
  46136. * @param scene The scene to use the layer in
  46137. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  46138. */
  46139. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  46140. /**
  46141. * Get the effect name of the layer.
  46142. * @return The effect name
  46143. */
  46144. getEffectName(): string;
  46145. /**
  46146. * Create the merge effect. This is the shader use to blit the information back
  46147. * to the main canvas at the end of the scene rendering.
  46148. */
  46149. protected _createMergeEffect(): Effect;
  46150. /**
  46151. * Creates the render target textures and post processes used in the glow layer.
  46152. */
  46153. protected _createTextureAndPostProcesses(): void;
  46154. /**
  46155. * Checks for the readiness of the element composing the layer.
  46156. * @param subMesh the mesh to check for
  46157. * @param useInstances specify wether or not to use instances to render the mesh
  46158. * @param emissiveTexture the associated emissive texture used to generate the glow
  46159. * @return true if ready otherwise, false
  46160. */
  46161. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46162. /**
  46163. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46164. */
  46165. needStencil(): boolean;
  46166. /**
  46167. * Returns true if the mesh can be rendered, otherwise false.
  46168. * @param mesh The mesh to render
  46169. * @param material The material used on the mesh
  46170. * @returns true if it can be rendered otherwise false
  46171. */
  46172. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46173. /**
  46174. * Implementation specific of rendering the generating effect on the main canvas.
  46175. * @param effect The effect used to render through
  46176. */
  46177. protected _internalRender(effect: Effect): void;
  46178. /**
  46179. * Sets the required values for both the emissive texture and and the main color.
  46180. */
  46181. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46182. /**
  46183. * Returns true if the mesh should render, otherwise false.
  46184. * @param mesh The mesh to render
  46185. * @returns true if it should render otherwise false
  46186. */
  46187. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46188. /**
  46189. * Adds specific effects defines.
  46190. * @param defines The defines to add specifics to.
  46191. */
  46192. protected _addCustomEffectDefines(defines: string[]): void;
  46193. /**
  46194. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  46195. * @param mesh The mesh to exclude from the glow layer
  46196. */
  46197. addExcludedMesh(mesh: Mesh): void;
  46198. /**
  46199. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  46200. * @param mesh The mesh to remove
  46201. */
  46202. removeExcludedMesh(mesh: Mesh): void;
  46203. /**
  46204. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  46205. * @param mesh The mesh to include in the glow layer
  46206. */
  46207. addIncludedOnlyMesh(mesh: Mesh): void;
  46208. /**
  46209. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  46210. * @param mesh The mesh to remove
  46211. */
  46212. removeIncludedOnlyMesh(mesh: Mesh): void;
  46213. /**
  46214. * Determine if a given mesh will be used in the glow layer
  46215. * @param mesh The mesh to test
  46216. * @returns true if the mesh will be highlighted by the current glow layer
  46217. */
  46218. hasMesh(mesh: AbstractMesh): boolean;
  46219. /**
  46220. * Free any resources and references associated to a mesh.
  46221. * Internal use
  46222. * @param mesh The mesh to free.
  46223. * @hidden
  46224. */
  46225. _disposeMesh(mesh: Mesh): void;
  46226. /**
  46227. * Gets the class name of the effect layer
  46228. * @returns the string with the class name of the effect layer
  46229. */
  46230. getClassName(): string;
  46231. /**
  46232. * Serializes this glow layer
  46233. * @returns a serialized glow layer object
  46234. */
  46235. serialize(): any;
  46236. /**
  46237. * Creates a Glow Layer from parsed glow layer data
  46238. * @param parsedGlowLayer defines glow layer data
  46239. * @param scene defines the current scene
  46240. * @param rootUrl defines the root URL containing the glow layer information
  46241. * @returns a parsed Glow Layer
  46242. */
  46243. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  46244. }
  46245. }
  46246. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  46247. /** @hidden */
  46248. export var glowBlurPostProcessPixelShader: {
  46249. name: string;
  46250. shader: string;
  46251. };
  46252. }
  46253. declare module "babylonjs/Layers/highlightLayer" {
  46254. import { Observable } from "babylonjs/Misc/observable";
  46255. import { Nullable } from "babylonjs/types";
  46256. import { Camera } from "babylonjs/Cameras/camera";
  46257. import { Scene } from "babylonjs/scene";
  46258. import { Color3, Color4 } from "babylonjs/Maths/math";
  46259. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46260. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46261. import { Mesh } from "babylonjs/Meshes/mesh";
  46262. import { Effect } from "babylonjs/Materials/effect";
  46263. import { Material } from "babylonjs/Materials/material";
  46264. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  46265. import "babylonjs/Shaders/glowMapMerge.fragment";
  46266. import "babylonjs/Shaders/glowMapMerge.vertex";
  46267. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  46268. module "babylonjs/abstractScene" {
  46269. interface AbstractScene {
  46270. /**
  46271. * Return a the first highlight layer of the scene with a given name.
  46272. * @param name The name of the highlight layer to look for.
  46273. * @return The highlight layer if found otherwise null.
  46274. */
  46275. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  46276. }
  46277. }
  46278. /**
  46279. * Highlight layer options. This helps customizing the behaviour
  46280. * of the highlight layer.
  46281. */
  46282. export interface IHighlightLayerOptions {
  46283. /**
  46284. * Multiplication factor apply to the canvas size to compute the render target size
  46285. * used to generated the glowing objects (the smaller the faster).
  46286. */
  46287. mainTextureRatio: number;
  46288. /**
  46289. * Enforces a fixed size texture to ensure resize independant blur.
  46290. */
  46291. mainTextureFixedSize?: number;
  46292. /**
  46293. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  46294. * of the picture to blur (the smaller the faster).
  46295. */
  46296. blurTextureSizeRatio: number;
  46297. /**
  46298. * How big in texel of the blur texture is the vertical blur.
  46299. */
  46300. blurVerticalSize: number;
  46301. /**
  46302. * How big in texel of the blur texture is the horizontal blur.
  46303. */
  46304. blurHorizontalSize: number;
  46305. /**
  46306. * Alpha blending mode used to apply the blur. Default is combine.
  46307. */
  46308. alphaBlendingMode: number;
  46309. /**
  46310. * The camera attached to the layer.
  46311. */
  46312. camera: Nullable<Camera>;
  46313. /**
  46314. * Should we display highlight as a solid stroke?
  46315. */
  46316. isStroke?: boolean;
  46317. /**
  46318. * The rendering group to draw the layer in.
  46319. */
  46320. renderingGroupId: number;
  46321. }
  46322. /**
  46323. * The highlight layer Helps adding a glow effect around a mesh.
  46324. *
  46325. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46326. * glowy meshes to your scene.
  46327. *
  46328. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  46329. */
  46330. export class HighlightLayer extends EffectLayer {
  46331. name: string;
  46332. /**
  46333. * Effect Name of the highlight layer.
  46334. */
  46335. static readonly EffectName: string;
  46336. /**
  46337. * The neutral color used during the preparation of the glow effect.
  46338. * This is black by default as the blend operation is a blend operation.
  46339. */
  46340. static NeutralColor: Color4;
  46341. /**
  46342. * Stencil value used for glowing meshes.
  46343. */
  46344. static GlowingMeshStencilReference: number;
  46345. /**
  46346. * Stencil value used for the other meshes in the scene.
  46347. */
  46348. static NormalMeshStencilReference: number;
  46349. /**
  46350. * Specifies whether or not the inner glow is ACTIVE in the layer.
  46351. */
  46352. innerGlow: boolean;
  46353. /**
  46354. * Specifies whether or not the outer glow is ACTIVE in the layer.
  46355. */
  46356. outerGlow: boolean;
  46357. /**
  46358. * Specifies the horizontal size of the blur.
  46359. */
  46360. /**
  46361. * Gets the horizontal size of the blur.
  46362. */
  46363. blurHorizontalSize: number;
  46364. /**
  46365. * Specifies the vertical size of the blur.
  46366. */
  46367. /**
  46368. * Gets the vertical size of the blur.
  46369. */
  46370. blurVerticalSize: number;
  46371. /**
  46372. * An event triggered when the highlight layer is being blurred.
  46373. */
  46374. onBeforeBlurObservable: Observable<HighlightLayer>;
  46375. /**
  46376. * An event triggered when the highlight layer has been blurred.
  46377. */
  46378. onAfterBlurObservable: Observable<HighlightLayer>;
  46379. private _instanceGlowingMeshStencilReference;
  46380. private _options;
  46381. private _downSamplePostprocess;
  46382. private _horizontalBlurPostprocess;
  46383. private _verticalBlurPostprocess;
  46384. private _blurTexture;
  46385. private _meshes;
  46386. private _excludedMeshes;
  46387. /**
  46388. * Instantiates a new highlight Layer and references it to the scene..
  46389. * @param name The name of the layer
  46390. * @param scene The scene to use the layer in
  46391. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  46392. */
  46393. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  46394. /**
  46395. * Get the effect name of the layer.
  46396. * @return The effect name
  46397. */
  46398. getEffectName(): string;
  46399. /**
  46400. * Create the merge effect. This is the shader use to blit the information back
  46401. * to the main canvas at the end of the scene rendering.
  46402. */
  46403. protected _createMergeEffect(): Effect;
  46404. /**
  46405. * Creates the render target textures and post processes used in the highlight layer.
  46406. */
  46407. protected _createTextureAndPostProcesses(): void;
  46408. /**
  46409. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46410. */
  46411. needStencil(): boolean;
  46412. /**
  46413. * Checks for the readiness of the element composing the layer.
  46414. * @param subMesh the mesh to check for
  46415. * @param useInstances specify wether or not to use instances to render the mesh
  46416. * @param emissiveTexture the associated emissive texture used to generate the glow
  46417. * @return true if ready otherwise, false
  46418. */
  46419. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46420. /**
  46421. * Implementation specific of rendering the generating effect on the main canvas.
  46422. * @param effect The effect used to render through
  46423. */
  46424. protected _internalRender(effect: Effect): void;
  46425. /**
  46426. * Returns true if the layer contains information to display, otherwise false.
  46427. */
  46428. shouldRender(): boolean;
  46429. /**
  46430. * Returns true if the mesh should render, otherwise false.
  46431. * @param mesh The mesh to render
  46432. * @returns true if it should render otherwise false
  46433. */
  46434. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46435. /**
  46436. * Sets the required values for both the emissive texture and and the main color.
  46437. */
  46438. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46439. /**
  46440. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  46441. * @param mesh The mesh to exclude from the highlight layer
  46442. */
  46443. addExcludedMesh(mesh: Mesh): void;
  46444. /**
  46445. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  46446. * @param mesh The mesh to highlight
  46447. */
  46448. removeExcludedMesh(mesh: Mesh): void;
  46449. /**
  46450. * Determine if a given mesh will be highlighted by the current HighlightLayer
  46451. * @param mesh mesh to test
  46452. * @returns true if the mesh will be highlighted by the current HighlightLayer
  46453. */
  46454. hasMesh(mesh: AbstractMesh): boolean;
  46455. /**
  46456. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  46457. * @param mesh The mesh to highlight
  46458. * @param color The color of the highlight
  46459. * @param glowEmissiveOnly Extract the glow from the emissive texture
  46460. */
  46461. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  46462. /**
  46463. * Remove a mesh from the highlight layer in order to make it stop glowing.
  46464. * @param mesh The mesh to highlight
  46465. */
  46466. removeMesh(mesh: Mesh): void;
  46467. /**
  46468. * Force the stencil to the normal expected value for none glowing parts
  46469. */
  46470. private _defaultStencilReference;
  46471. /**
  46472. * Free any resources and references associated to a mesh.
  46473. * Internal use
  46474. * @param mesh The mesh to free.
  46475. * @hidden
  46476. */
  46477. _disposeMesh(mesh: Mesh): void;
  46478. /**
  46479. * Dispose the highlight layer and free resources.
  46480. */
  46481. dispose(): void;
  46482. /**
  46483. * Gets the class name of the effect layer
  46484. * @returns the string with the class name of the effect layer
  46485. */
  46486. getClassName(): string;
  46487. /**
  46488. * Serializes this Highlight layer
  46489. * @returns a serialized Highlight layer object
  46490. */
  46491. serialize(): any;
  46492. /**
  46493. * Creates a Highlight layer from parsed Highlight layer data
  46494. * @param parsedHightlightLayer defines the Highlight layer data
  46495. * @param scene defines the current scene
  46496. * @param rootUrl defines the root URL containing the Highlight layer information
  46497. * @returns a parsed Highlight layer
  46498. */
  46499. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  46500. }
  46501. }
  46502. declare module "babylonjs/Layers/index" {
  46503. export * from "babylonjs/Layers/effectLayer";
  46504. export * from "babylonjs/Layers/effectLayerSceneComponent";
  46505. export * from "babylonjs/Layers/glowLayer";
  46506. export * from "babylonjs/Layers/highlightLayer";
  46507. export * from "babylonjs/Layers/layer";
  46508. export * from "babylonjs/Layers/layerSceneComponent";
  46509. }
  46510. declare module "babylonjs/Shaders/lensFlare.fragment" {
  46511. /** @hidden */
  46512. export var lensFlarePixelShader: {
  46513. name: string;
  46514. shader: string;
  46515. };
  46516. }
  46517. declare module "babylonjs/Shaders/lensFlare.vertex" {
  46518. /** @hidden */
  46519. export var lensFlareVertexShader: {
  46520. name: string;
  46521. shader: string;
  46522. };
  46523. }
  46524. declare module "babylonjs/LensFlares/lensFlareSystem" {
  46525. import { Scene } from "babylonjs/scene";
  46526. import { Vector3, Viewport } from "babylonjs/Maths/math";
  46527. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46528. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  46529. import "babylonjs/Shaders/lensFlare.fragment";
  46530. import "babylonjs/Shaders/lensFlare.vertex";
  46531. /**
  46532. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46533. * It is usually composed of several `lensFlare`.
  46534. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46535. */
  46536. export class LensFlareSystem {
  46537. /**
  46538. * Define the name of the lens flare system
  46539. */
  46540. name: string;
  46541. /**
  46542. * List of lens flares used in this system.
  46543. */
  46544. lensFlares: LensFlare[];
  46545. /**
  46546. * Define a limit from the border the lens flare can be visible.
  46547. */
  46548. borderLimit: number;
  46549. /**
  46550. * Define a viewport border we do not want to see the lens flare in.
  46551. */
  46552. viewportBorder: number;
  46553. /**
  46554. * Define a predicate which could limit the list of meshes able to occlude the effect.
  46555. */
  46556. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46557. /**
  46558. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  46559. */
  46560. layerMask: number;
  46561. /**
  46562. * Define the id of the lens flare system in the scene.
  46563. * (equal to name by default)
  46564. */
  46565. id: string;
  46566. private _scene;
  46567. private _emitter;
  46568. private _vertexBuffers;
  46569. private _indexBuffer;
  46570. private _effect;
  46571. private _positionX;
  46572. private _positionY;
  46573. private _isEnabled;
  46574. /** @hidden */
  46575. static _SceneComponentInitialization: (scene: Scene) => void;
  46576. /**
  46577. * Instantiates a lens flare system.
  46578. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46579. * It is usually composed of several `lensFlare`.
  46580. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46581. * @param name Define the name of the lens flare system in the scene
  46582. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  46583. * @param scene Define the scene the lens flare system belongs to
  46584. */
  46585. constructor(
  46586. /**
  46587. * Define the name of the lens flare system
  46588. */
  46589. name: string, emitter: any, scene: Scene);
  46590. /**
  46591. * Define if the lens flare system is enabled.
  46592. */
  46593. isEnabled: boolean;
  46594. /**
  46595. * Get the scene the effects belongs to.
  46596. * @returns the scene holding the lens flare system
  46597. */
  46598. getScene(): Scene;
  46599. /**
  46600. * Get the emitter of the lens flare system.
  46601. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46602. * @returns the emitter of the lens flare system
  46603. */
  46604. getEmitter(): any;
  46605. /**
  46606. * Set the emitter of the lens flare system.
  46607. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46608. * @param newEmitter Define the new emitter of the system
  46609. */
  46610. setEmitter(newEmitter: any): void;
  46611. /**
  46612. * Get the lens flare system emitter position.
  46613. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  46614. * @returns the position
  46615. */
  46616. getEmitterPosition(): Vector3;
  46617. /**
  46618. * @hidden
  46619. */
  46620. computeEffectivePosition(globalViewport: Viewport): boolean;
  46621. /** @hidden */
  46622. _isVisible(): boolean;
  46623. /**
  46624. * @hidden
  46625. */
  46626. render(): boolean;
  46627. /**
  46628. * Dispose and release the lens flare with its associated resources.
  46629. */
  46630. dispose(): void;
  46631. /**
  46632. * Parse a lens flare system from a JSON repressentation
  46633. * @param parsedLensFlareSystem Define the JSON to parse
  46634. * @param scene Define the scene the parsed system should be instantiated in
  46635. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  46636. * @returns the parsed system
  46637. */
  46638. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  46639. /**
  46640. * Serialize the current Lens Flare System into a JSON representation.
  46641. * @returns the serialized JSON
  46642. */
  46643. serialize(): any;
  46644. }
  46645. }
  46646. declare module "babylonjs/LensFlares/lensFlare" {
  46647. import { Nullable } from "babylonjs/types";
  46648. import { Color3 } from "babylonjs/Maths/math";
  46649. import { Texture } from "babylonjs/Materials/Textures/texture";
  46650. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  46651. /**
  46652. * This represents one of the lens effect in a `lensFlareSystem`.
  46653. * It controls one of the indiviual texture used in the effect.
  46654. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46655. */
  46656. export class LensFlare {
  46657. /**
  46658. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  46659. */
  46660. size: number;
  46661. /**
  46662. * 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.
  46663. */
  46664. position: number;
  46665. /**
  46666. * Define the lens color.
  46667. */
  46668. color: Color3;
  46669. /**
  46670. * Define the lens texture.
  46671. */
  46672. texture: Nullable<Texture>;
  46673. /**
  46674. * Define the alpha mode to render this particular lens.
  46675. */
  46676. alphaMode: number;
  46677. private _system;
  46678. /**
  46679. * Creates a new Lens Flare.
  46680. * This represents one of the lens effect in a `lensFlareSystem`.
  46681. * It controls one of the indiviual texture used in the effect.
  46682. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46683. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  46684. * @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.
  46685. * @param color Define the lens color
  46686. * @param imgUrl Define the lens texture url
  46687. * @param system Define the `lensFlareSystem` this flare is part of
  46688. * @returns The newly created Lens Flare
  46689. */
  46690. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  46691. /**
  46692. * Instantiates a new Lens Flare.
  46693. * This represents one of the lens effect in a `lensFlareSystem`.
  46694. * It controls one of the indiviual texture used in the effect.
  46695. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46696. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  46697. * @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.
  46698. * @param color Define the lens color
  46699. * @param imgUrl Define the lens texture url
  46700. * @param system Define the `lensFlareSystem` this flare is part of
  46701. */
  46702. constructor(
  46703. /**
  46704. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  46705. */
  46706. size: number,
  46707. /**
  46708. * 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.
  46709. */
  46710. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  46711. /**
  46712. * Dispose and release the lens flare with its associated resources.
  46713. */
  46714. dispose(): void;
  46715. }
  46716. }
  46717. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  46718. import { Nullable } from "babylonjs/types";
  46719. import { Scene } from "babylonjs/scene";
  46720. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  46721. import { AbstractScene } from "babylonjs/abstractScene";
  46722. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  46723. module "babylonjs/abstractScene" {
  46724. interface AbstractScene {
  46725. /**
  46726. * The list of lens flare system added to the scene
  46727. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46728. */
  46729. lensFlareSystems: Array<LensFlareSystem>;
  46730. /**
  46731. * Removes the given lens flare system from this scene.
  46732. * @param toRemove The lens flare system to remove
  46733. * @returns The index of the removed lens flare system
  46734. */
  46735. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  46736. /**
  46737. * Adds the given lens flare system to this scene
  46738. * @param newLensFlareSystem The lens flare system to add
  46739. */
  46740. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  46741. /**
  46742. * Gets a lens flare system using its name
  46743. * @param name defines the name to look for
  46744. * @returns the lens flare system or null if not found
  46745. */
  46746. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  46747. /**
  46748. * Gets a lens flare system using its id
  46749. * @param id defines the id to look for
  46750. * @returns the lens flare system or null if not found
  46751. */
  46752. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  46753. }
  46754. }
  46755. /**
  46756. * Defines the lens flare scene component responsible to manage any lens flares
  46757. * in a given scene.
  46758. */
  46759. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  46760. /**
  46761. * The component name helpfull to identify the component in the list of scene components.
  46762. */
  46763. readonly name: string;
  46764. /**
  46765. * The scene the component belongs to.
  46766. */
  46767. scene: Scene;
  46768. /**
  46769. * Creates a new instance of the component for the given scene
  46770. * @param scene Defines the scene to register the component in
  46771. */
  46772. constructor(scene: Scene);
  46773. /**
  46774. * Registers the component in a given scene
  46775. */
  46776. register(): void;
  46777. /**
  46778. * Rebuilds the elements related to this component in case of
  46779. * context lost for instance.
  46780. */
  46781. rebuild(): void;
  46782. /**
  46783. * Adds all the element from the container to the scene
  46784. * @param container the container holding the elements
  46785. */
  46786. addFromContainer(container: AbstractScene): void;
  46787. /**
  46788. * Removes all the elements in the container from the scene
  46789. * @param container contains the elements to remove
  46790. */
  46791. removeFromContainer(container: AbstractScene): void;
  46792. /**
  46793. * Serializes the component data to the specified json object
  46794. * @param serializationObject The object to serialize to
  46795. */
  46796. serialize(serializationObject: any): void;
  46797. /**
  46798. * Disposes the component and the associated ressources.
  46799. */
  46800. dispose(): void;
  46801. private _draw;
  46802. }
  46803. }
  46804. declare module "babylonjs/LensFlares/index" {
  46805. export * from "babylonjs/LensFlares/lensFlare";
  46806. export * from "babylonjs/LensFlares/lensFlareSystem";
  46807. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  46808. }
  46809. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  46810. import { Scene } from "babylonjs/scene";
  46811. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  46812. import { AbstractScene } from "babylonjs/abstractScene";
  46813. /**
  46814. * Defines the shadow generator component responsible to manage any shadow generators
  46815. * in a given scene.
  46816. */
  46817. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  46818. /**
  46819. * The component name helpfull to identify the component in the list of scene components.
  46820. */
  46821. readonly name: string;
  46822. /**
  46823. * The scene the component belongs to.
  46824. */
  46825. scene: Scene;
  46826. /**
  46827. * Creates a new instance of the component for the given scene
  46828. * @param scene Defines the scene to register the component in
  46829. */
  46830. constructor(scene: Scene);
  46831. /**
  46832. * Registers the component in a given scene
  46833. */
  46834. register(): void;
  46835. /**
  46836. * Rebuilds the elements related to this component in case of
  46837. * context lost for instance.
  46838. */
  46839. rebuild(): void;
  46840. /**
  46841. * Serializes the component data to the specified json object
  46842. * @param serializationObject The object to serialize to
  46843. */
  46844. serialize(serializationObject: any): void;
  46845. /**
  46846. * Adds all the element from the container to the scene
  46847. * @param container the container holding the elements
  46848. */
  46849. addFromContainer(container: AbstractScene): void;
  46850. /**
  46851. * Removes all the elements in the container from the scene
  46852. * @param container contains the elements to remove
  46853. */
  46854. removeFromContainer(container: AbstractScene): void;
  46855. /**
  46856. * Rebuilds the elements related to this component in case of
  46857. * context lost for instance.
  46858. */
  46859. dispose(): void;
  46860. private _gatherRenderTargets;
  46861. }
  46862. }
  46863. declare module "babylonjs/Lights/Shadows/index" {
  46864. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  46865. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  46866. }
  46867. declare module "babylonjs/Lights/directionalLight" {
  46868. import { Camera } from "babylonjs/Cameras/camera";
  46869. import { Scene } from "babylonjs/scene";
  46870. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  46871. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46872. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46873. import { Effect } from "babylonjs/Materials/effect";
  46874. /**
  46875. * A directional light is defined by a direction (what a surprise!).
  46876. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  46877. * 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.
  46878. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46879. */
  46880. export class DirectionalLight extends ShadowLight {
  46881. private _shadowFrustumSize;
  46882. /**
  46883. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  46884. */
  46885. /**
  46886. * Specifies a fix frustum size for the shadow generation.
  46887. */
  46888. shadowFrustumSize: number;
  46889. private _shadowOrthoScale;
  46890. /**
  46891. * Gets the shadow projection scale against the optimal computed one.
  46892. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46893. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46894. */
  46895. /**
  46896. * Sets the shadow projection scale against the optimal computed one.
  46897. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46898. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46899. */
  46900. shadowOrthoScale: number;
  46901. /**
  46902. * Automatically compute the projection matrix to best fit (including all the casters)
  46903. * on each frame.
  46904. */
  46905. autoUpdateExtends: boolean;
  46906. private _orthoLeft;
  46907. private _orthoRight;
  46908. private _orthoTop;
  46909. private _orthoBottom;
  46910. /**
  46911. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  46912. * The directional light is emitted from everywhere in the given direction.
  46913. * It can cast shadows.
  46914. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46915. * @param name The friendly name of the light
  46916. * @param direction The direction of the light
  46917. * @param scene The scene the light belongs to
  46918. */
  46919. constructor(name: string, direction: Vector3, scene: Scene);
  46920. /**
  46921. * Returns the string "DirectionalLight".
  46922. * @return The class name
  46923. */
  46924. getClassName(): string;
  46925. /**
  46926. * Returns the integer 1.
  46927. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46928. */
  46929. getTypeID(): number;
  46930. /**
  46931. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  46932. * Returns the DirectionalLight Shadow projection matrix.
  46933. */
  46934. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46935. /**
  46936. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  46937. * Returns the DirectionalLight Shadow projection matrix.
  46938. */
  46939. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  46940. /**
  46941. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  46942. * Returns the DirectionalLight Shadow projection matrix.
  46943. */
  46944. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46945. protected _buildUniformLayout(): void;
  46946. /**
  46947. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  46948. * @param effect The effect to update
  46949. * @param lightIndex The index of the light in the effect to update
  46950. * @returns The directional light
  46951. */
  46952. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  46953. /**
  46954. * Gets the minZ used for shadow according to both the scene and the light.
  46955. *
  46956. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46957. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46958. * @param activeCamera The camera we are returning the min for
  46959. * @returns the depth min z
  46960. */
  46961. getDepthMinZ(activeCamera: Camera): number;
  46962. /**
  46963. * Gets the maxZ used for shadow according to both the scene and the light.
  46964. *
  46965. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46966. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46967. * @param activeCamera The camera we are returning the max for
  46968. * @returns the depth max z
  46969. */
  46970. getDepthMaxZ(activeCamera: Camera): number;
  46971. /**
  46972. * Prepares the list of defines specific to the light type.
  46973. * @param defines the list of defines
  46974. * @param lightIndex defines the index of the light for the effect
  46975. */
  46976. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46977. }
  46978. }
  46979. declare module "babylonjs/Lights/pointLight" {
  46980. import { Scene } from "babylonjs/scene";
  46981. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  46982. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46983. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46984. import { Effect } from "babylonjs/Materials/effect";
  46985. /**
  46986. * A point light is a light defined by an unique point in world space.
  46987. * The light is emitted in every direction from this point.
  46988. * A good example of a point light is a standard light bulb.
  46989. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46990. */
  46991. export class PointLight extends ShadowLight {
  46992. private _shadowAngle;
  46993. /**
  46994. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46995. * This specifies what angle the shadow will use to be created.
  46996. *
  46997. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  46998. */
  46999. /**
  47000. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47001. * This specifies what angle the shadow will use to be created.
  47002. *
  47003. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47004. */
  47005. shadowAngle: number;
  47006. /**
  47007. * Gets the direction if it has been set.
  47008. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47009. */
  47010. /**
  47011. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47012. */
  47013. direction: Vector3;
  47014. /**
  47015. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  47016. * A PointLight emits the light in every direction.
  47017. * It can cast shadows.
  47018. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  47019. * ```javascript
  47020. * var pointLight = new PointLight("pl", camera.position, scene);
  47021. * ```
  47022. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47023. * @param name The light friendly name
  47024. * @param position The position of the point light in the scene
  47025. * @param scene The scene the lights belongs to
  47026. */
  47027. constructor(name: string, position: Vector3, scene: Scene);
  47028. /**
  47029. * Returns the string "PointLight"
  47030. * @returns the class name
  47031. */
  47032. getClassName(): string;
  47033. /**
  47034. * Returns the integer 0.
  47035. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47036. */
  47037. getTypeID(): number;
  47038. /**
  47039. * Specifies wether or not the shadowmap should be a cube texture.
  47040. * @returns true if the shadowmap needs to be a cube texture.
  47041. */
  47042. needCube(): boolean;
  47043. /**
  47044. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  47045. * @param faceIndex The index of the face we are computed the direction to generate shadow
  47046. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  47047. */
  47048. getShadowDirection(faceIndex?: number): Vector3;
  47049. /**
  47050. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  47051. * - fov = PI / 2
  47052. * - aspect ratio : 1.0
  47053. * - z-near and far equal to the active camera minZ and maxZ.
  47054. * Returns the PointLight.
  47055. */
  47056. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47057. protected _buildUniformLayout(): void;
  47058. /**
  47059. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  47060. * @param effect The effect to update
  47061. * @param lightIndex The index of the light in the effect to update
  47062. * @returns The point light
  47063. */
  47064. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  47065. /**
  47066. * Prepares the list of defines specific to the light type.
  47067. * @param defines the list of defines
  47068. * @param lightIndex defines the index of the light for the effect
  47069. */
  47070. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47071. }
  47072. }
  47073. declare module "babylonjs/Lights/spotLight" {
  47074. import { Nullable } from "babylonjs/types";
  47075. import { Scene } from "babylonjs/scene";
  47076. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  47077. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47078. import { Effect } from "babylonjs/Materials/effect";
  47079. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47080. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47081. /**
  47082. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47083. * These values define a cone of light starting from the position, emitting toward the direction.
  47084. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47085. * and the exponent defines the speed of the decay of the light with distance (reach).
  47086. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47087. */
  47088. export class SpotLight extends ShadowLight {
  47089. private _angle;
  47090. private _innerAngle;
  47091. private _cosHalfAngle;
  47092. private _lightAngleScale;
  47093. private _lightAngleOffset;
  47094. /**
  47095. * Gets the cone angle of the spot light in Radians.
  47096. */
  47097. /**
  47098. * Sets the cone angle of the spot light in Radians.
  47099. */
  47100. angle: number;
  47101. /**
  47102. * Only used in gltf falloff mode, this defines the angle where
  47103. * the directional falloff will start before cutting at angle which could be seen
  47104. * as outer angle.
  47105. */
  47106. /**
  47107. * Only used in gltf falloff mode, this defines the angle where
  47108. * the directional falloff will start before cutting at angle which could be seen
  47109. * as outer angle.
  47110. */
  47111. innerAngle: number;
  47112. private _shadowAngleScale;
  47113. /**
  47114. * Allows scaling the angle of the light for shadow generation only.
  47115. */
  47116. /**
  47117. * Allows scaling the angle of the light for shadow generation only.
  47118. */
  47119. shadowAngleScale: number;
  47120. /**
  47121. * The light decay speed with the distance from the emission spot.
  47122. */
  47123. exponent: number;
  47124. private _projectionTextureMatrix;
  47125. /**
  47126. * Allows reading the projecton texture
  47127. */
  47128. readonly projectionTextureMatrix: Matrix;
  47129. protected _projectionTextureLightNear: number;
  47130. /**
  47131. * Gets the near clip of the Spotlight for texture projection.
  47132. */
  47133. /**
  47134. * Sets the near clip of the Spotlight for texture projection.
  47135. */
  47136. projectionTextureLightNear: number;
  47137. protected _projectionTextureLightFar: number;
  47138. /**
  47139. * Gets the far clip of the Spotlight for texture projection.
  47140. */
  47141. /**
  47142. * Sets the far clip of the Spotlight for texture projection.
  47143. */
  47144. projectionTextureLightFar: number;
  47145. protected _projectionTextureUpDirection: Vector3;
  47146. /**
  47147. * Gets the Up vector of the Spotlight for texture projection.
  47148. */
  47149. /**
  47150. * Sets the Up vector of the Spotlight for texture projection.
  47151. */
  47152. projectionTextureUpDirection: Vector3;
  47153. private _projectionTexture;
  47154. /**
  47155. * Gets the projection texture of the light.
  47156. */
  47157. /**
  47158. * Sets the projection texture of the light.
  47159. */
  47160. projectionTexture: Nullable<BaseTexture>;
  47161. private _projectionTextureViewLightDirty;
  47162. private _projectionTextureProjectionLightDirty;
  47163. private _projectionTextureDirty;
  47164. private _projectionTextureViewTargetVector;
  47165. private _projectionTextureViewLightMatrix;
  47166. private _projectionTextureProjectionLightMatrix;
  47167. private _projectionTextureScalingMatrix;
  47168. /**
  47169. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  47170. * It can cast shadows.
  47171. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47172. * @param name The light friendly name
  47173. * @param position The position of the spot light in the scene
  47174. * @param direction The direction of the light in the scene
  47175. * @param angle The cone angle of the light in Radians
  47176. * @param exponent The light decay speed with the distance from the emission spot
  47177. * @param scene The scene the lights belongs to
  47178. */
  47179. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  47180. /**
  47181. * Returns the string "SpotLight".
  47182. * @returns the class name
  47183. */
  47184. getClassName(): string;
  47185. /**
  47186. * Returns the integer 2.
  47187. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47188. */
  47189. getTypeID(): number;
  47190. /**
  47191. * Overrides the direction setter to recompute the projection texture view light Matrix.
  47192. */
  47193. protected _setDirection(value: Vector3): void;
  47194. /**
  47195. * Overrides the position setter to recompute the projection texture view light Matrix.
  47196. */
  47197. protected _setPosition(value: Vector3): void;
  47198. /**
  47199. * 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.
  47200. * Returns the SpotLight.
  47201. */
  47202. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47203. protected _computeProjectionTextureViewLightMatrix(): void;
  47204. protected _computeProjectionTextureProjectionLightMatrix(): void;
  47205. /**
  47206. * Main function for light texture projection matrix computing.
  47207. */
  47208. protected _computeProjectionTextureMatrix(): void;
  47209. protected _buildUniformLayout(): void;
  47210. private _computeAngleValues;
  47211. /**
  47212. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  47213. * @param effect The effect to update
  47214. * @param lightIndex The index of the light in the effect to update
  47215. * @returns The spot light
  47216. */
  47217. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  47218. /**
  47219. * Disposes the light and the associated resources.
  47220. */
  47221. dispose(): void;
  47222. /**
  47223. * Prepares the list of defines specific to the light type.
  47224. * @param defines the list of defines
  47225. * @param lightIndex defines the index of the light for the effect
  47226. */
  47227. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47228. }
  47229. }
  47230. declare module "babylonjs/Lights/index" {
  47231. export * from "babylonjs/Lights/light";
  47232. export * from "babylonjs/Lights/shadowLight";
  47233. export * from "babylonjs/Lights/Shadows/index";
  47234. export * from "babylonjs/Lights/directionalLight";
  47235. export * from "babylonjs/Lights/hemisphericLight";
  47236. export * from "babylonjs/Lights/pointLight";
  47237. export * from "babylonjs/Lights/spotLight";
  47238. }
  47239. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  47240. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  47241. /**
  47242. * Header information of HDR texture files.
  47243. */
  47244. export interface HDRInfo {
  47245. /**
  47246. * The height of the texture in pixels.
  47247. */
  47248. height: number;
  47249. /**
  47250. * The width of the texture in pixels.
  47251. */
  47252. width: number;
  47253. /**
  47254. * The index of the beginning of the data in the binary file.
  47255. */
  47256. dataPosition: number;
  47257. }
  47258. /**
  47259. * This groups tools to convert HDR texture to native colors array.
  47260. */
  47261. export class HDRTools {
  47262. private static Ldexp;
  47263. private static Rgbe2float;
  47264. private static readStringLine;
  47265. /**
  47266. * Reads header information from an RGBE texture stored in a native array.
  47267. * More information on this format are available here:
  47268. * https://en.wikipedia.org/wiki/RGBE_image_format
  47269. *
  47270. * @param uint8array The binary file stored in native array.
  47271. * @return The header information.
  47272. */
  47273. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  47274. /**
  47275. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  47276. * This RGBE texture needs to store the information as a panorama.
  47277. *
  47278. * More information on this format are available here:
  47279. * https://en.wikipedia.org/wiki/RGBE_image_format
  47280. *
  47281. * @param buffer The binary file stored in an array buffer.
  47282. * @param size The expected size of the extracted cubemap.
  47283. * @return The Cube Map information.
  47284. */
  47285. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  47286. /**
  47287. * Returns the pixels data extracted from an RGBE texture.
  47288. * This pixels will be stored left to right up to down in the R G B order in one array.
  47289. *
  47290. * More information on this format are available here:
  47291. * https://en.wikipedia.org/wiki/RGBE_image_format
  47292. *
  47293. * @param uint8array The binary file stored in an array buffer.
  47294. * @param hdrInfo The header information of the file.
  47295. * @return The pixels data in RGB right to left up to down order.
  47296. */
  47297. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  47298. private static RGBE_ReadPixels_RLE;
  47299. }
  47300. }
  47301. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  47302. import { Nullable } from "babylonjs/types";
  47303. import { Scene } from "babylonjs/scene";
  47304. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  47305. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47306. /**
  47307. * This represents a texture coming from an HDR input.
  47308. *
  47309. * The only supported format is currently panorama picture stored in RGBE format.
  47310. * Example of such files can be found on HDRLib: http://hdrlib.com/
  47311. */
  47312. export class HDRCubeTexture extends BaseTexture {
  47313. private static _facesMapping;
  47314. private _generateHarmonics;
  47315. private _noMipmap;
  47316. private _textureMatrix;
  47317. private _size;
  47318. private _onLoad;
  47319. private _onError;
  47320. /**
  47321. * The texture URL.
  47322. */
  47323. url: string;
  47324. /**
  47325. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  47326. */
  47327. coordinatesMode: number;
  47328. protected _isBlocking: boolean;
  47329. /**
  47330. * Sets wether or not the texture is blocking during loading.
  47331. */
  47332. /**
  47333. * Gets wether or not the texture is blocking during loading.
  47334. */
  47335. isBlocking: boolean;
  47336. protected _rotationY: number;
  47337. /**
  47338. * Sets texture matrix rotation angle around Y axis in radians.
  47339. */
  47340. /**
  47341. * Gets texture matrix rotation angle around Y axis radians.
  47342. */
  47343. rotationY: number;
  47344. /**
  47345. * Gets or sets the center of the bounding box associated with the cube texture
  47346. * It must define where the camera used to render the texture was set
  47347. */
  47348. boundingBoxPosition: Vector3;
  47349. private _boundingBoxSize;
  47350. /**
  47351. * Gets or sets the size of the bounding box associated with the cube texture
  47352. * When defined, the cubemap will switch to local mode
  47353. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  47354. * @example https://www.babylonjs-playground.com/#RNASML
  47355. */
  47356. boundingBoxSize: Vector3;
  47357. /**
  47358. * Instantiates an HDRTexture from the following parameters.
  47359. *
  47360. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  47361. * @param scene The scene the texture will be used in
  47362. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  47363. * @param noMipmap Forces to not generate the mipmap if true
  47364. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  47365. * @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)
  47366. * @param reserved Reserved flag for internal use.
  47367. */
  47368. 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>);
  47369. /**
  47370. * Get the current class name of the texture useful for serialization or dynamic coding.
  47371. * @returns "HDRCubeTexture"
  47372. */
  47373. getClassName(): string;
  47374. /**
  47375. * Occurs when the file is raw .hdr file.
  47376. */
  47377. private loadTexture;
  47378. clone(): HDRCubeTexture;
  47379. delayLoad(): void;
  47380. /**
  47381. * Get the texture reflection matrix used to rotate/transform the reflection.
  47382. * @returns the reflection matrix
  47383. */
  47384. getReflectionTextureMatrix(): Matrix;
  47385. /**
  47386. * Set the texture reflection matrix used to rotate/transform the reflection.
  47387. * @param value Define the reflection matrix to set
  47388. */
  47389. setReflectionTextureMatrix(value: Matrix): void;
  47390. /**
  47391. * Parses a JSON representation of an HDR Texture in order to create the texture
  47392. * @param parsedTexture Define the JSON representation
  47393. * @param scene Define the scene the texture should be created in
  47394. * @param rootUrl Define the root url in case we need to load relative dependencies
  47395. * @returns the newly created texture after parsing
  47396. */
  47397. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  47398. serialize(): any;
  47399. }
  47400. }
  47401. declare module "babylonjs/Physics/physicsEngine" {
  47402. import { Nullable } from "babylonjs/types";
  47403. import { Vector3 } from "babylonjs/Maths/math";
  47404. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  47405. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  47406. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  47407. /**
  47408. * Class used to control physics engine
  47409. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  47410. */
  47411. export class PhysicsEngine implements IPhysicsEngine {
  47412. private _physicsPlugin;
  47413. /**
  47414. * Global value used to control the smallest number supported by the simulation
  47415. */
  47416. static Epsilon: number;
  47417. private _impostors;
  47418. private _joints;
  47419. /**
  47420. * Gets the gravity vector used by the simulation
  47421. */
  47422. gravity: Vector3;
  47423. /**
  47424. * Factory used to create the default physics plugin.
  47425. * @returns The default physics plugin
  47426. */
  47427. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  47428. /**
  47429. * Creates a new Physics Engine
  47430. * @param gravity defines the gravity vector used by the simulation
  47431. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  47432. */
  47433. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  47434. /**
  47435. * Sets the gravity vector used by the simulation
  47436. * @param gravity defines the gravity vector to use
  47437. */
  47438. setGravity(gravity: Vector3): void;
  47439. /**
  47440. * Set the time step of the physics engine.
  47441. * Default is 1/60.
  47442. * To slow it down, enter 1/600 for example.
  47443. * To speed it up, 1/30
  47444. * @param newTimeStep defines the new timestep to apply to this world.
  47445. */
  47446. setTimeStep(newTimeStep?: number): void;
  47447. /**
  47448. * Get the time step of the physics engine.
  47449. * @returns the current time step
  47450. */
  47451. getTimeStep(): number;
  47452. /**
  47453. * Release all resources
  47454. */
  47455. dispose(): void;
  47456. /**
  47457. * Gets the name of the current physics plugin
  47458. * @returns the name of the plugin
  47459. */
  47460. getPhysicsPluginName(): string;
  47461. /**
  47462. * Adding a new impostor for the impostor tracking.
  47463. * This will be done by the impostor itself.
  47464. * @param impostor the impostor to add
  47465. */
  47466. addImpostor(impostor: PhysicsImpostor): void;
  47467. /**
  47468. * Remove an impostor from the engine.
  47469. * This impostor and its mesh will not longer be updated by the physics engine.
  47470. * @param impostor the impostor to remove
  47471. */
  47472. removeImpostor(impostor: PhysicsImpostor): void;
  47473. /**
  47474. * Add a joint to the physics engine
  47475. * @param mainImpostor defines the main impostor to which the joint is added.
  47476. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  47477. * @param joint defines the joint that will connect both impostors.
  47478. */
  47479. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47480. /**
  47481. * Removes a joint from the simulation
  47482. * @param mainImpostor defines the impostor used with the joint
  47483. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  47484. * @param joint defines the joint to remove
  47485. */
  47486. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47487. /**
  47488. * Called by the scene. No need to call it.
  47489. * @param delta defines the timespam between frames
  47490. */
  47491. _step(delta: number): void;
  47492. /**
  47493. * Gets the current plugin used to run the simulation
  47494. * @returns current plugin
  47495. */
  47496. getPhysicsPlugin(): IPhysicsEnginePlugin;
  47497. /**
  47498. * Gets the list of physic impostors
  47499. * @returns an array of PhysicsImpostor
  47500. */
  47501. getImpostors(): Array<PhysicsImpostor>;
  47502. /**
  47503. * Gets the impostor for a physics enabled object
  47504. * @param object defines the object impersonated by the impostor
  47505. * @returns the PhysicsImpostor or null if not found
  47506. */
  47507. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  47508. /**
  47509. * Gets the impostor for a physics body object
  47510. * @param body defines physics body used by the impostor
  47511. * @returns the PhysicsImpostor or null if not found
  47512. */
  47513. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  47514. }
  47515. }
  47516. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  47517. import { Nullable } from "babylonjs/types";
  47518. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  47519. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47520. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  47521. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  47522. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  47523. /** @hidden */
  47524. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  47525. private _useDeltaForWorldStep;
  47526. world: any;
  47527. name: string;
  47528. private _physicsMaterials;
  47529. private _fixedTimeStep;
  47530. BJSCANNON: any;
  47531. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  47532. setGravity(gravity: Vector3): void;
  47533. setTimeStep(timeStep: number): void;
  47534. getTimeStep(): number;
  47535. executeStep(delta: number): void;
  47536. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47537. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47538. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47539. private _processChildMeshes;
  47540. removePhysicsBody(impostor: PhysicsImpostor): void;
  47541. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47542. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47543. private _addMaterial;
  47544. private _checkWithEpsilon;
  47545. private _createShape;
  47546. private _createHeightmap;
  47547. private _minus90X;
  47548. private _plus90X;
  47549. private _tmpPosition;
  47550. private _tmpDeltaPosition;
  47551. private _tmpUnityRotation;
  47552. private _updatePhysicsBodyTransformation;
  47553. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47554. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47555. isSupported(): boolean;
  47556. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47557. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47558. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47559. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47560. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47561. getBodyMass(impostor: PhysicsImpostor): number;
  47562. getBodyFriction(impostor: PhysicsImpostor): number;
  47563. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47564. getBodyRestitution(impostor: PhysicsImpostor): number;
  47565. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47566. sleepBody(impostor: PhysicsImpostor): void;
  47567. wakeUpBody(impostor: PhysicsImpostor): void;
  47568. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  47569. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  47570. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  47571. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47572. getRadius(impostor: PhysicsImpostor): number;
  47573. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47574. dispose(): void;
  47575. private _extendNamespace;
  47576. }
  47577. }
  47578. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  47579. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  47580. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  47581. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  47582. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47583. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  47584. import { Nullable } from "babylonjs/types";
  47585. /** @hidden */
  47586. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  47587. world: any;
  47588. name: string;
  47589. BJSOIMO: any;
  47590. constructor(iterations?: number, oimoInjection?: any);
  47591. setGravity(gravity: Vector3): void;
  47592. setTimeStep(timeStep: number): void;
  47593. getTimeStep(): number;
  47594. private _tmpImpostorsArray;
  47595. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47596. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47597. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47598. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47599. private _tmpPositionVector;
  47600. removePhysicsBody(impostor: PhysicsImpostor): void;
  47601. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47602. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47603. isSupported(): boolean;
  47604. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47605. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47606. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47607. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47608. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47609. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47610. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47611. getBodyMass(impostor: PhysicsImpostor): number;
  47612. getBodyFriction(impostor: PhysicsImpostor): number;
  47613. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47614. getBodyRestitution(impostor: PhysicsImpostor): number;
  47615. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47616. sleepBody(impostor: PhysicsImpostor): void;
  47617. wakeUpBody(impostor: PhysicsImpostor): void;
  47618. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  47619. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  47620. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  47621. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47622. getRadius(impostor: PhysicsImpostor): number;
  47623. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47624. dispose(): void;
  47625. }
  47626. }
  47627. declare module "babylonjs/Probes/reflectionProbe" {
  47628. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47629. import { Vector3 } from "babylonjs/Maths/math";
  47630. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47631. import { Nullable } from "babylonjs/types";
  47632. import { Scene } from "babylonjs/scene";
  47633. module "babylonjs/abstractScene" {
  47634. interface AbstractScene {
  47635. /**
  47636. * The list of reflection probes added to the scene
  47637. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  47638. */
  47639. reflectionProbes: Array<ReflectionProbe>;
  47640. /**
  47641. * Removes the given reflection probe from this scene.
  47642. * @param toRemove The reflection probe to remove
  47643. * @returns The index of the removed reflection probe
  47644. */
  47645. removeReflectionProbe(toRemove: ReflectionProbe): number;
  47646. /**
  47647. * Adds the given reflection probe to this scene.
  47648. * @param newReflectionProbe The reflection probe to add
  47649. */
  47650. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  47651. }
  47652. }
  47653. /**
  47654. * Class used to generate realtime reflection / refraction cube textures
  47655. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  47656. */
  47657. export class ReflectionProbe {
  47658. /** defines the name of the probe */
  47659. name: string;
  47660. private _scene;
  47661. private _renderTargetTexture;
  47662. private _projectionMatrix;
  47663. private _viewMatrix;
  47664. private _target;
  47665. private _add;
  47666. private _attachedMesh;
  47667. private _invertYAxis;
  47668. /** Gets or sets probe position (center of the cube map) */
  47669. position: Vector3;
  47670. /**
  47671. * Creates a new reflection probe
  47672. * @param name defines the name of the probe
  47673. * @param size defines the texture resolution (for each face)
  47674. * @param scene defines the hosting scene
  47675. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  47676. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  47677. */
  47678. constructor(
  47679. /** defines the name of the probe */
  47680. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  47681. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  47682. samples: number;
  47683. /** Gets or sets the refresh rate to use (on every frame by default) */
  47684. refreshRate: number;
  47685. /**
  47686. * Gets the hosting scene
  47687. * @returns a Scene
  47688. */
  47689. getScene(): Scene;
  47690. /** Gets the internal CubeTexture used to render to */
  47691. readonly cubeTexture: RenderTargetTexture;
  47692. /** Gets the list of meshes to render */
  47693. readonly renderList: Nullable<AbstractMesh[]>;
  47694. /**
  47695. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  47696. * @param mesh defines the mesh to attach to
  47697. */
  47698. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47699. /**
  47700. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  47701. * @param renderingGroupId The rendering group id corresponding to its index
  47702. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  47703. */
  47704. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  47705. /**
  47706. * Clean all associated resources
  47707. */
  47708. dispose(): void;
  47709. /**
  47710. * Converts the reflection probe information to a readable string for debug purpose.
  47711. * @param fullDetails Supports for multiple levels of logging within scene loading
  47712. * @returns the human readable reflection probe info
  47713. */
  47714. toString(fullDetails?: boolean): string;
  47715. /**
  47716. * Get the class name of the relfection probe.
  47717. * @returns "ReflectionProbe"
  47718. */
  47719. getClassName(): string;
  47720. /**
  47721. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  47722. * @returns The JSON representation of the texture
  47723. */
  47724. serialize(): any;
  47725. /**
  47726. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  47727. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  47728. * @param scene Define the scene the parsed reflection probe should be instantiated in
  47729. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  47730. * @returns The parsed reflection probe if successful
  47731. */
  47732. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  47733. }
  47734. }
  47735. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  47736. /** @hidden */
  47737. export var _BabylonLoaderRegistered: boolean;
  47738. }
  47739. declare module "babylonjs/Loading/Plugins/index" {
  47740. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  47741. }
  47742. declare module "babylonjs/Loading/index" {
  47743. export * from "babylonjs/Loading/loadingScreen";
  47744. export * from "babylonjs/Loading/Plugins/index";
  47745. export * from "babylonjs/Loading/sceneLoader";
  47746. export * from "babylonjs/Loading/sceneLoaderFlags";
  47747. }
  47748. declare module "babylonjs/Materials/Background/index" {
  47749. export * from "babylonjs/Materials/Background/backgroundMaterial";
  47750. }
  47751. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  47752. import { Scene } from "babylonjs/scene";
  47753. import { Color3 } from "babylonjs/Maths/math";
  47754. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  47755. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47756. /**
  47757. * The Physically based simple base material of BJS.
  47758. *
  47759. * This enables better naming and convention enforcements on top of the pbrMaterial.
  47760. * It is used as the base class for both the specGloss and metalRough conventions.
  47761. */
  47762. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  47763. /**
  47764. * Number of Simultaneous lights allowed on the material.
  47765. */
  47766. maxSimultaneousLights: number;
  47767. /**
  47768. * If sets to true, disables all the lights affecting the material.
  47769. */
  47770. disableLighting: boolean;
  47771. /**
  47772. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  47773. */
  47774. environmentTexture: BaseTexture;
  47775. /**
  47776. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47777. */
  47778. invertNormalMapX: boolean;
  47779. /**
  47780. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47781. */
  47782. invertNormalMapY: boolean;
  47783. /**
  47784. * Normal map used in the model.
  47785. */
  47786. normalTexture: BaseTexture;
  47787. /**
  47788. * Emissivie color used to self-illuminate the model.
  47789. */
  47790. emissiveColor: Color3;
  47791. /**
  47792. * Emissivie texture used to self-illuminate the model.
  47793. */
  47794. emissiveTexture: BaseTexture;
  47795. /**
  47796. * Occlusion Channel Strenght.
  47797. */
  47798. occlusionStrength: number;
  47799. /**
  47800. * Occlusion Texture of the material (adding extra occlusion effects).
  47801. */
  47802. occlusionTexture: BaseTexture;
  47803. /**
  47804. * Defines the alpha limits in alpha test mode.
  47805. */
  47806. alphaCutOff: number;
  47807. /**
  47808. * Gets the current double sided mode.
  47809. */
  47810. /**
  47811. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47812. */
  47813. doubleSided: boolean;
  47814. /**
  47815. * Stores the pre-calculated light information of a mesh in a texture.
  47816. */
  47817. lightmapTexture: BaseTexture;
  47818. /**
  47819. * If true, the light map contains occlusion information instead of lighting info.
  47820. */
  47821. useLightmapAsShadowmap: boolean;
  47822. /**
  47823. * Instantiates a new PBRMaterial instance.
  47824. *
  47825. * @param name The material name
  47826. * @param scene The scene the material will be use in.
  47827. */
  47828. constructor(name: string, scene: Scene);
  47829. getClassName(): string;
  47830. }
  47831. }
  47832. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  47833. import { Scene } from "babylonjs/scene";
  47834. import { Color3 } from "babylonjs/Maths/math";
  47835. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47836. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  47837. /**
  47838. * The PBR material of BJS following the metal roughness convention.
  47839. *
  47840. * This fits to the PBR convention in the GLTF definition:
  47841. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  47842. */
  47843. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  47844. /**
  47845. * The base color has two different interpretations depending on the value of metalness.
  47846. * When the material is a metal, the base color is the specific measured reflectance value
  47847. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  47848. * of the material.
  47849. */
  47850. baseColor: Color3;
  47851. /**
  47852. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  47853. * well as opacity information in the alpha channel.
  47854. */
  47855. baseTexture: BaseTexture;
  47856. /**
  47857. * Specifies the metallic scalar value of the material.
  47858. * Can also be used to scale the metalness values of the metallic texture.
  47859. */
  47860. metallic: number;
  47861. /**
  47862. * Specifies the roughness scalar value of the material.
  47863. * Can also be used to scale the roughness values of the metallic texture.
  47864. */
  47865. roughness: number;
  47866. /**
  47867. * Texture containing both the metallic value in the B channel and the
  47868. * roughness value in the G channel to keep better precision.
  47869. */
  47870. metallicRoughnessTexture: BaseTexture;
  47871. /**
  47872. * Instantiates a new PBRMetalRoughnessMaterial instance.
  47873. *
  47874. * @param name The material name
  47875. * @param scene The scene the material will be use in.
  47876. */
  47877. constructor(name: string, scene: Scene);
  47878. /**
  47879. * Return the currrent class name of the material.
  47880. */
  47881. getClassName(): string;
  47882. /**
  47883. * Makes a duplicate of the current material.
  47884. * @param name - name to use for the new material.
  47885. */
  47886. clone(name: string): PBRMetallicRoughnessMaterial;
  47887. /**
  47888. * Serialize the material to a parsable JSON object.
  47889. */
  47890. serialize(): any;
  47891. /**
  47892. * Parses a JSON object correponding to the serialize function.
  47893. */
  47894. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  47895. }
  47896. }
  47897. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  47898. import { Scene } from "babylonjs/scene";
  47899. import { Color3 } from "babylonjs/Maths/math";
  47900. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47901. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  47902. /**
  47903. * The PBR material of BJS following the specular glossiness convention.
  47904. *
  47905. * This fits to the PBR convention in the GLTF definition:
  47906. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  47907. */
  47908. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  47909. /**
  47910. * Specifies the diffuse color of the material.
  47911. */
  47912. diffuseColor: Color3;
  47913. /**
  47914. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  47915. * channel.
  47916. */
  47917. diffuseTexture: BaseTexture;
  47918. /**
  47919. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  47920. */
  47921. specularColor: Color3;
  47922. /**
  47923. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  47924. */
  47925. glossiness: number;
  47926. /**
  47927. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  47928. */
  47929. specularGlossinessTexture: BaseTexture;
  47930. /**
  47931. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  47932. *
  47933. * @param name The material name
  47934. * @param scene The scene the material will be use in.
  47935. */
  47936. constructor(name: string, scene: Scene);
  47937. /**
  47938. * Return the currrent class name of the material.
  47939. */
  47940. getClassName(): string;
  47941. /**
  47942. * Makes a duplicate of the current material.
  47943. * @param name - name to use for the new material.
  47944. */
  47945. clone(name: string): PBRSpecularGlossinessMaterial;
  47946. /**
  47947. * Serialize the material to a parsable JSON object.
  47948. */
  47949. serialize(): any;
  47950. /**
  47951. * Parses a JSON object correponding to the serialize function.
  47952. */
  47953. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  47954. }
  47955. }
  47956. declare module "babylonjs/Materials/PBR/index" {
  47957. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  47958. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  47959. export * from "babylonjs/Materials/PBR/pbrMaterial";
  47960. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  47961. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  47962. }
  47963. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  47964. import { Nullable } from "babylonjs/types";
  47965. import { Scene } from "babylonjs/scene";
  47966. import { Matrix } from "babylonjs/Maths/math";
  47967. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47968. /**
  47969. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  47970. * It can help converting any input color in a desired output one. This can then be used to create effects
  47971. * from sepia, black and white to sixties or futuristic rendering...
  47972. *
  47973. * The only supported format is currently 3dl.
  47974. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  47975. */
  47976. export class ColorGradingTexture extends BaseTexture {
  47977. /**
  47978. * The current texture matrix. (will always be identity in color grading texture)
  47979. */
  47980. private _textureMatrix;
  47981. /**
  47982. * The texture URL.
  47983. */
  47984. url: string;
  47985. /**
  47986. * Empty line regex stored for GC.
  47987. */
  47988. private static _noneEmptyLineRegex;
  47989. private _engine;
  47990. /**
  47991. * Instantiates a ColorGradingTexture from the following parameters.
  47992. *
  47993. * @param url The location of the color gradind data (currently only supporting 3dl)
  47994. * @param scene The scene the texture will be used in
  47995. */
  47996. constructor(url: string, scene: Scene);
  47997. /**
  47998. * Returns the texture matrix used in most of the material.
  47999. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  48000. */
  48001. getTextureMatrix(): Matrix;
  48002. /**
  48003. * Occurs when the file being loaded is a .3dl LUT file.
  48004. */
  48005. private load3dlTexture;
  48006. /**
  48007. * Starts the loading process of the texture.
  48008. */
  48009. private loadTexture;
  48010. /**
  48011. * Clones the color gradind texture.
  48012. */
  48013. clone(): ColorGradingTexture;
  48014. /**
  48015. * Called during delayed load for textures.
  48016. */
  48017. delayLoad(): void;
  48018. /**
  48019. * Parses a color grading texture serialized by Babylon.
  48020. * @param parsedTexture The texture information being parsedTexture
  48021. * @param scene The scene to load the texture in
  48022. * @param rootUrl The root url of the data assets to load
  48023. * @return A color gradind texture
  48024. */
  48025. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  48026. /**
  48027. * Serializes the LUT texture to json format.
  48028. */
  48029. serialize(): any;
  48030. }
  48031. }
  48032. declare module "babylonjs/Misc/dds" {
  48033. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48034. import { Engine } from "babylonjs/Engines/engine";
  48035. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48036. import { Nullable } from "babylonjs/types";
  48037. import { Scene } from "babylonjs/scene";
  48038. /**
  48039. * Direct draw surface info
  48040. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  48041. */
  48042. export interface DDSInfo {
  48043. /**
  48044. * Width of the texture
  48045. */
  48046. width: number;
  48047. /**
  48048. * Width of the texture
  48049. */
  48050. height: number;
  48051. /**
  48052. * Number of Mipmaps for the texture
  48053. * @see https://en.wikipedia.org/wiki/Mipmap
  48054. */
  48055. mipmapCount: number;
  48056. /**
  48057. * If the textures format is a known fourCC format
  48058. * @see https://www.fourcc.org/
  48059. */
  48060. isFourCC: boolean;
  48061. /**
  48062. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  48063. */
  48064. isRGB: boolean;
  48065. /**
  48066. * If the texture is a lumincance format
  48067. */
  48068. isLuminance: boolean;
  48069. /**
  48070. * If this is a cube texture
  48071. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  48072. */
  48073. isCube: boolean;
  48074. /**
  48075. * If the texture is a compressed format eg. FOURCC_DXT1
  48076. */
  48077. isCompressed: boolean;
  48078. /**
  48079. * The dxgiFormat of the texture
  48080. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  48081. */
  48082. dxgiFormat: number;
  48083. /**
  48084. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  48085. */
  48086. textureType: number;
  48087. /**
  48088. * Sphericle polynomial created for the dds texture
  48089. */
  48090. sphericalPolynomial?: SphericalPolynomial;
  48091. }
  48092. /**
  48093. * Class used to provide DDS decompression tools
  48094. */
  48095. export class DDSTools {
  48096. /**
  48097. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  48098. */
  48099. static StoreLODInAlphaChannel: boolean;
  48100. /**
  48101. * Gets DDS information from an array buffer
  48102. * @param arrayBuffer defines the array buffer to read data from
  48103. * @returns the DDS information
  48104. */
  48105. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  48106. private static _FloatView;
  48107. private static _Int32View;
  48108. private static _ToHalfFloat;
  48109. private static _FromHalfFloat;
  48110. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  48111. private static _GetHalfFloatRGBAArrayBuffer;
  48112. private static _GetFloatRGBAArrayBuffer;
  48113. private static _GetFloatAsUIntRGBAArrayBuffer;
  48114. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  48115. private static _GetRGBAArrayBuffer;
  48116. private static _ExtractLongWordOrder;
  48117. private static _GetRGBArrayBuffer;
  48118. private static _GetLuminanceArrayBuffer;
  48119. /**
  48120. * Uploads DDS Levels to a Babylon Texture
  48121. * @hidden
  48122. */
  48123. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  48124. }
  48125. module "babylonjs/Engines/engine" {
  48126. interface Engine {
  48127. /**
  48128. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  48129. * @param rootUrl defines the url where the file to load is located
  48130. * @param scene defines the current scene
  48131. * @param lodScale defines scale to apply to the mip map selection
  48132. * @param lodOffset defines offset to apply to the mip map selection
  48133. * @param onLoad defines an optional callback raised when the texture is loaded
  48134. * @param onError defines an optional callback raised if there is an issue to load the texture
  48135. * @param format defines the format of the data
  48136. * @param forcedExtension defines the extension to use to pick the right loader
  48137. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48138. * @returns the cube texture as an InternalTexture
  48139. */
  48140. 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;
  48141. }
  48142. }
  48143. }
  48144. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  48145. import { Nullable } from "babylonjs/types";
  48146. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48147. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48148. /**
  48149. * Implementation of the DDS Texture Loader.
  48150. * @hidden
  48151. */
  48152. export class _DDSTextureLoader implements IInternalTextureLoader {
  48153. /**
  48154. * Defines wether the loader supports cascade loading the different faces.
  48155. */
  48156. readonly supportCascades: boolean;
  48157. /**
  48158. * This returns if the loader support the current file information.
  48159. * @param extension defines the file extension of the file being loaded
  48160. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48161. * @param fallback defines the fallback internal texture if any
  48162. * @param isBase64 defines whether the texture is encoded as a base64
  48163. * @param isBuffer defines whether the texture data are stored as a buffer
  48164. * @returns true if the loader can load the specified file
  48165. */
  48166. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48167. /**
  48168. * Transform the url before loading if required.
  48169. * @param rootUrl the url of the texture
  48170. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48171. * @returns the transformed texture
  48172. */
  48173. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48174. /**
  48175. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48176. * @param rootUrl the url of the texture
  48177. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48178. * @returns the fallback texture
  48179. */
  48180. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48181. /**
  48182. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48183. * @param data contains the texture data
  48184. * @param texture defines the BabylonJS internal texture
  48185. * @param createPolynomials will be true if polynomials have been requested
  48186. * @param onLoad defines the callback to trigger once the texture is ready
  48187. * @param onError defines the callback to trigger in case of error
  48188. */
  48189. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48190. /**
  48191. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48192. * @param data contains the texture data
  48193. * @param texture defines the BabylonJS internal texture
  48194. * @param callback defines the method to call once ready to upload
  48195. */
  48196. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48197. }
  48198. }
  48199. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48200. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48201. /** @hidden */
  48202. export var rgbdEncodePixelShader: {
  48203. name: string;
  48204. shader: string;
  48205. };
  48206. }
  48207. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  48208. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48209. /** @hidden */
  48210. export var rgbdDecodePixelShader: {
  48211. name: string;
  48212. shader: string;
  48213. };
  48214. }
  48215. declare module "babylonjs/Misc/environmentTextureTools" {
  48216. import { Nullable } from "babylonjs/types";
  48217. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48218. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48219. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48220. import "babylonjs/Shaders/rgbdEncode.fragment";
  48221. import "babylonjs/Shaders/rgbdDecode.fragment";
  48222. /**
  48223. * Raw texture data and descriptor sufficient for WebGL texture upload
  48224. */
  48225. export interface EnvironmentTextureInfo {
  48226. /**
  48227. * Version of the environment map
  48228. */
  48229. version: number;
  48230. /**
  48231. * Width of image
  48232. */
  48233. width: number;
  48234. /**
  48235. * Irradiance information stored in the file.
  48236. */
  48237. irradiance: any;
  48238. /**
  48239. * Specular information stored in the file.
  48240. */
  48241. specular: any;
  48242. }
  48243. /**
  48244. * Sets of helpers addressing the serialization and deserialization of environment texture
  48245. * stored in a BabylonJS env file.
  48246. * Those files are usually stored as .env files.
  48247. */
  48248. export class EnvironmentTextureTools {
  48249. /**
  48250. * Magic number identifying the env file.
  48251. */
  48252. private static _MagicBytes;
  48253. /**
  48254. * Gets the environment info from an env file.
  48255. * @param data The array buffer containing the .env bytes.
  48256. * @returns the environment file info (the json header) if successfully parsed.
  48257. */
  48258. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  48259. /**
  48260. * Creates an environment texture from a loaded cube texture.
  48261. * @param texture defines the cube texture to convert in env file
  48262. * @return a promise containing the environment data if succesfull.
  48263. */
  48264. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48265. /**
  48266. * Creates a JSON representation of the spherical data.
  48267. * @param texture defines the texture containing the polynomials
  48268. * @return the JSON representation of the spherical info
  48269. */
  48270. private static _CreateEnvTextureIrradiance;
  48271. /**
  48272. * Uploads the texture info contained in the env file to the GPU.
  48273. * @param texture defines the internal texture to upload to
  48274. * @param arrayBuffer defines the buffer cotaining the data to load
  48275. * @param info defines the texture info retrieved through the GetEnvInfo method
  48276. * @returns a promise
  48277. */
  48278. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  48279. /**
  48280. * Uploads the levels of image data to the GPU.
  48281. * @param texture defines the internal texture to upload to
  48282. * @param imageData defines the array buffer views of image data [mipmap][face]
  48283. * @returns a promise
  48284. */
  48285. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48286. /**
  48287. * Uploads spherical polynomials information to the texture.
  48288. * @param texture defines the texture we are trying to upload the information to
  48289. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48290. */
  48291. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48292. /** @hidden */
  48293. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48294. }
  48295. }
  48296. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  48297. import { Nullable } from "babylonjs/types";
  48298. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48299. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48300. /**
  48301. * Implementation of the ENV Texture Loader.
  48302. * @hidden
  48303. */
  48304. export class _ENVTextureLoader implements IInternalTextureLoader {
  48305. /**
  48306. * Defines wether the loader supports cascade loading the different faces.
  48307. */
  48308. readonly supportCascades: boolean;
  48309. /**
  48310. * This returns if the loader support the current file information.
  48311. * @param extension defines the file extension of the file being loaded
  48312. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48313. * @param fallback defines the fallback internal texture if any
  48314. * @param isBase64 defines whether the texture is encoded as a base64
  48315. * @param isBuffer defines whether the texture data are stored as a buffer
  48316. * @returns true if the loader can load the specified file
  48317. */
  48318. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48319. /**
  48320. * Transform the url before loading if required.
  48321. * @param rootUrl the url of the texture
  48322. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48323. * @returns the transformed texture
  48324. */
  48325. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48326. /**
  48327. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48328. * @param rootUrl the url of the texture
  48329. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48330. * @returns the fallback texture
  48331. */
  48332. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48333. /**
  48334. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48335. * @param data contains the texture data
  48336. * @param texture defines the BabylonJS internal texture
  48337. * @param createPolynomials will be true if polynomials have been requested
  48338. * @param onLoad defines the callback to trigger once the texture is ready
  48339. * @param onError defines the callback to trigger in case of error
  48340. */
  48341. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48342. /**
  48343. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48344. * @param data contains the texture data
  48345. * @param texture defines the BabylonJS internal texture
  48346. * @param callback defines the method to call once ready to upload
  48347. */
  48348. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48349. }
  48350. }
  48351. declare module "babylonjs/Misc/khronosTextureContainer" {
  48352. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48353. /**
  48354. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48355. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48356. */
  48357. export class KhronosTextureContainer {
  48358. /** contents of the KTX container file */
  48359. arrayBuffer: any;
  48360. private static HEADER_LEN;
  48361. private static COMPRESSED_2D;
  48362. private static COMPRESSED_3D;
  48363. private static TEX_2D;
  48364. private static TEX_3D;
  48365. /**
  48366. * Gets the openGL type
  48367. */
  48368. glType: number;
  48369. /**
  48370. * Gets the openGL type size
  48371. */
  48372. glTypeSize: number;
  48373. /**
  48374. * Gets the openGL format
  48375. */
  48376. glFormat: number;
  48377. /**
  48378. * Gets the openGL internal format
  48379. */
  48380. glInternalFormat: number;
  48381. /**
  48382. * Gets the base internal format
  48383. */
  48384. glBaseInternalFormat: number;
  48385. /**
  48386. * Gets image width in pixel
  48387. */
  48388. pixelWidth: number;
  48389. /**
  48390. * Gets image height in pixel
  48391. */
  48392. pixelHeight: number;
  48393. /**
  48394. * Gets image depth in pixels
  48395. */
  48396. pixelDepth: number;
  48397. /**
  48398. * Gets the number of array elements
  48399. */
  48400. numberOfArrayElements: number;
  48401. /**
  48402. * Gets the number of faces
  48403. */
  48404. numberOfFaces: number;
  48405. /**
  48406. * Gets the number of mipmap levels
  48407. */
  48408. numberOfMipmapLevels: number;
  48409. /**
  48410. * Gets the bytes of key value data
  48411. */
  48412. bytesOfKeyValueData: number;
  48413. /**
  48414. * Gets the load type
  48415. */
  48416. loadType: number;
  48417. /**
  48418. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48419. */
  48420. isInvalid: boolean;
  48421. /**
  48422. * Creates a new KhronosTextureContainer
  48423. * @param arrayBuffer contents of the KTX container file
  48424. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48425. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48426. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48427. */
  48428. constructor(
  48429. /** contents of the KTX container file */
  48430. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48431. /**
  48432. * Uploads KTX content to a Babylon Texture.
  48433. * It is assumed that the texture has already been created & is currently bound
  48434. * @hidden
  48435. */
  48436. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48437. private _upload2DCompressedLevels;
  48438. }
  48439. }
  48440. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  48441. import { Nullable } from "babylonjs/types";
  48442. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48443. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48444. /**
  48445. * Implementation of the KTX Texture Loader.
  48446. * @hidden
  48447. */
  48448. export class _KTXTextureLoader implements IInternalTextureLoader {
  48449. /**
  48450. * Defines wether the loader supports cascade loading the different faces.
  48451. */
  48452. readonly supportCascades: boolean;
  48453. /**
  48454. * This returns if the loader support the current file information.
  48455. * @param extension defines the file extension of the file being loaded
  48456. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48457. * @param fallback defines the fallback internal texture if any
  48458. * @param isBase64 defines whether the texture is encoded as a base64
  48459. * @param isBuffer defines whether the texture data are stored as a buffer
  48460. * @returns true if the loader can load the specified file
  48461. */
  48462. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48463. /**
  48464. * Transform the url before loading if required.
  48465. * @param rootUrl the url of the texture
  48466. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48467. * @returns the transformed texture
  48468. */
  48469. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48470. /**
  48471. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48472. * @param rootUrl the url of the texture
  48473. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48474. * @returns the fallback texture
  48475. */
  48476. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48477. /**
  48478. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48479. * @param data contains the texture data
  48480. * @param texture defines the BabylonJS internal texture
  48481. * @param createPolynomials will be true if polynomials have been requested
  48482. * @param onLoad defines the callback to trigger once the texture is ready
  48483. * @param onError defines the callback to trigger in case of error
  48484. */
  48485. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48486. /**
  48487. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48488. * @param data contains the texture data
  48489. * @param texture defines the BabylonJS internal texture
  48490. * @param callback defines the method to call once ready to upload
  48491. */
  48492. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48493. }
  48494. }
  48495. declare module "babylonjs/Misc/tga" {
  48496. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48497. /**
  48498. * Based on jsTGALoader - Javascript loader for TGA file
  48499. * By Vincent Thibault
  48500. * @see http://blog.robrowser.com/javascript-tga-loader.html
  48501. */
  48502. export class TGATools {
  48503. private static _TYPE_INDEXED;
  48504. private static _TYPE_RGB;
  48505. private static _TYPE_GREY;
  48506. private static _TYPE_RLE_INDEXED;
  48507. private static _TYPE_RLE_RGB;
  48508. private static _TYPE_RLE_GREY;
  48509. private static _ORIGIN_MASK;
  48510. private static _ORIGIN_SHIFT;
  48511. private static _ORIGIN_BL;
  48512. private static _ORIGIN_BR;
  48513. private static _ORIGIN_UL;
  48514. private static _ORIGIN_UR;
  48515. /**
  48516. * Gets the header of a TGA file
  48517. * @param data defines the TGA data
  48518. * @returns the header
  48519. */
  48520. static GetTGAHeader(data: Uint8Array): any;
  48521. /**
  48522. * Uploads TGA content to a Babylon Texture
  48523. * @hidden
  48524. */
  48525. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  48526. /** @hidden */
  48527. 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;
  48528. /** @hidden */
  48529. 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;
  48530. /** @hidden */
  48531. 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;
  48532. /** @hidden */
  48533. 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;
  48534. /** @hidden */
  48535. 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;
  48536. /** @hidden */
  48537. 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;
  48538. }
  48539. }
  48540. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  48541. import { Nullable } from "babylonjs/types";
  48542. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48543. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48544. /**
  48545. * Implementation of the TGA Texture Loader.
  48546. * @hidden
  48547. */
  48548. export class _TGATextureLoader implements IInternalTextureLoader {
  48549. /**
  48550. * Defines wether the loader supports cascade loading the different faces.
  48551. */
  48552. readonly supportCascades: boolean;
  48553. /**
  48554. * This returns if the loader support the current file information.
  48555. * @param extension defines the file extension of the file being loaded
  48556. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48557. * @param fallback defines the fallback internal texture if any
  48558. * @param isBase64 defines whether the texture is encoded as a base64
  48559. * @param isBuffer defines whether the texture data are stored as a buffer
  48560. * @returns true if the loader can load the specified file
  48561. */
  48562. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48563. /**
  48564. * Transform the url before loading if required.
  48565. * @param rootUrl the url of the texture
  48566. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48567. * @returns the transformed texture
  48568. */
  48569. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48570. /**
  48571. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48572. * @param rootUrl the url of the texture
  48573. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48574. * @returns the fallback texture
  48575. */
  48576. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48577. /**
  48578. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48579. * @param data contains the texture data
  48580. * @param texture defines the BabylonJS internal texture
  48581. * @param createPolynomials will be true if polynomials have been requested
  48582. * @param onLoad defines the callback to trigger once the texture is ready
  48583. * @param onError defines the callback to trigger in case of error
  48584. */
  48585. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48586. /**
  48587. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48588. * @param data contains the texture data
  48589. * @param texture defines the BabylonJS internal texture
  48590. * @param callback defines the method to call once ready to upload
  48591. */
  48592. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48593. }
  48594. }
  48595. declare module "babylonjs/Materials/Textures/Loaders/index" {
  48596. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  48597. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  48598. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  48599. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  48600. }
  48601. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  48602. import { Scene } from "babylonjs/scene";
  48603. import { Texture } from "babylonjs/Materials/Textures/texture";
  48604. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  48605. /**
  48606. * 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.
  48607. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48608. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48609. */
  48610. export class CustomProceduralTexture extends ProceduralTexture {
  48611. private _animate;
  48612. private _time;
  48613. private _config;
  48614. private _texturePath;
  48615. /**
  48616. * Instantiates a new Custom Procedural Texture.
  48617. * 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.
  48618. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48619. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48620. * @param name Define the name of the texture
  48621. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  48622. * @param size Define the size of the texture to create
  48623. * @param scene Define the scene the texture belongs to
  48624. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  48625. * @param generateMipMaps Define if the texture should creates mip maps or not
  48626. */
  48627. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48628. private _loadJson;
  48629. /**
  48630. * Is the texture ready to be used ? (rendered at least once)
  48631. * @returns true if ready, otherwise, false.
  48632. */
  48633. isReady(): boolean;
  48634. /**
  48635. * Render the texture to its associated render target.
  48636. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  48637. */
  48638. render(useCameraPostProcess?: boolean): void;
  48639. /**
  48640. * Update the list of dependant textures samplers in the shader.
  48641. */
  48642. updateTextures(): void;
  48643. /**
  48644. * Update the uniform values of the procedural texture in the shader.
  48645. */
  48646. updateShaderUniforms(): void;
  48647. /**
  48648. * Define if the texture animates or not.
  48649. */
  48650. animate: boolean;
  48651. }
  48652. }
  48653. declare module "babylonjs/Shaders/noise.fragment" {
  48654. /** @hidden */
  48655. export var noisePixelShader: {
  48656. name: string;
  48657. shader: string;
  48658. };
  48659. }
  48660. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  48661. import { Nullable } from "babylonjs/types";
  48662. import { Scene } from "babylonjs/scene";
  48663. import { Texture } from "babylonjs/Materials/Textures/texture";
  48664. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  48665. import "babylonjs/Shaders/noise.fragment";
  48666. /**
  48667. * Class used to generate noise procedural textures
  48668. */
  48669. export class NoiseProceduralTexture extends ProceduralTexture {
  48670. private _time;
  48671. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  48672. brightness: number;
  48673. /** Defines the number of octaves to process */
  48674. octaves: number;
  48675. /** Defines the level of persistence (0.8 by default) */
  48676. persistence: number;
  48677. /** Gets or sets animation speed factor (default is 1) */
  48678. animationSpeedFactor: number;
  48679. /**
  48680. * Creates a new NoiseProceduralTexture
  48681. * @param name defines the name fo the texture
  48682. * @param size defines the size of the texture (default is 256)
  48683. * @param scene defines the hosting scene
  48684. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  48685. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  48686. */
  48687. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48688. private _updateShaderUniforms;
  48689. protected _getDefines(): string;
  48690. /** Generate the current state of the procedural texture */
  48691. render(useCameraPostProcess?: boolean): void;
  48692. /**
  48693. * Serializes this noise procedural texture
  48694. * @returns a serialized noise procedural texture object
  48695. */
  48696. serialize(): any;
  48697. /**
  48698. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  48699. * @param parsedTexture defines parsed texture data
  48700. * @param scene defines the current scene
  48701. * @param rootUrl defines the root URL containing noise procedural texture information
  48702. * @returns a parsed NoiseProceduralTexture
  48703. */
  48704. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  48705. }
  48706. }
  48707. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  48708. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  48709. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  48710. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  48711. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  48712. }
  48713. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  48714. import { Nullable } from "babylonjs/types";
  48715. import { Scene } from "babylonjs/scene";
  48716. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48717. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48718. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48719. /**
  48720. * Raw cube texture where the raw buffers are passed in
  48721. */
  48722. export class RawCubeTexture extends CubeTexture {
  48723. /**
  48724. * Creates a cube texture where the raw buffers are passed in.
  48725. * @param scene defines the scene the texture is attached to
  48726. * @param data defines the array of data to use to create each face
  48727. * @param size defines the size of the textures
  48728. * @param format defines the format of the data
  48729. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  48730. * @param generateMipMaps defines if the engine should generate the mip levels
  48731. * @param invertY defines if data must be stored with Y axis inverted
  48732. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  48733. * @param compression defines the compression used (null by default)
  48734. */
  48735. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  48736. /**
  48737. * Updates the raw cube texture.
  48738. * @param data defines the data to store
  48739. * @param format defines the data format
  48740. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  48741. * @param invertY defines if data must be stored with Y axis inverted
  48742. * @param compression defines the compression used (null by default)
  48743. * @param level defines which level of the texture to update
  48744. */
  48745. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  48746. /**
  48747. * Updates a raw cube texture with RGBD encoded data.
  48748. * @param data defines the array of data [mipmap][face] to use to create each face
  48749. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  48750. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48751. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48752. * @returns a promsie that resolves when the operation is complete
  48753. */
  48754. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  48755. /**
  48756. * Clones the raw cube texture.
  48757. * @return a new cube texture
  48758. */
  48759. clone(): CubeTexture;
  48760. /** @hidden */
  48761. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48762. }
  48763. }
  48764. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  48765. import { Scene } from "babylonjs/scene";
  48766. import { Texture } from "babylonjs/Materials/Textures/texture";
  48767. /**
  48768. * Class used to store 3D textures containing user data
  48769. */
  48770. export class RawTexture3D extends Texture {
  48771. /** Gets or sets the texture format to use */
  48772. format: number;
  48773. private _engine;
  48774. /**
  48775. * Create a new RawTexture3D
  48776. * @param data defines the data of the texture
  48777. * @param width defines the width of the texture
  48778. * @param height defines the height of the texture
  48779. * @param depth defines the depth of the texture
  48780. * @param format defines the texture format to use
  48781. * @param scene defines the hosting scene
  48782. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  48783. * @param invertY defines if texture must be stored with Y axis inverted
  48784. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  48785. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  48786. */
  48787. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  48788. /** Gets or sets the texture format to use */
  48789. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  48790. /**
  48791. * Update the texture with new data
  48792. * @param data defines the data to store in the texture
  48793. */
  48794. update(data: ArrayBufferView): void;
  48795. }
  48796. }
  48797. declare module "babylonjs/Materials/Textures/refractionTexture" {
  48798. import { Scene } from "babylonjs/scene";
  48799. import { Plane } from "babylonjs/Maths/math";
  48800. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48801. /**
  48802. * Creates a refraction texture used by refraction channel of the standard material.
  48803. * It is like a mirror but to see through a material.
  48804. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48805. */
  48806. export class RefractionTexture extends RenderTargetTexture {
  48807. /**
  48808. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  48809. * 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.
  48810. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48811. */
  48812. refractionPlane: Plane;
  48813. /**
  48814. * Define how deep under the surface we should see.
  48815. */
  48816. depth: number;
  48817. /**
  48818. * Creates a refraction texture used by refraction channel of the standard material.
  48819. * It is like a mirror but to see through a material.
  48820. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48821. * @param name Define the texture name
  48822. * @param size Define the size of the underlying texture
  48823. * @param scene Define the scene the refraction belongs to
  48824. * @param generateMipMaps Define if we need to generate mips level for the refraction
  48825. */
  48826. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  48827. /**
  48828. * Clone the refraction texture.
  48829. * @returns the cloned texture
  48830. */
  48831. clone(): RefractionTexture;
  48832. /**
  48833. * Serialize the texture to a JSON representation you could use in Parse later on
  48834. * @returns the serialized JSON representation
  48835. */
  48836. serialize(): any;
  48837. }
  48838. }
  48839. declare module "babylonjs/Materials/Textures/index" {
  48840. export * from "babylonjs/Materials/Textures/baseTexture";
  48841. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  48842. export * from "babylonjs/Materials/Textures/cubeTexture";
  48843. export * from "babylonjs/Materials/Textures/dynamicTexture";
  48844. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  48845. export * from "babylonjs/Materials/Textures/internalTexture";
  48846. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  48847. export * from "babylonjs/Materials/Textures/internalTextureTracker";
  48848. export * from "babylonjs/Materials/Textures/Loaders/index";
  48849. export * from "babylonjs/Materials/Textures/mirrorTexture";
  48850. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  48851. export * from "babylonjs/Materials/Textures/Procedurals/index";
  48852. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  48853. export * from "babylonjs/Materials/Textures/rawTexture";
  48854. export * from "babylonjs/Materials/Textures/rawTexture3D";
  48855. export * from "babylonjs/Materials/Textures/refractionTexture";
  48856. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  48857. export * from "babylonjs/Materials/Textures/texture";
  48858. export * from "babylonjs/Materials/Textures/videoTexture";
  48859. }
  48860. declare module "babylonjs/Materials/index" {
  48861. export * from "babylonjs/Materials/Background/index";
  48862. export * from "babylonjs/Materials/colorCurves";
  48863. export * from "babylonjs/Materials/effect";
  48864. export * from "babylonjs/Materials/fresnelParameters";
  48865. export * from "babylonjs/Materials/imageProcessingConfiguration";
  48866. export * from "babylonjs/Materials/material";
  48867. export * from "babylonjs/Materials/materialDefines";
  48868. export * from "babylonjs/Materials/materialHelper";
  48869. export * from "babylonjs/Materials/multiMaterial";
  48870. export * from "babylonjs/Materials/PBR/index";
  48871. export * from "babylonjs/Materials/pushMaterial";
  48872. export * from "babylonjs/Materials/shaderMaterial";
  48873. export * from "babylonjs/Materials/standardMaterial";
  48874. export * from "babylonjs/Materials/Textures/index";
  48875. export * from "babylonjs/Materials/uniformBuffer";
  48876. export * from "babylonjs/Materials/materialFlags";
  48877. }
  48878. declare module "babylonjs/Maths/index" {
  48879. export * from "babylonjs/Maths/math.scalar";
  48880. export * from "babylonjs/Maths/math";
  48881. export * from "babylonjs/Maths/sphericalPolynomial";
  48882. }
  48883. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  48884. import { IDisposable } from "babylonjs/scene";
  48885. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  48886. /**
  48887. * Configuration for Draco compression
  48888. */
  48889. export interface IDracoCompressionConfiguration {
  48890. /**
  48891. * Configuration for the decoder.
  48892. */
  48893. decoder?: {
  48894. /**
  48895. * The url to the WebAssembly module.
  48896. */
  48897. wasmUrl?: string;
  48898. /**
  48899. * The url to the WebAssembly binary.
  48900. */
  48901. wasmBinaryUrl?: string;
  48902. /**
  48903. * The url to the fallback JavaScript module.
  48904. */
  48905. fallbackUrl?: string;
  48906. };
  48907. }
  48908. /**
  48909. * Draco compression (https://google.github.io/draco/)
  48910. *
  48911. * This class wraps the Draco module.
  48912. *
  48913. * **Encoder**
  48914. *
  48915. * The encoder is not currently implemented.
  48916. *
  48917. * **Decoder**
  48918. *
  48919. * 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.
  48920. *
  48921. * To update the configuration, use the following code:
  48922. * ```javascript
  48923. * DracoCompression.Configuration = {
  48924. * decoder: {
  48925. * wasmUrl: "<url to the WebAssembly library>",
  48926. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  48927. * fallbackUrl: "<url to the fallback JavaScript library>",
  48928. * }
  48929. * };
  48930. * ```
  48931. *
  48932. * 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.
  48933. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  48934. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  48935. *
  48936. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  48937. * ```javascript
  48938. * var dracoCompression = new DracoCompression();
  48939. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  48940. * [VertexBuffer.PositionKind]: 0
  48941. * });
  48942. * ```
  48943. *
  48944. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  48945. */
  48946. export class DracoCompression implements IDisposable {
  48947. private static _DecoderModulePromise;
  48948. /**
  48949. * The configuration. Defaults to the following urls:
  48950. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  48951. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  48952. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  48953. */
  48954. static Configuration: IDracoCompressionConfiguration;
  48955. /**
  48956. * Returns true if the decoder is available.
  48957. */
  48958. static readonly DecoderAvailable: boolean;
  48959. /**
  48960. * Constructor
  48961. */
  48962. constructor();
  48963. /**
  48964. * Stop all async operations and release resources.
  48965. */
  48966. dispose(): void;
  48967. /**
  48968. * Decode Draco compressed mesh data to vertex data.
  48969. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  48970. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  48971. * @returns A promise that resolves with the decoded vertex data
  48972. */
  48973. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  48974. [kind: string]: number;
  48975. }): Promise<VertexData>;
  48976. private static _GetDecoderModule;
  48977. private static _LoadScriptAsync;
  48978. private static _LoadFileAsync;
  48979. }
  48980. }
  48981. declare module "babylonjs/Meshes/Compression/index" {
  48982. export * from "babylonjs/Meshes/Compression/dracoCompression";
  48983. }
  48984. declare module "babylonjs/Meshes/csg" {
  48985. import { Nullable } from "babylonjs/types";
  48986. import { Scene } from "babylonjs/scene";
  48987. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  48988. import { Mesh } from "babylonjs/Meshes/mesh";
  48989. import { Material } from "babylonjs/Materials/material";
  48990. /**
  48991. * Class for building Constructive Solid Geometry
  48992. */
  48993. export class CSG {
  48994. private polygons;
  48995. /**
  48996. * The world matrix
  48997. */
  48998. matrix: Matrix;
  48999. /**
  49000. * Stores the position
  49001. */
  49002. position: Vector3;
  49003. /**
  49004. * Stores the rotation
  49005. */
  49006. rotation: Vector3;
  49007. /**
  49008. * Stores the rotation quaternion
  49009. */
  49010. rotationQuaternion: Nullable<Quaternion>;
  49011. /**
  49012. * Stores the scaling vector
  49013. */
  49014. scaling: Vector3;
  49015. /**
  49016. * Convert the Mesh to CSG
  49017. * @param mesh The Mesh to convert to CSG
  49018. * @returns A new CSG from the Mesh
  49019. */
  49020. static FromMesh(mesh: Mesh): CSG;
  49021. /**
  49022. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  49023. * @param polygons Polygons used to construct a CSG solid
  49024. */
  49025. private static FromPolygons;
  49026. /**
  49027. * Clones, or makes a deep copy, of the CSG
  49028. * @returns A new CSG
  49029. */
  49030. clone(): CSG;
  49031. /**
  49032. * Unions this CSG with another CSG
  49033. * @param csg The CSG to union against this CSG
  49034. * @returns The unioned CSG
  49035. */
  49036. union(csg: CSG): CSG;
  49037. /**
  49038. * Unions this CSG with another CSG in place
  49039. * @param csg The CSG to union against this CSG
  49040. */
  49041. unionInPlace(csg: CSG): void;
  49042. /**
  49043. * Subtracts this CSG with another CSG
  49044. * @param csg The CSG to subtract against this CSG
  49045. * @returns A new CSG
  49046. */
  49047. subtract(csg: CSG): CSG;
  49048. /**
  49049. * Subtracts this CSG with another CSG in place
  49050. * @param csg The CSG to subtact against this CSG
  49051. */
  49052. subtractInPlace(csg: CSG): void;
  49053. /**
  49054. * Intersect this CSG with another CSG
  49055. * @param csg The CSG to intersect against this CSG
  49056. * @returns A new CSG
  49057. */
  49058. intersect(csg: CSG): CSG;
  49059. /**
  49060. * Intersects this CSG with another CSG in place
  49061. * @param csg The CSG to intersect against this CSG
  49062. */
  49063. intersectInPlace(csg: CSG): void;
  49064. /**
  49065. * Return a new CSG solid with solid and empty space switched. This solid is
  49066. * not modified.
  49067. * @returns A new CSG solid with solid and empty space switched
  49068. */
  49069. inverse(): CSG;
  49070. /**
  49071. * Inverses the CSG in place
  49072. */
  49073. inverseInPlace(): void;
  49074. /**
  49075. * This is used to keep meshes transformations so they can be restored
  49076. * when we build back a Babylon Mesh
  49077. * NB : All CSG operations are performed in world coordinates
  49078. * @param csg The CSG to copy the transform attributes from
  49079. * @returns This CSG
  49080. */
  49081. copyTransformAttributes(csg: CSG): CSG;
  49082. /**
  49083. * Build Raw mesh from CSG
  49084. * Coordinates here are in world space
  49085. * @param name The name of the mesh geometry
  49086. * @param scene The Scene
  49087. * @param keepSubMeshes Specifies if the submeshes should be kept
  49088. * @returns A new Mesh
  49089. */
  49090. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  49091. /**
  49092. * Build Mesh from CSG taking material and transforms into account
  49093. * @param name The name of the Mesh
  49094. * @param material The material of the Mesh
  49095. * @param scene The Scene
  49096. * @param keepSubMeshes Specifies if submeshes should be kept
  49097. * @returns The new Mesh
  49098. */
  49099. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  49100. }
  49101. }
  49102. declare module "babylonjs/Meshes/trailMesh" {
  49103. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49104. import { Mesh } from "babylonjs/Meshes/mesh";
  49105. import { Scene } from "babylonjs/scene";
  49106. /**
  49107. * Class used to create a trail following a mesh
  49108. */
  49109. export class TrailMesh extends Mesh {
  49110. private _generator;
  49111. private _autoStart;
  49112. private _running;
  49113. private _diameter;
  49114. private _length;
  49115. private _sectionPolygonPointsCount;
  49116. private _sectionVectors;
  49117. private _sectionNormalVectors;
  49118. private _beforeRenderObserver;
  49119. /**
  49120. * @constructor
  49121. * @param name The value used by scene.getMeshByName() to do a lookup.
  49122. * @param generator The mesh to generate a trail.
  49123. * @param scene The scene to add this mesh to.
  49124. * @param diameter Diameter of trailing mesh. Default is 1.
  49125. * @param length Length of trailing mesh. Default is 60.
  49126. * @param autoStart Automatically start trailing mesh. Default true.
  49127. */
  49128. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  49129. /**
  49130. * "TrailMesh"
  49131. * @returns "TrailMesh"
  49132. */
  49133. getClassName(): string;
  49134. private _createMesh;
  49135. /**
  49136. * Start trailing mesh.
  49137. */
  49138. start(): void;
  49139. /**
  49140. * Stop trailing mesh.
  49141. */
  49142. stop(): void;
  49143. /**
  49144. * Update trailing mesh geometry.
  49145. */
  49146. update(): void;
  49147. /**
  49148. * Returns a new TrailMesh object.
  49149. * @param name is a string, the name given to the new mesh
  49150. * @param newGenerator use new generator object for cloned trail mesh
  49151. * @returns a new mesh
  49152. */
  49153. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  49154. /**
  49155. * Serializes this trail mesh
  49156. * @param serializationObject object to write serialization to
  49157. */
  49158. serialize(serializationObject: any): void;
  49159. /**
  49160. * Parses a serialized trail mesh
  49161. * @param parsedMesh the serialized mesh
  49162. * @param scene the scene to create the trail mesh in
  49163. * @returns the created trail mesh
  49164. */
  49165. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  49166. }
  49167. }
  49168. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  49169. import { Nullable } from "babylonjs/types";
  49170. import { Scene } from "babylonjs/scene";
  49171. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  49172. import { Mesh } from "babylonjs/Meshes/mesh";
  49173. /**
  49174. * Class containing static functions to help procedurally build meshes
  49175. */
  49176. export class RibbonBuilder {
  49177. /**
  49178. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49179. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49180. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49181. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49182. * * 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
  49183. * * 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
  49184. * * 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
  49185. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49186. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49187. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49188. * * 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
  49189. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49190. * * 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
  49191. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49192. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49193. * @param name defines the name of the mesh
  49194. * @param options defines the options used to create the mesh
  49195. * @param scene defines the hosting scene
  49196. * @returns the ribbon mesh
  49197. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49198. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49199. */
  49200. static CreateRibbon(name: string, options: {
  49201. pathArray: Vector3[][];
  49202. closeArray?: boolean;
  49203. closePath?: boolean;
  49204. offset?: number;
  49205. updatable?: boolean;
  49206. sideOrientation?: number;
  49207. frontUVs?: Vector4;
  49208. backUVs?: Vector4;
  49209. instance?: Mesh;
  49210. invertUV?: boolean;
  49211. uvs?: Vector2[];
  49212. colors?: Color4[];
  49213. }, scene?: Nullable<Scene>): Mesh;
  49214. }
  49215. }
  49216. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  49217. import { Vector4 } from "babylonjs/Maths/math";
  49218. import { Mesh } from "babylonjs/Meshes/mesh";
  49219. /**
  49220. * Class containing static functions to help procedurally build meshes
  49221. */
  49222. export class TorusKnotBuilder {
  49223. /**
  49224. * Creates a torus knot mesh
  49225. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  49226. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  49227. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  49228. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  49229. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49230. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49231. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49232. * @param name defines the name of the mesh
  49233. * @param options defines the options used to create the mesh
  49234. * @param scene defines the hosting scene
  49235. * @returns the torus knot mesh
  49236. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  49237. */
  49238. static CreateTorusKnot(name: string, options: {
  49239. radius?: number;
  49240. tube?: number;
  49241. radialSegments?: number;
  49242. tubularSegments?: number;
  49243. p?: number;
  49244. q?: number;
  49245. updatable?: boolean;
  49246. sideOrientation?: number;
  49247. frontUVs?: Vector4;
  49248. backUVs?: Vector4;
  49249. }, scene: any): Mesh;
  49250. }
  49251. }
  49252. declare module "babylonjs/Meshes/polygonMesh" {
  49253. import { Scene } from "babylonjs/scene";
  49254. import { Vector2, Path2 } from "babylonjs/Maths/math";
  49255. import { Mesh } from "babylonjs/Meshes/mesh";
  49256. /**
  49257. * Polygon
  49258. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  49259. */
  49260. export class Polygon {
  49261. /**
  49262. * Creates a rectangle
  49263. * @param xmin bottom X coord
  49264. * @param ymin bottom Y coord
  49265. * @param xmax top X coord
  49266. * @param ymax top Y coord
  49267. * @returns points that make the resulting rectation
  49268. */
  49269. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  49270. /**
  49271. * Creates a circle
  49272. * @param radius radius of circle
  49273. * @param cx scale in x
  49274. * @param cy scale in y
  49275. * @param numberOfSides number of sides that make up the circle
  49276. * @returns points that make the resulting circle
  49277. */
  49278. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  49279. /**
  49280. * Creates a polygon from input string
  49281. * @param input Input polygon data
  49282. * @returns the parsed points
  49283. */
  49284. static Parse(input: string): Vector2[];
  49285. /**
  49286. * Starts building a polygon from x and y coordinates
  49287. * @param x x coordinate
  49288. * @param y y coordinate
  49289. * @returns the started path2
  49290. */
  49291. static StartingAt(x: number, y: number): Path2;
  49292. }
  49293. /**
  49294. * Builds a polygon
  49295. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  49296. */
  49297. export class PolygonMeshBuilder {
  49298. private _points;
  49299. private _outlinepoints;
  49300. private _holes;
  49301. private _name;
  49302. private _scene;
  49303. private _epoints;
  49304. private _eholes;
  49305. private _addToepoint;
  49306. /**
  49307. * Babylon reference to the earcut plugin.
  49308. */
  49309. bjsEarcut: any;
  49310. /**
  49311. * Creates a PolygonMeshBuilder
  49312. * @param name name of the builder
  49313. * @param contours Path of the polygon
  49314. * @param scene scene to add to
  49315. * @param earcutInjection can be used to inject your own earcut reference
  49316. */
  49317. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  49318. /**
  49319. * Adds a whole within the polygon
  49320. * @param hole Array of points defining the hole
  49321. * @returns this
  49322. */
  49323. addHole(hole: Vector2[]): PolygonMeshBuilder;
  49324. /**
  49325. * Creates the polygon
  49326. * @param updatable If the mesh should be updatable
  49327. * @param depth The depth of the mesh created
  49328. * @returns the created mesh
  49329. */
  49330. build(updatable?: boolean, depth?: number): Mesh;
  49331. /**
  49332. * Adds a side to the polygon
  49333. * @param positions points that make the polygon
  49334. * @param normals normals of the polygon
  49335. * @param uvs uvs of the polygon
  49336. * @param indices indices of the polygon
  49337. * @param bounds bounds of the polygon
  49338. * @param points points of the polygon
  49339. * @param depth depth of the polygon
  49340. * @param flip flip of the polygon
  49341. */
  49342. private addSide;
  49343. }
  49344. }
  49345. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  49346. import { Scene } from "babylonjs/scene";
  49347. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  49348. import { Mesh } from "babylonjs/Meshes/mesh";
  49349. /**
  49350. * Class containing static functions to help procedurally build meshes
  49351. */
  49352. export class PolygonBuilder {
  49353. /**
  49354. * Creates a polygon mesh
  49355. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  49356. * * 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
  49357. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  49358. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49359. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  49360. * * Remember you can only change the shape positions, not their number when updating a polygon
  49361. * @param name defines the name of the mesh
  49362. * @param options defines the options used to create the mesh
  49363. * @param scene defines the hosting scene
  49364. * @param earcutInjection can be used to inject your own earcut reference
  49365. * @returns the polygon mesh
  49366. */
  49367. static CreatePolygon(name: string, options: {
  49368. shape: Vector3[];
  49369. holes?: Vector3[][];
  49370. depth?: number;
  49371. faceUV?: Vector4[];
  49372. faceColors?: Color4[];
  49373. updatable?: boolean;
  49374. sideOrientation?: number;
  49375. frontUVs?: Vector4;
  49376. backUVs?: Vector4;
  49377. }, scene: Scene, earcutInjection?: any): Mesh;
  49378. /**
  49379. * Creates an extruded polygon mesh, with depth in the Y direction.
  49380. * * 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)
  49381. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49382. * @param name defines the name of the mesh
  49383. * @param options defines the options used to create the mesh
  49384. * @param scene defines the hosting scene
  49385. * @param earcutInjection can be used to inject your own earcut reference
  49386. * @returns the polygon mesh
  49387. */
  49388. static ExtrudePolygon(name: string, options: {
  49389. shape: Vector3[];
  49390. holes?: Vector3[][];
  49391. depth?: number;
  49392. faceUV?: Vector4[];
  49393. faceColors?: Color4[];
  49394. updatable?: boolean;
  49395. sideOrientation?: number;
  49396. frontUVs?: Vector4;
  49397. backUVs?: Vector4;
  49398. }, scene: Scene, earcutInjection?: any): Mesh;
  49399. }
  49400. }
  49401. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  49402. import { Nullable } from "babylonjs/types";
  49403. import { Scene } from "babylonjs/scene";
  49404. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  49405. import { Mesh } from "babylonjs/Meshes/mesh";
  49406. /**
  49407. * Class containing static functions to help procedurally build meshes
  49408. */
  49409. export class ShapeBuilder {
  49410. /**
  49411. * 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.
  49412. * * 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.
  49413. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49414. * * 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.
  49415. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49416. * * 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
  49417. * * 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
  49418. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49419. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49420. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49421. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49422. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49423. * @param name defines the name of the mesh
  49424. * @param options defines the options used to create the mesh
  49425. * @param scene defines the hosting scene
  49426. * @returns the extruded shape mesh
  49427. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49428. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49429. */
  49430. static ExtrudeShape(name: string, options: {
  49431. shape: Vector3[];
  49432. path: Vector3[];
  49433. scale?: number;
  49434. rotation?: number;
  49435. cap?: number;
  49436. updatable?: boolean;
  49437. sideOrientation?: number;
  49438. frontUVs?: Vector4;
  49439. backUVs?: Vector4;
  49440. instance?: Mesh;
  49441. invertUV?: boolean;
  49442. }, scene?: Nullable<Scene>): Mesh;
  49443. /**
  49444. * Creates an custom extruded shape mesh.
  49445. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49446. * * 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.
  49447. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49448. * * 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
  49449. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49450. * * 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
  49451. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49452. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49453. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49454. * * 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
  49455. * * 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
  49456. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49457. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49458. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49459. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49460. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49461. * @param name defines the name of the mesh
  49462. * @param options defines the options used to create the mesh
  49463. * @param scene defines the hosting scene
  49464. * @returns the custom extruded shape mesh
  49465. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49466. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49467. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49468. */
  49469. static ExtrudeShapeCustom(name: string, options: {
  49470. shape: Vector3[];
  49471. path: Vector3[];
  49472. scaleFunction?: any;
  49473. rotationFunction?: any;
  49474. ribbonCloseArray?: boolean;
  49475. ribbonClosePath?: boolean;
  49476. cap?: number;
  49477. updatable?: boolean;
  49478. sideOrientation?: number;
  49479. frontUVs?: Vector4;
  49480. backUVs?: Vector4;
  49481. instance?: Mesh;
  49482. invertUV?: boolean;
  49483. }, scene: Scene): Mesh;
  49484. private static _ExtrudeShapeGeneric;
  49485. }
  49486. }
  49487. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  49488. import { Scene } from "babylonjs/scene";
  49489. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  49490. import { Mesh } from "babylonjs/Meshes/mesh";
  49491. /**
  49492. * Class containing static functions to help procedurally build meshes
  49493. */
  49494. export class LatheBuilder {
  49495. /**
  49496. * Creates lathe mesh.
  49497. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  49498. * * 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
  49499. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  49500. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  49501. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  49502. * * 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
  49503. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  49504. * * 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
  49505. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49506. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49507. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49508. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49509. * @param name defines the name of the mesh
  49510. * @param options defines the options used to create the mesh
  49511. * @param scene defines the hosting scene
  49512. * @returns the lathe mesh
  49513. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  49514. */
  49515. static CreateLathe(name: string, options: {
  49516. shape: Vector3[];
  49517. radius?: number;
  49518. tessellation?: number;
  49519. clip?: number;
  49520. arc?: number;
  49521. closed?: boolean;
  49522. updatable?: boolean;
  49523. sideOrientation?: number;
  49524. frontUVs?: Vector4;
  49525. backUVs?: Vector4;
  49526. cap?: number;
  49527. invertUV?: boolean;
  49528. }, scene: Scene): Mesh;
  49529. }
  49530. }
  49531. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  49532. import { Scene } from "babylonjs/scene";
  49533. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  49534. import { Mesh } from "babylonjs/Meshes/mesh";
  49535. /**
  49536. * Class containing static functions to help procedurally build meshes
  49537. */
  49538. export class TubeBuilder {
  49539. /**
  49540. * Creates a tube mesh.
  49541. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49542. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  49543. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  49544. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  49545. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  49546. * * 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)
  49547. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  49548. * * 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
  49549. * * 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
  49550. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49551. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49552. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49553. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49554. * @param name defines the name of the mesh
  49555. * @param options defines the options used to create the mesh
  49556. * @param scene defines the hosting scene
  49557. * @returns the tube mesh
  49558. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49559. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  49560. */
  49561. static CreateTube(name: string, options: {
  49562. path: Vector3[];
  49563. radius?: number;
  49564. tessellation?: number;
  49565. radiusFunction?: {
  49566. (i: number, distance: number): number;
  49567. };
  49568. cap?: number;
  49569. arc?: number;
  49570. updatable?: boolean;
  49571. sideOrientation?: number;
  49572. frontUVs?: Vector4;
  49573. backUVs?: Vector4;
  49574. instance?: Mesh;
  49575. invertUV?: boolean;
  49576. }, scene: Scene): Mesh;
  49577. }
  49578. }
  49579. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  49580. import { Scene } from "babylonjs/scene";
  49581. import { Vector4 } from "babylonjs/Maths/math";
  49582. import { Mesh } from "babylonjs/Meshes/mesh";
  49583. /**
  49584. * Class containing static functions to help procedurally build meshes
  49585. */
  49586. export class IcoSphereBuilder {
  49587. /**
  49588. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  49589. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  49590. * * 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`)
  49591. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  49592. * * 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
  49593. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49594. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49595. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49596. * @param name defines the name of the mesh
  49597. * @param options defines the options used to create the mesh
  49598. * @param scene defines the hosting scene
  49599. * @returns the icosahedron mesh
  49600. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  49601. */
  49602. static CreateIcoSphere(name: string, options: {
  49603. radius?: number;
  49604. radiusX?: number;
  49605. radiusY?: number;
  49606. radiusZ?: number;
  49607. flat?: boolean;
  49608. subdivisions?: number;
  49609. sideOrientation?: number;
  49610. frontUVs?: Vector4;
  49611. backUVs?: Vector4;
  49612. updatable?: boolean;
  49613. }, scene: Scene): Mesh;
  49614. }
  49615. }
  49616. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  49617. import { Vector3 } from "babylonjs/Maths/math";
  49618. import { Mesh } from "babylonjs/Meshes/mesh";
  49619. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49620. /**
  49621. * Class containing static functions to help procedurally build meshes
  49622. */
  49623. export class DecalBuilder {
  49624. /**
  49625. * Creates a decal mesh.
  49626. * 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
  49627. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  49628. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  49629. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  49630. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  49631. * @param name defines the name of the mesh
  49632. * @param sourceMesh defines the mesh where the decal must be applied
  49633. * @param options defines the options used to create the mesh
  49634. * @param scene defines the hosting scene
  49635. * @returns the decal mesh
  49636. * @see https://doc.babylonjs.com/how_to/decals
  49637. */
  49638. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  49639. position?: Vector3;
  49640. normal?: Vector3;
  49641. size?: Vector3;
  49642. angle?: number;
  49643. }): Mesh;
  49644. }
  49645. }
  49646. declare module "babylonjs/Meshes/meshBuilder" {
  49647. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  49648. import { Nullable } from "babylonjs/types";
  49649. import { Scene } from "babylonjs/scene";
  49650. import { Mesh } from "babylonjs/Meshes/mesh";
  49651. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  49652. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  49653. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49654. /**
  49655. * Class containing static functions to help procedurally build meshes
  49656. */
  49657. export class MeshBuilder {
  49658. /**
  49659. * Creates a box mesh
  49660. * * The parameter `size` sets the size (float) of each box side (default 1)
  49661. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  49662. * * 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)
  49663. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49664. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49665. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49666. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49667. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  49668. * @param name defines the name of the mesh
  49669. * @param options defines the options used to create the mesh
  49670. * @param scene defines the hosting scene
  49671. * @returns the box mesh
  49672. */
  49673. static CreateBox(name: string, options: {
  49674. size?: number;
  49675. width?: number;
  49676. height?: number;
  49677. depth?: number;
  49678. faceUV?: Vector4[];
  49679. faceColors?: Color4[];
  49680. sideOrientation?: number;
  49681. frontUVs?: Vector4;
  49682. backUVs?: Vector4;
  49683. updatable?: boolean;
  49684. }, scene?: Nullable<Scene>): Mesh;
  49685. /**
  49686. * Creates a sphere mesh
  49687. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  49688. * * 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`)
  49689. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  49690. * * 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
  49691. * * 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)
  49692. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49693. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49694. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49695. * @param name defines the name of the mesh
  49696. * @param options defines the options used to create the mesh
  49697. * @param scene defines the hosting scene
  49698. * @returns the sphere mesh
  49699. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  49700. */
  49701. static CreateSphere(name: string, options: {
  49702. segments?: number;
  49703. diameter?: number;
  49704. diameterX?: number;
  49705. diameterY?: number;
  49706. diameterZ?: number;
  49707. arc?: number;
  49708. slice?: number;
  49709. sideOrientation?: number;
  49710. frontUVs?: Vector4;
  49711. backUVs?: Vector4;
  49712. updatable?: boolean;
  49713. }, scene: any): Mesh;
  49714. /**
  49715. * Creates a plane polygonal mesh. By default, this is a disc
  49716. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  49717. * * 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
  49718. * * 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
  49719. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49720. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49721. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49722. * @param name defines the name of the mesh
  49723. * @param options defines the options used to create the mesh
  49724. * @param scene defines the hosting scene
  49725. * @returns the plane polygonal mesh
  49726. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  49727. */
  49728. static CreateDisc(name: string, options: {
  49729. radius?: number;
  49730. tessellation?: number;
  49731. arc?: number;
  49732. updatable?: boolean;
  49733. sideOrientation?: number;
  49734. frontUVs?: Vector4;
  49735. backUVs?: Vector4;
  49736. }, scene?: Nullable<Scene>): Mesh;
  49737. /**
  49738. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  49739. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  49740. * * 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`)
  49741. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  49742. * * 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
  49743. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49744. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49745. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49746. * @param name defines the name of the mesh
  49747. * @param options defines the options used to create the mesh
  49748. * @param scene defines the hosting scene
  49749. * @returns the icosahedron mesh
  49750. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  49751. */
  49752. static CreateIcoSphere(name: string, options: {
  49753. radius?: number;
  49754. radiusX?: number;
  49755. radiusY?: number;
  49756. radiusZ?: number;
  49757. flat?: boolean;
  49758. subdivisions?: number;
  49759. sideOrientation?: number;
  49760. frontUVs?: Vector4;
  49761. backUVs?: Vector4;
  49762. updatable?: boolean;
  49763. }, scene: Scene): Mesh;
  49764. /**
  49765. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49766. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49767. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49768. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49769. * * 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
  49770. * * 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
  49771. * * 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
  49772. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49773. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49774. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49775. * * 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
  49776. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49777. * * 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
  49778. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49779. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49780. * @param name defines the name of the mesh
  49781. * @param options defines the options used to create the mesh
  49782. * @param scene defines the hosting scene
  49783. * @returns the ribbon mesh
  49784. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49785. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49786. */
  49787. static CreateRibbon(name: string, options: {
  49788. pathArray: Vector3[][];
  49789. closeArray?: boolean;
  49790. closePath?: boolean;
  49791. offset?: number;
  49792. updatable?: boolean;
  49793. sideOrientation?: number;
  49794. frontUVs?: Vector4;
  49795. backUVs?: Vector4;
  49796. instance?: Mesh;
  49797. invertUV?: boolean;
  49798. uvs?: Vector2[];
  49799. colors?: Color4[];
  49800. }, scene?: Nullable<Scene>): Mesh;
  49801. /**
  49802. * Creates a cylinder or a cone mesh
  49803. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  49804. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  49805. * * 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.
  49806. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  49807. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  49808. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  49809. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  49810. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  49811. * * 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).
  49812. * * 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
  49813. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  49814. * * 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
  49815. * * 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.
  49816. * * If `enclose` is false, a ring surface is one element.
  49817. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  49818. * * 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
  49819. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49820. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49821. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49822. * @param name defines the name of the mesh
  49823. * @param options defines the options used to create the mesh
  49824. * @param scene defines the hosting scene
  49825. * @returns the cylinder mesh
  49826. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  49827. */
  49828. static CreateCylinder(name: string, options: {
  49829. height?: number;
  49830. diameterTop?: number;
  49831. diameterBottom?: number;
  49832. diameter?: number;
  49833. tessellation?: number;
  49834. subdivisions?: number;
  49835. arc?: number;
  49836. faceColors?: Color4[];
  49837. faceUV?: Vector4[];
  49838. updatable?: boolean;
  49839. hasRings?: boolean;
  49840. enclose?: boolean;
  49841. sideOrientation?: number;
  49842. frontUVs?: Vector4;
  49843. backUVs?: Vector4;
  49844. }, scene: any): Mesh;
  49845. /**
  49846. * Creates a torus mesh
  49847. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  49848. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  49849. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  49850. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49851. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49852. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49853. * @param name defines the name of the mesh
  49854. * @param options defines the options used to create the mesh
  49855. * @param scene defines the hosting scene
  49856. * @returns the torus mesh
  49857. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  49858. */
  49859. static CreateTorus(name: string, options: {
  49860. diameter?: number;
  49861. thickness?: number;
  49862. tessellation?: number;
  49863. updatable?: boolean;
  49864. sideOrientation?: number;
  49865. frontUVs?: Vector4;
  49866. backUVs?: Vector4;
  49867. }, scene: any): Mesh;
  49868. /**
  49869. * Creates a torus knot mesh
  49870. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  49871. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  49872. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  49873. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  49874. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49875. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49876. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49877. * @param name defines the name of the mesh
  49878. * @param options defines the options used to create the mesh
  49879. * @param scene defines the hosting scene
  49880. * @returns the torus knot mesh
  49881. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  49882. */
  49883. static CreateTorusKnot(name: string, options: {
  49884. radius?: number;
  49885. tube?: number;
  49886. radialSegments?: number;
  49887. tubularSegments?: number;
  49888. p?: number;
  49889. q?: number;
  49890. updatable?: boolean;
  49891. sideOrientation?: number;
  49892. frontUVs?: Vector4;
  49893. backUVs?: Vector4;
  49894. }, scene: any): Mesh;
  49895. /**
  49896. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49897. * * 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
  49898. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49899. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49900. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49901. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49902. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49903. * * 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
  49904. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  49905. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49906. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  49907. * @param name defines the name of the new line system
  49908. * @param options defines the options used to create the line system
  49909. * @param scene defines the hosting scene
  49910. * @returns a new line system mesh
  49911. */
  49912. static CreateLineSystem(name: string, options: {
  49913. lines: Vector3[][];
  49914. updatable?: boolean;
  49915. instance?: Nullable<LinesMesh>;
  49916. colors?: Nullable<Color4[][]>;
  49917. useVertexAlpha?: boolean;
  49918. }, scene: Nullable<Scene>): LinesMesh;
  49919. /**
  49920. * Creates a line mesh
  49921. * 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
  49922. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49923. * * The parameter `points` is an array successive Vector3
  49924. * * 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
  49925. * * The optional parameter `colors` is an array of successive Color4, one per line point
  49926. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  49927. * * When updating an instance, remember that only point positions can change, not the number of points
  49928. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49929. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  49930. * @param name defines the name of the new line system
  49931. * @param options defines the options used to create the line system
  49932. * @param scene defines the hosting scene
  49933. * @returns a new line mesh
  49934. */
  49935. static CreateLines(name: string, options: {
  49936. points: Vector3[];
  49937. updatable?: boolean;
  49938. instance?: Nullable<LinesMesh>;
  49939. colors?: Color4[];
  49940. useVertexAlpha?: boolean;
  49941. }, scene?: Nullable<Scene>): LinesMesh;
  49942. /**
  49943. * Creates a dashed line mesh
  49944. * * 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
  49945. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49946. * * The parameter `points` is an array successive Vector3
  49947. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  49948. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  49949. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  49950. * * 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
  49951. * * When updating an instance, remember that only point positions can change, not the number of points
  49952. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49953. * @param name defines the name of the mesh
  49954. * @param options defines the options used to create the mesh
  49955. * @param scene defines the hosting scene
  49956. * @returns the dashed line mesh
  49957. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  49958. */
  49959. static CreateDashedLines(name: string, options: {
  49960. points: Vector3[];
  49961. dashSize?: number;
  49962. gapSize?: number;
  49963. dashNb?: number;
  49964. updatable?: boolean;
  49965. instance?: LinesMesh;
  49966. }, scene?: Nullable<Scene>): LinesMesh;
  49967. /**
  49968. * 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.
  49969. * * 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.
  49970. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49971. * * 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.
  49972. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49973. * * 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
  49974. * * 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
  49975. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49976. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49977. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49978. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49979. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49980. * @param name defines the name of the mesh
  49981. * @param options defines the options used to create the mesh
  49982. * @param scene defines the hosting scene
  49983. * @returns the extruded shape mesh
  49984. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49985. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49986. */
  49987. static ExtrudeShape(name: string, options: {
  49988. shape: Vector3[];
  49989. path: Vector3[];
  49990. scale?: number;
  49991. rotation?: number;
  49992. cap?: number;
  49993. updatable?: boolean;
  49994. sideOrientation?: number;
  49995. frontUVs?: Vector4;
  49996. backUVs?: Vector4;
  49997. instance?: Mesh;
  49998. invertUV?: boolean;
  49999. }, scene?: Nullable<Scene>): Mesh;
  50000. /**
  50001. * Creates an custom extruded shape mesh.
  50002. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50003. * * 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.
  50004. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50005. * * 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
  50006. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50007. * * 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
  50008. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50009. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50010. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50011. * * 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
  50012. * * 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
  50013. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50014. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50015. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50016. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50017. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50018. * @param name defines the name of the mesh
  50019. * @param options defines the options used to create the mesh
  50020. * @param scene defines the hosting scene
  50021. * @returns the custom extruded shape mesh
  50022. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50023. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50024. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50025. */
  50026. static ExtrudeShapeCustom(name: string, options: {
  50027. shape: Vector3[];
  50028. path: Vector3[];
  50029. scaleFunction?: any;
  50030. rotationFunction?: any;
  50031. ribbonCloseArray?: boolean;
  50032. ribbonClosePath?: boolean;
  50033. cap?: number;
  50034. updatable?: boolean;
  50035. sideOrientation?: number;
  50036. frontUVs?: Vector4;
  50037. backUVs?: Vector4;
  50038. instance?: Mesh;
  50039. invertUV?: boolean;
  50040. }, scene: Scene): Mesh;
  50041. /**
  50042. * Creates lathe mesh.
  50043. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  50044. * * 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
  50045. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  50046. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  50047. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  50048. * * 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
  50049. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  50050. * * 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
  50051. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50052. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50053. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50054. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50055. * @param name defines the name of the mesh
  50056. * @param options defines the options used to create the mesh
  50057. * @param scene defines the hosting scene
  50058. * @returns the lathe mesh
  50059. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  50060. */
  50061. static CreateLathe(name: string, options: {
  50062. shape: Vector3[];
  50063. radius?: number;
  50064. tessellation?: number;
  50065. clip?: number;
  50066. arc?: number;
  50067. closed?: boolean;
  50068. updatable?: boolean;
  50069. sideOrientation?: number;
  50070. frontUVs?: Vector4;
  50071. backUVs?: Vector4;
  50072. cap?: number;
  50073. invertUV?: boolean;
  50074. }, scene: Scene): Mesh;
  50075. /**
  50076. * Creates a plane mesh
  50077. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  50078. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  50079. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  50080. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50081. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50082. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50083. * @param name defines the name of the mesh
  50084. * @param options defines the options used to create the mesh
  50085. * @param scene defines the hosting scene
  50086. * @returns the plane mesh
  50087. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  50088. */
  50089. static CreatePlane(name: string, options: {
  50090. size?: number;
  50091. width?: number;
  50092. height?: number;
  50093. sideOrientation?: number;
  50094. frontUVs?: Vector4;
  50095. backUVs?: Vector4;
  50096. updatable?: boolean;
  50097. sourcePlane?: Plane;
  50098. }, scene: Scene): Mesh;
  50099. /**
  50100. * Creates a ground mesh
  50101. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  50102. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  50103. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50104. * @param name defines the name of the mesh
  50105. * @param options defines the options used to create the mesh
  50106. * @param scene defines the hosting scene
  50107. * @returns the ground mesh
  50108. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  50109. */
  50110. static CreateGround(name: string, options: {
  50111. width?: number;
  50112. height?: number;
  50113. subdivisions?: number;
  50114. subdivisionsX?: number;
  50115. subdivisionsY?: number;
  50116. updatable?: boolean;
  50117. }, scene: any): Mesh;
  50118. /**
  50119. * Creates a tiled ground mesh
  50120. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  50121. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  50122. * * 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
  50123. * * 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
  50124. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50125. * @param name defines the name of the mesh
  50126. * @param options defines the options used to create the mesh
  50127. * @param scene defines the hosting scene
  50128. * @returns the tiled ground mesh
  50129. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  50130. */
  50131. static CreateTiledGround(name: string, options: {
  50132. xmin: number;
  50133. zmin: number;
  50134. xmax: number;
  50135. zmax: number;
  50136. subdivisions?: {
  50137. w: number;
  50138. h: number;
  50139. };
  50140. precision?: {
  50141. w: number;
  50142. h: number;
  50143. };
  50144. updatable?: boolean;
  50145. }, scene: Scene): Mesh;
  50146. /**
  50147. * Creates a ground mesh from a height map
  50148. * * The parameter `url` sets the URL of the height map image resource.
  50149. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  50150. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  50151. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  50152. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  50153. * * 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.
  50154. * * 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).
  50155. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  50156. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50157. * @param name defines the name of the mesh
  50158. * @param url defines the url to the height map
  50159. * @param options defines the options used to create the mesh
  50160. * @param scene defines the hosting scene
  50161. * @returns the ground mesh
  50162. * @see https://doc.babylonjs.com/babylon101/height_map
  50163. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  50164. */
  50165. static CreateGroundFromHeightMap(name: string, url: string, options: {
  50166. width?: number;
  50167. height?: number;
  50168. subdivisions?: number;
  50169. minHeight?: number;
  50170. maxHeight?: number;
  50171. colorFilter?: Color3;
  50172. alphaFilter?: number;
  50173. updatable?: boolean;
  50174. onReady?: (mesh: GroundMesh) => void;
  50175. }, scene: Scene): GroundMesh;
  50176. /**
  50177. * Creates a polygon mesh
  50178. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50179. * * 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
  50180. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50181. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50182. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  50183. * * Remember you can only change the shape positions, not their number when updating a polygon
  50184. * @param name defines the name of the mesh
  50185. * @param options defines the options used to create the mesh
  50186. * @param scene defines the hosting scene
  50187. * @param earcutInjection can be used to inject your own earcut reference
  50188. * @returns the polygon mesh
  50189. */
  50190. static CreatePolygon(name: string, options: {
  50191. shape: Vector3[];
  50192. holes?: Vector3[][];
  50193. depth?: number;
  50194. faceUV?: Vector4[];
  50195. faceColors?: Color4[];
  50196. updatable?: boolean;
  50197. sideOrientation?: number;
  50198. frontUVs?: Vector4;
  50199. backUVs?: Vector4;
  50200. }, scene: Scene, earcutInjection?: any): Mesh;
  50201. /**
  50202. * Creates an extruded polygon mesh, with depth in the Y direction.
  50203. * * 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)
  50204. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50205. * @param name defines the name of the mesh
  50206. * @param options defines the options used to create the mesh
  50207. * @param scene defines the hosting scene
  50208. * @param earcutInjection can be used to inject your own earcut reference
  50209. * @returns the polygon mesh
  50210. */
  50211. static ExtrudePolygon(name: string, options: {
  50212. shape: Vector3[];
  50213. holes?: Vector3[][];
  50214. depth?: number;
  50215. faceUV?: Vector4[];
  50216. faceColors?: Color4[];
  50217. updatable?: boolean;
  50218. sideOrientation?: number;
  50219. frontUVs?: Vector4;
  50220. backUVs?: Vector4;
  50221. }, scene: Scene, earcutInjection?: any): Mesh;
  50222. /**
  50223. * Creates a tube mesh.
  50224. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50225. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50226. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50227. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50228. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50229. * * 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)
  50230. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50231. * * 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
  50232. * * 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
  50233. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50234. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50235. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50236. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50237. * @param name defines the name of the mesh
  50238. * @param options defines the options used to create the mesh
  50239. * @param scene defines the hosting scene
  50240. * @returns the tube mesh
  50241. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50242. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50243. */
  50244. static CreateTube(name: string, options: {
  50245. path: Vector3[];
  50246. radius?: number;
  50247. tessellation?: number;
  50248. radiusFunction?: {
  50249. (i: number, distance: number): number;
  50250. };
  50251. cap?: number;
  50252. arc?: number;
  50253. updatable?: boolean;
  50254. sideOrientation?: number;
  50255. frontUVs?: Vector4;
  50256. backUVs?: Vector4;
  50257. instance?: Mesh;
  50258. invertUV?: boolean;
  50259. }, scene: Scene): Mesh;
  50260. /**
  50261. * Creates a polyhedron mesh
  50262. * * 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
  50263. * * The parameter `size` (positive float, default 1) sets the polygon size
  50264. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50265. * * 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`
  50266. * * 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
  50267. * * 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)`)
  50268. * * 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
  50269. * * 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
  50270. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50271. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50272. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50273. * @param name defines the name of the mesh
  50274. * @param options defines the options used to create the mesh
  50275. * @param scene defines the hosting scene
  50276. * @returns the polyhedron mesh
  50277. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50278. */
  50279. static CreatePolyhedron(name: string, options: {
  50280. type?: number;
  50281. size?: number;
  50282. sizeX?: number;
  50283. sizeY?: number;
  50284. sizeZ?: number;
  50285. custom?: any;
  50286. faceUV?: Vector4[];
  50287. faceColors?: Color4[];
  50288. flat?: boolean;
  50289. updatable?: boolean;
  50290. sideOrientation?: number;
  50291. frontUVs?: Vector4;
  50292. backUVs?: Vector4;
  50293. }, scene: Scene): Mesh;
  50294. /**
  50295. * Creates a decal mesh.
  50296. * 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
  50297. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50298. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50299. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50300. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50301. * @param name defines the name of the mesh
  50302. * @param sourceMesh defines the mesh where the decal must be applied
  50303. * @param options defines the options used to create the mesh
  50304. * @param scene defines the hosting scene
  50305. * @returns the decal mesh
  50306. * @see https://doc.babylonjs.com/how_to/decals
  50307. */
  50308. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50309. position?: Vector3;
  50310. normal?: Vector3;
  50311. size?: Vector3;
  50312. angle?: number;
  50313. }): Mesh;
  50314. }
  50315. }
  50316. declare module "babylonjs/Meshes/meshSimplification" {
  50317. import { Mesh } from "babylonjs/Meshes/mesh";
  50318. /**
  50319. * A simplifier interface for future simplification implementations
  50320. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50321. */
  50322. export interface ISimplifier {
  50323. /**
  50324. * Simplification of a given mesh according to the given settings.
  50325. * Since this requires computation, it is assumed that the function runs async.
  50326. * @param settings The settings of the simplification, including quality and distance
  50327. * @param successCallback A callback that will be called after the mesh was simplified.
  50328. * @param errorCallback in case of an error, this callback will be called. optional.
  50329. */
  50330. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  50331. }
  50332. /**
  50333. * Expected simplification settings.
  50334. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  50335. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50336. */
  50337. export interface ISimplificationSettings {
  50338. /**
  50339. * Gets or sets the expected quality
  50340. */
  50341. quality: number;
  50342. /**
  50343. * Gets or sets the distance when this optimized version should be used
  50344. */
  50345. distance: number;
  50346. /**
  50347. * Gets an already optimized mesh
  50348. */
  50349. optimizeMesh?: boolean;
  50350. }
  50351. /**
  50352. * Class used to specify simplification options
  50353. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50354. */
  50355. export class SimplificationSettings implements ISimplificationSettings {
  50356. /** expected quality */
  50357. quality: number;
  50358. /** distance when this optimized version should be used */
  50359. distance: number;
  50360. /** already optimized mesh */
  50361. optimizeMesh?: boolean | undefined;
  50362. /**
  50363. * Creates a SimplificationSettings
  50364. * @param quality expected quality
  50365. * @param distance distance when this optimized version should be used
  50366. * @param optimizeMesh already optimized mesh
  50367. */
  50368. constructor(
  50369. /** expected quality */
  50370. quality: number,
  50371. /** distance when this optimized version should be used */
  50372. distance: number,
  50373. /** already optimized mesh */
  50374. optimizeMesh?: boolean | undefined);
  50375. }
  50376. /**
  50377. * Interface used to define a simplification task
  50378. */
  50379. export interface ISimplificationTask {
  50380. /**
  50381. * Array of settings
  50382. */
  50383. settings: Array<ISimplificationSettings>;
  50384. /**
  50385. * Simplification type
  50386. */
  50387. simplificationType: SimplificationType;
  50388. /**
  50389. * Mesh to simplify
  50390. */
  50391. mesh: Mesh;
  50392. /**
  50393. * Callback called on success
  50394. */
  50395. successCallback?: () => void;
  50396. /**
  50397. * Defines if parallel processing can be used
  50398. */
  50399. parallelProcessing: boolean;
  50400. }
  50401. /**
  50402. * Queue used to order the simplification tasks
  50403. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50404. */
  50405. export class SimplificationQueue {
  50406. private _simplificationArray;
  50407. /**
  50408. * Gets a boolean indicating that the process is still running
  50409. */
  50410. running: boolean;
  50411. /**
  50412. * Creates a new queue
  50413. */
  50414. constructor();
  50415. /**
  50416. * Adds a new simplification task
  50417. * @param task defines a task to add
  50418. */
  50419. addTask(task: ISimplificationTask): void;
  50420. /**
  50421. * Execute next task
  50422. */
  50423. executeNext(): void;
  50424. /**
  50425. * Execute a simplification task
  50426. * @param task defines the task to run
  50427. */
  50428. runSimplification(task: ISimplificationTask): void;
  50429. private getSimplifier;
  50430. }
  50431. /**
  50432. * The implemented types of simplification
  50433. * At the moment only Quadratic Error Decimation is implemented
  50434. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50435. */
  50436. export enum SimplificationType {
  50437. /** Quadratic error decimation */
  50438. QUADRATIC = 0
  50439. }
  50440. }
  50441. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  50442. import { Scene } from "babylonjs/scene";
  50443. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  50444. import { ISceneComponent } from "babylonjs/sceneComponent";
  50445. module "babylonjs/scene" {
  50446. interface Scene {
  50447. /** @hidden (Backing field) */
  50448. _simplificationQueue: SimplificationQueue;
  50449. /**
  50450. * Gets or sets the simplification queue attached to the scene
  50451. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50452. */
  50453. simplificationQueue: SimplificationQueue;
  50454. }
  50455. }
  50456. module "babylonjs/Meshes/mesh" {
  50457. interface Mesh {
  50458. /**
  50459. * Simplify the mesh according to the given array of settings.
  50460. * Function will return immediately and will simplify async
  50461. * @param settings a collection of simplification settings
  50462. * @param parallelProcessing should all levels calculate parallel or one after the other
  50463. * @param simplificationType the type of simplification to run
  50464. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  50465. * @returns the current mesh
  50466. */
  50467. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  50468. }
  50469. }
  50470. /**
  50471. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  50472. * created in a scene
  50473. */
  50474. export class SimplicationQueueSceneComponent implements ISceneComponent {
  50475. /**
  50476. * The component name helpfull to identify the component in the list of scene components.
  50477. */
  50478. readonly name: string;
  50479. /**
  50480. * The scene the component belongs to.
  50481. */
  50482. scene: Scene;
  50483. /**
  50484. * Creates a new instance of the component for the given scene
  50485. * @param scene Defines the scene to register the component in
  50486. */
  50487. constructor(scene: Scene);
  50488. /**
  50489. * Registers the component in a given scene
  50490. */
  50491. register(): void;
  50492. /**
  50493. * Rebuilds the elements related to this component in case of
  50494. * context lost for instance.
  50495. */
  50496. rebuild(): void;
  50497. /**
  50498. * Disposes the component and the associated ressources
  50499. */
  50500. dispose(): void;
  50501. private _beforeCameraUpdate;
  50502. }
  50503. }
  50504. declare module "babylonjs/Meshes/Builders/index" {
  50505. export * from "babylonjs/Meshes/Builders/boxBuilder";
  50506. export * from "babylonjs/Meshes/Builders/discBuilder";
  50507. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  50508. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  50509. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  50510. export * from "babylonjs/Meshes/Builders/torusBuilder";
  50511. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  50512. export * from "babylonjs/Meshes/Builders/linesBuilder";
  50513. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  50514. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  50515. export * from "babylonjs/Meshes/Builders/latheBuilder";
  50516. export * from "babylonjs/Meshes/Builders/planeBuilder";
  50517. export * from "babylonjs/Meshes/Builders/groundBuilder";
  50518. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  50519. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  50520. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  50521. export * from "babylonjs/Meshes/Builders/decalBuilder";
  50522. }
  50523. declare module "babylonjs/Meshes/index" {
  50524. export * from "babylonjs/Meshes/abstractMesh";
  50525. export * from "babylonjs/Meshes/buffer";
  50526. export * from "babylonjs/Meshes/Compression/index";
  50527. export * from "babylonjs/Meshes/csg";
  50528. export * from "babylonjs/Meshes/geometry";
  50529. export * from "babylonjs/Meshes/groundMesh";
  50530. export * from "babylonjs/Meshes/trailMesh";
  50531. export * from "babylonjs/Meshes/instancedMesh";
  50532. export * from "babylonjs/Meshes/linesMesh";
  50533. export * from "babylonjs/Meshes/mesh";
  50534. export * from "babylonjs/Meshes/mesh.vertexData";
  50535. export * from "babylonjs/Meshes/meshBuilder";
  50536. export * from "babylonjs/Meshes/meshSimplification";
  50537. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  50538. export * from "babylonjs/Meshes/polygonMesh";
  50539. export * from "babylonjs/Meshes/subMesh";
  50540. export * from "babylonjs/Meshes/transformNode";
  50541. export * from "babylonjs/Meshes/Builders/index";
  50542. }
  50543. declare module "babylonjs/Morph/index" {
  50544. export * from "babylonjs/Morph/morphTarget";
  50545. export * from "babylonjs/Morph/morphTargetManager";
  50546. }
  50547. declare module "babylonjs/Offline/database" {
  50548. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  50549. /**
  50550. * Class used to enable access to IndexedDB
  50551. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  50552. */
  50553. export class Database implements IOfflineProvider {
  50554. private _callbackManifestChecked;
  50555. private _currentSceneUrl;
  50556. private _db;
  50557. private _enableSceneOffline;
  50558. private _enableTexturesOffline;
  50559. private _manifestVersionFound;
  50560. private _mustUpdateRessources;
  50561. private _hasReachedQuota;
  50562. private _isSupported;
  50563. private _idbFactory;
  50564. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  50565. private static IsUASupportingBlobStorage;
  50566. /**
  50567. * Gets a boolean indicating if Database storate is enabled (off by default)
  50568. */
  50569. static IDBStorageEnabled: boolean;
  50570. /**
  50571. * Gets a boolean indicating if scene must be saved in the database
  50572. */
  50573. readonly enableSceneOffline: boolean;
  50574. /**
  50575. * Gets a boolean indicating if textures must be saved in the database
  50576. */
  50577. readonly enableTexturesOffline: boolean;
  50578. /**
  50579. * Creates a new Database
  50580. * @param urlToScene defines the url to load the scene
  50581. * @param callbackManifestChecked defines the callback to use when manifest is checked
  50582. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  50583. */
  50584. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  50585. private static _ParseURL;
  50586. private static _ReturnFullUrlLocation;
  50587. private _checkManifestFile;
  50588. /**
  50589. * Open the database and make it available
  50590. * @param successCallback defines the callback to call on success
  50591. * @param errorCallback defines the callback to call on error
  50592. */
  50593. open(successCallback: () => void, errorCallback: () => void): void;
  50594. /**
  50595. * Loads an image from the database
  50596. * @param url defines the url to load from
  50597. * @param image defines the target DOM image
  50598. */
  50599. loadImage(url: string, image: HTMLImageElement): void;
  50600. private _loadImageFromDBAsync;
  50601. private _saveImageIntoDBAsync;
  50602. private _checkVersionFromDB;
  50603. private _loadVersionFromDBAsync;
  50604. private _saveVersionIntoDBAsync;
  50605. /**
  50606. * Loads a file from database
  50607. * @param url defines the URL to load from
  50608. * @param sceneLoaded defines a callback to call on success
  50609. * @param progressCallBack defines a callback to call when progress changed
  50610. * @param errorCallback defines a callback to call on error
  50611. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  50612. */
  50613. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  50614. private _loadFileAsync;
  50615. private _saveFileAsync;
  50616. /**
  50617. * Validates if xhr data is correct
  50618. * @param xhr defines the request to validate
  50619. * @param dataType defines the expected data type
  50620. * @returns true if data is correct
  50621. */
  50622. private static _ValidateXHRData;
  50623. }
  50624. }
  50625. declare module "babylonjs/Offline/index" {
  50626. export * from "babylonjs/Offline/database";
  50627. export * from "babylonjs/Offline/IOfflineProvider";
  50628. }
  50629. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  50630. /** @hidden */
  50631. export var gpuUpdateParticlesPixelShader: {
  50632. name: string;
  50633. shader: string;
  50634. };
  50635. }
  50636. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  50637. /** @hidden */
  50638. export var gpuUpdateParticlesVertexShader: {
  50639. name: string;
  50640. shader: string;
  50641. };
  50642. }
  50643. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  50644. /** @hidden */
  50645. export var clipPlaneFragmentDeclaration2: {
  50646. name: string;
  50647. shader: string;
  50648. };
  50649. }
  50650. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  50651. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  50652. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  50653. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50654. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  50655. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  50656. /** @hidden */
  50657. export var gpuRenderParticlesPixelShader: {
  50658. name: string;
  50659. shader: string;
  50660. };
  50661. }
  50662. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  50663. /** @hidden */
  50664. export var clipPlaneVertexDeclaration2: {
  50665. name: string;
  50666. shader: string;
  50667. };
  50668. }
  50669. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  50670. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  50671. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  50672. /** @hidden */
  50673. export var gpuRenderParticlesVertexShader: {
  50674. name: string;
  50675. shader: string;
  50676. };
  50677. }
  50678. declare module "babylonjs/Particles/gpuParticleSystem" {
  50679. import { Nullable } from "babylonjs/types";
  50680. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  50681. import { Observable } from "babylonjs/Misc/observable";
  50682. import { Color4, Color3 } from "babylonjs/Maths/math";
  50683. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  50684. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  50685. import { Scene, IDisposable } from "babylonjs/scene";
  50686. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  50687. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  50688. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  50689. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  50690. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  50691. /**
  50692. * This represents a GPU particle system in Babylon
  50693. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  50694. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  50695. */
  50696. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  50697. /**
  50698. * The layer mask we are rendering the particles through.
  50699. */
  50700. layerMask: number;
  50701. private _capacity;
  50702. private _activeCount;
  50703. private _currentActiveCount;
  50704. private _accumulatedCount;
  50705. private _renderEffect;
  50706. private _updateEffect;
  50707. private _buffer0;
  50708. private _buffer1;
  50709. private _spriteBuffer;
  50710. private _updateVAO;
  50711. private _renderVAO;
  50712. private _targetIndex;
  50713. private _sourceBuffer;
  50714. private _targetBuffer;
  50715. private _engine;
  50716. private _currentRenderId;
  50717. private _started;
  50718. private _stopped;
  50719. private _timeDelta;
  50720. private _randomTexture;
  50721. private _randomTexture2;
  50722. private _attributesStrideSize;
  50723. private _updateEffectOptions;
  50724. private _randomTextureSize;
  50725. private _actualFrame;
  50726. private readonly _rawTextureWidth;
  50727. /**
  50728. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  50729. */
  50730. static readonly IsSupported: boolean;
  50731. /**
  50732. * An event triggered when the system is disposed.
  50733. */
  50734. onDisposeObservable: Observable<GPUParticleSystem>;
  50735. /**
  50736. * Gets the maximum number of particles active at the same time.
  50737. * @returns The max number of active particles.
  50738. */
  50739. getCapacity(): number;
  50740. /**
  50741. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  50742. * to override the particles.
  50743. */
  50744. forceDepthWrite: boolean;
  50745. /**
  50746. * Gets or set the number of active particles
  50747. */
  50748. activeParticleCount: number;
  50749. private _preWarmDone;
  50750. /**
  50751. * Is this system ready to be used/rendered
  50752. * @return true if the system is ready
  50753. */
  50754. isReady(): boolean;
  50755. /**
  50756. * Gets if the system has been started. (Note: this will still be true after stop is called)
  50757. * @returns True if it has been started, otherwise false.
  50758. */
  50759. isStarted(): boolean;
  50760. /**
  50761. * Starts the particle system and begins to emit
  50762. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  50763. */
  50764. start(delay?: number): void;
  50765. /**
  50766. * Stops the particle system.
  50767. */
  50768. stop(): void;
  50769. /**
  50770. * Remove all active particles
  50771. */
  50772. reset(): void;
  50773. /**
  50774. * Returns the string "GPUParticleSystem"
  50775. * @returns a string containing the class name
  50776. */
  50777. getClassName(): string;
  50778. private _colorGradientsTexture;
  50779. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  50780. /**
  50781. * Adds a new color gradient
  50782. * @param gradient defines the gradient to use (between 0 and 1)
  50783. * @param color1 defines the color to affect to the specified gradient
  50784. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  50785. * @returns the current particle system
  50786. */
  50787. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  50788. /**
  50789. * Remove a specific color gradient
  50790. * @param gradient defines the gradient to remove
  50791. * @returns the current particle system
  50792. */
  50793. removeColorGradient(gradient: number): GPUParticleSystem;
  50794. private _angularSpeedGradientsTexture;
  50795. private _sizeGradientsTexture;
  50796. private _velocityGradientsTexture;
  50797. private _limitVelocityGradientsTexture;
  50798. private _dragGradientsTexture;
  50799. private _addFactorGradient;
  50800. /**
  50801. * Adds a new size gradient
  50802. * @param gradient defines the gradient to use (between 0 and 1)
  50803. * @param factor defines the size factor to affect to the specified gradient
  50804. * @returns the current particle system
  50805. */
  50806. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  50807. /**
  50808. * Remove a specific size gradient
  50809. * @param gradient defines the gradient to remove
  50810. * @returns the current particle system
  50811. */
  50812. removeSizeGradient(gradient: number): GPUParticleSystem;
  50813. /**
  50814. * Adds a new angular speed gradient
  50815. * @param gradient defines the gradient to use (between 0 and 1)
  50816. * @param factor defines the angular speed to affect to the specified gradient
  50817. * @returns the current particle system
  50818. */
  50819. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  50820. /**
  50821. * Remove a specific angular speed gradient
  50822. * @param gradient defines the gradient to remove
  50823. * @returns the current particle system
  50824. */
  50825. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  50826. /**
  50827. * Adds a new velocity gradient
  50828. * @param gradient defines the gradient to use (between 0 and 1)
  50829. * @param factor defines the velocity to affect to the specified gradient
  50830. * @returns the current particle system
  50831. */
  50832. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  50833. /**
  50834. * Remove a specific velocity gradient
  50835. * @param gradient defines the gradient to remove
  50836. * @returns the current particle system
  50837. */
  50838. removeVelocityGradient(gradient: number): GPUParticleSystem;
  50839. /**
  50840. * Adds a new limit velocity gradient
  50841. * @param gradient defines the gradient to use (between 0 and 1)
  50842. * @param factor defines the limit velocity value to affect to the specified gradient
  50843. * @returns the current particle system
  50844. */
  50845. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  50846. /**
  50847. * Remove a specific limit velocity gradient
  50848. * @param gradient defines the gradient to remove
  50849. * @returns the current particle system
  50850. */
  50851. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  50852. /**
  50853. * Adds a new drag gradient
  50854. * @param gradient defines the gradient to use (between 0 and 1)
  50855. * @param factor defines the drag value to affect to the specified gradient
  50856. * @returns the current particle system
  50857. */
  50858. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  50859. /**
  50860. * Remove a specific drag gradient
  50861. * @param gradient defines the gradient to remove
  50862. * @returns the current particle system
  50863. */
  50864. removeDragGradient(gradient: number): GPUParticleSystem;
  50865. /**
  50866. * Not supported by GPUParticleSystem
  50867. * @param gradient defines the gradient to use (between 0 and 1)
  50868. * @param factor defines the emit rate value to affect to the specified gradient
  50869. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50870. * @returns the current particle system
  50871. */
  50872. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50873. /**
  50874. * Not supported by GPUParticleSystem
  50875. * @param gradient defines the gradient to remove
  50876. * @returns the current particle system
  50877. */
  50878. removeEmitRateGradient(gradient: number): IParticleSystem;
  50879. /**
  50880. * Not supported by GPUParticleSystem
  50881. * @param gradient defines the gradient to use (between 0 and 1)
  50882. * @param factor defines the start size value to affect to the specified gradient
  50883. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50884. * @returns the current particle system
  50885. */
  50886. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50887. /**
  50888. * Not supported by GPUParticleSystem
  50889. * @param gradient defines the gradient to remove
  50890. * @returns the current particle system
  50891. */
  50892. removeStartSizeGradient(gradient: number): IParticleSystem;
  50893. /**
  50894. * Not supported by GPUParticleSystem
  50895. * @param gradient defines the gradient to use (between 0 and 1)
  50896. * @param min defines the color remap minimal range
  50897. * @param max defines the color remap maximal range
  50898. * @returns the current particle system
  50899. */
  50900. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  50901. /**
  50902. * Not supported by GPUParticleSystem
  50903. * @param gradient defines the gradient to remove
  50904. * @returns the current particle system
  50905. */
  50906. removeColorRemapGradient(): IParticleSystem;
  50907. /**
  50908. * Not supported by GPUParticleSystem
  50909. * @param gradient defines the gradient to use (between 0 and 1)
  50910. * @param min defines the alpha remap minimal range
  50911. * @param max defines the alpha remap maximal range
  50912. * @returns the current particle system
  50913. */
  50914. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  50915. /**
  50916. * Not supported by GPUParticleSystem
  50917. * @param gradient defines the gradient to remove
  50918. * @returns the current particle system
  50919. */
  50920. removeAlphaRemapGradient(): IParticleSystem;
  50921. /**
  50922. * Not supported by GPUParticleSystem
  50923. * @param gradient defines the gradient to use (between 0 and 1)
  50924. * @param color defines the color to affect to the specified gradient
  50925. * @returns the current particle system
  50926. */
  50927. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  50928. /**
  50929. * Not supported by GPUParticleSystem
  50930. * @param gradient defines the gradient to remove
  50931. * @returns the current particle system
  50932. */
  50933. removeRampGradient(): IParticleSystem;
  50934. /**
  50935. * Not supported by GPUParticleSystem
  50936. * @returns the list of ramp gradients
  50937. */
  50938. getRampGradients(): Nullable<Array<Color3Gradient>>;
  50939. /**
  50940. * Not supported by GPUParticleSystem
  50941. * Gets or sets a boolean indicating that ramp gradients must be used
  50942. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  50943. */
  50944. useRampGradients: boolean;
  50945. /**
  50946. * Not supported by GPUParticleSystem
  50947. * @param gradient defines the gradient to use (between 0 and 1)
  50948. * @param factor defines the life time factor to affect to the specified gradient
  50949. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50950. * @returns the current particle system
  50951. */
  50952. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50953. /**
  50954. * Not supported by GPUParticleSystem
  50955. * @param gradient defines the gradient to remove
  50956. * @returns the current particle system
  50957. */
  50958. removeLifeTimeGradient(gradient: number): IParticleSystem;
  50959. /**
  50960. * Instantiates a GPU particle system.
  50961. * 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.
  50962. * @param name The name of the particle system
  50963. * @param options The options used to create the system
  50964. * @param scene The scene the particle system belongs to
  50965. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  50966. */
  50967. constructor(name: string, options: Partial<{
  50968. capacity: number;
  50969. randomTextureSize: number;
  50970. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  50971. protected _reset(): void;
  50972. private _createUpdateVAO;
  50973. private _createRenderVAO;
  50974. private _initialize;
  50975. /** @hidden */
  50976. _recreateUpdateEffect(): void;
  50977. /** @hidden */
  50978. _recreateRenderEffect(): void;
  50979. /**
  50980. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  50981. * @param preWarm defines if we are in the pre-warmimg phase
  50982. */
  50983. animate(preWarm?: boolean): void;
  50984. private _createFactorGradientTexture;
  50985. private _createSizeGradientTexture;
  50986. private _createAngularSpeedGradientTexture;
  50987. private _createVelocityGradientTexture;
  50988. private _createLimitVelocityGradientTexture;
  50989. private _createDragGradientTexture;
  50990. private _createColorGradientTexture;
  50991. /**
  50992. * Renders the particle system in its current state
  50993. * @param preWarm defines if the system should only update the particles but not render them
  50994. * @returns the current number of particles
  50995. */
  50996. render(preWarm?: boolean): number;
  50997. /**
  50998. * Rebuilds the particle system
  50999. */
  51000. rebuild(): void;
  51001. private _releaseBuffers;
  51002. private _releaseVAOs;
  51003. /**
  51004. * Disposes the particle system and free the associated resources
  51005. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  51006. */
  51007. dispose(disposeTexture?: boolean): void;
  51008. /**
  51009. * Clones the particle system.
  51010. * @param name The name of the cloned object
  51011. * @param newEmitter The new emitter to use
  51012. * @returns the cloned particle system
  51013. */
  51014. clone(name: string, newEmitter: any): GPUParticleSystem;
  51015. /**
  51016. * Serializes the particle system to a JSON object.
  51017. * @returns the JSON object
  51018. */
  51019. serialize(): any;
  51020. /**
  51021. * Parses a JSON object to create a GPU particle system.
  51022. * @param parsedParticleSystem The JSON object to parse
  51023. * @param scene The scene to create the particle system in
  51024. * @param rootUrl The root url to use to load external dependencies like texture
  51025. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  51026. * @returns the parsed GPU particle system
  51027. */
  51028. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  51029. }
  51030. }
  51031. declare module "babylonjs/Particles/particleSystemSet" {
  51032. import { Nullable } from "babylonjs/types";
  51033. import { Color3 } from "babylonjs/Maths/math";
  51034. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51035. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51036. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51037. import { Scene, IDisposable } from "babylonjs/scene";
  51038. /**
  51039. * Represents a set of particle systems working together to create a specific effect
  51040. */
  51041. export class ParticleSystemSet implements IDisposable {
  51042. private _emitterCreationOptions;
  51043. private _emitterNode;
  51044. /**
  51045. * Gets the particle system list
  51046. */
  51047. systems: IParticleSystem[];
  51048. /**
  51049. * Gets the emitter node used with this set
  51050. */
  51051. readonly emitterNode: Nullable<TransformNode>;
  51052. /**
  51053. * Creates a new emitter mesh as a sphere
  51054. * @param options defines the options used to create the sphere
  51055. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  51056. * @param scene defines the hosting scene
  51057. */
  51058. setEmitterAsSphere(options: {
  51059. diameter: number;
  51060. segments: number;
  51061. color: Color3;
  51062. }, renderingGroupId: number, scene: Scene): void;
  51063. /**
  51064. * Starts all particle systems of the set
  51065. * @param emitter defines an optional mesh to use as emitter for the particle systems
  51066. */
  51067. start(emitter?: AbstractMesh): void;
  51068. /**
  51069. * Release all associated resources
  51070. */
  51071. dispose(): void;
  51072. /**
  51073. * Serialize the set into a JSON compatible object
  51074. * @returns a JSON compatible representation of the set
  51075. */
  51076. serialize(): any;
  51077. /**
  51078. * Parse a new ParticleSystemSet from a serialized source
  51079. * @param data defines a JSON compatible representation of the set
  51080. * @param scene defines the hosting scene
  51081. * @param gpu defines if we want GPU particles or CPU particles
  51082. * @returns a new ParticleSystemSet
  51083. */
  51084. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  51085. }
  51086. }
  51087. declare module "babylonjs/Particles/particleHelper" {
  51088. import { Nullable } from "babylonjs/types";
  51089. import { Scene } from "babylonjs/scene";
  51090. import { Vector3 } from "babylonjs/Maths/math";
  51091. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51092. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51093. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  51094. /**
  51095. * This class is made for on one-liner static method to help creating particle system set.
  51096. */
  51097. export class ParticleHelper {
  51098. /**
  51099. * Gets or sets base Assets URL
  51100. */
  51101. static BaseAssetsUrl: string;
  51102. /**
  51103. * Create a default particle system that you can tweak
  51104. * @param emitter defines the emitter to use
  51105. * @param capacity defines the system capacity (default is 500 particles)
  51106. * @param scene defines the hosting scene
  51107. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  51108. * @returns the new Particle system
  51109. */
  51110. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  51111. /**
  51112. * This is the main static method (one-liner) of this helper to create different particle systems
  51113. * @param type This string represents the type to the particle system to create
  51114. * @param scene The scene where the particle system should live
  51115. * @param gpu If the system will use gpu
  51116. * @returns the ParticleSystemSet created
  51117. */
  51118. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  51119. /**
  51120. * Static function used to export a particle system to a ParticleSystemSet variable.
  51121. * Please note that the emitter shape is not exported
  51122. * @param systems defines the particle systems to export
  51123. * @returns the created particle system set
  51124. */
  51125. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  51126. }
  51127. }
  51128. declare module "babylonjs/Particles/particleSystemComponent" {
  51129. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51130. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  51131. import "babylonjs/Shaders/particles.vertex";
  51132. module "babylonjs/Engines/engine" {
  51133. interface Engine {
  51134. /**
  51135. * Create an effect to use with particle systems.
  51136. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  51137. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  51138. * @param uniformsNames defines a list of attribute names
  51139. * @param samplers defines an array of string used to represent textures
  51140. * @param defines defines the string containing the defines to use to compile the shaders
  51141. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  51142. * @param onCompiled defines a function to call when the effect creation is successful
  51143. * @param onError defines a function to call when the effect creation has failed
  51144. * @returns the new Effect
  51145. */
  51146. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  51147. }
  51148. }
  51149. module "babylonjs/Meshes/mesh" {
  51150. interface Mesh {
  51151. /**
  51152. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  51153. * @returns an array of IParticleSystem
  51154. */
  51155. getEmittedParticleSystems(): IParticleSystem[];
  51156. /**
  51157. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  51158. * @returns an array of IParticleSystem
  51159. */
  51160. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  51161. }
  51162. }
  51163. /**
  51164. * @hidden
  51165. */
  51166. export var _IDoNeedToBeInTheBuild: number;
  51167. }
  51168. declare module "babylonjs/Particles/index" {
  51169. export * from "babylonjs/Particles/baseParticleSystem";
  51170. export * from "babylonjs/Particles/EmitterTypes/index";
  51171. export * from "babylonjs/Particles/gpuParticleSystem";
  51172. export * from "babylonjs/Particles/IParticleSystem";
  51173. export * from "babylonjs/Particles/particle";
  51174. export * from "babylonjs/Particles/particleHelper";
  51175. export * from "babylonjs/Particles/particleSystem";
  51176. export * from "babylonjs/Particles/particleSystemComponent";
  51177. export * from "babylonjs/Particles/particleSystemSet";
  51178. export * from "babylonjs/Particles/solidParticle";
  51179. export * from "babylonjs/Particles/solidParticleSystem";
  51180. export * from "babylonjs/Particles/subEmitter";
  51181. }
  51182. declare module "babylonjs/Physics/physicsEngineComponent" {
  51183. import { Nullable } from "babylonjs/types";
  51184. import { Observable, Observer } from "babylonjs/Misc/observable";
  51185. import { Vector3 } from "babylonjs/Maths/math";
  51186. import { Mesh } from "babylonjs/Meshes/mesh";
  51187. import { ISceneComponent } from "babylonjs/sceneComponent";
  51188. import { Scene } from "babylonjs/scene";
  51189. import { Node } from "babylonjs/node";
  51190. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  51191. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51192. module "babylonjs/scene" {
  51193. interface Scene {
  51194. /** @hidden (Backing field) */
  51195. _physicsEngine: Nullable<IPhysicsEngine>;
  51196. /**
  51197. * Gets the current physics engine
  51198. * @returns a IPhysicsEngine or null if none attached
  51199. */
  51200. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  51201. /**
  51202. * Enables physics to the current scene
  51203. * @param gravity defines the scene's gravity for the physics engine
  51204. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  51205. * @return a boolean indicating if the physics engine was initialized
  51206. */
  51207. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  51208. /**
  51209. * Disables and disposes the physics engine associated with the scene
  51210. */
  51211. disablePhysicsEngine(): void;
  51212. /**
  51213. * Gets a boolean indicating if there is an active physics engine
  51214. * @returns a boolean indicating if there is an active physics engine
  51215. */
  51216. isPhysicsEnabled(): boolean;
  51217. /**
  51218. * Deletes a physics compound impostor
  51219. * @param compound defines the compound to delete
  51220. */
  51221. deleteCompoundImpostor(compound: any): void;
  51222. /**
  51223. * An event triggered when physic simulation is about to be run
  51224. */
  51225. onBeforePhysicsObservable: Observable<Scene>;
  51226. /**
  51227. * An event triggered when physic simulation has been done
  51228. */
  51229. onAfterPhysicsObservable: Observable<Scene>;
  51230. }
  51231. }
  51232. module "babylonjs/Meshes/abstractMesh" {
  51233. interface AbstractMesh {
  51234. /** @hidden */
  51235. _physicsImpostor: Nullable<PhysicsImpostor>;
  51236. /**
  51237. * Gets or sets impostor used for physic simulation
  51238. * @see http://doc.babylonjs.com/features/physics_engine
  51239. */
  51240. physicsImpostor: Nullable<PhysicsImpostor>;
  51241. /**
  51242. * Gets the current physics impostor
  51243. * @see http://doc.babylonjs.com/features/physics_engine
  51244. * @returns a physics impostor or null
  51245. */
  51246. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  51247. /** Apply a physic impulse to the mesh
  51248. * @param force defines the force to apply
  51249. * @param contactPoint defines where to apply the force
  51250. * @returns the current mesh
  51251. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51252. */
  51253. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  51254. /**
  51255. * Creates a physic joint between two meshes
  51256. * @param otherMesh defines the other mesh to use
  51257. * @param pivot1 defines the pivot to use on this mesh
  51258. * @param pivot2 defines the pivot to use on the other mesh
  51259. * @param options defines additional options (can be plugin dependent)
  51260. * @returns the current mesh
  51261. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  51262. */
  51263. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  51264. /** @hidden */
  51265. _disposePhysicsObserver: Nullable<Observer<Node>>;
  51266. }
  51267. }
  51268. /**
  51269. * Defines the physics engine scene component responsible to manage a physics engine
  51270. */
  51271. export class PhysicsEngineSceneComponent implements ISceneComponent {
  51272. /**
  51273. * The component name helpful to identify the component in the list of scene components.
  51274. */
  51275. readonly name: string;
  51276. /**
  51277. * The scene the component belongs to.
  51278. */
  51279. scene: Scene;
  51280. /**
  51281. * Creates a new instance of the component for the given scene
  51282. * @param scene Defines the scene to register the component in
  51283. */
  51284. constructor(scene: Scene);
  51285. /**
  51286. * Registers the component in a given scene
  51287. */
  51288. register(): void;
  51289. /**
  51290. * Rebuilds the elements related to this component in case of
  51291. * context lost for instance.
  51292. */
  51293. rebuild(): void;
  51294. /**
  51295. * Disposes the component and the associated ressources
  51296. */
  51297. dispose(): void;
  51298. }
  51299. }
  51300. declare module "babylonjs/Physics/physicsHelper" {
  51301. import { Nullable } from "babylonjs/types";
  51302. import { Vector3 } from "babylonjs/Maths/math";
  51303. import { Mesh } from "babylonjs/Meshes/mesh";
  51304. import { Ray } from "babylonjs/Culling/ray";
  51305. import { Scene } from "babylonjs/scene";
  51306. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51307. /**
  51308. * A helper for physics simulations
  51309. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51310. */
  51311. export class PhysicsHelper {
  51312. private _scene;
  51313. private _physicsEngine;
  51314. /**
  51315. * Initializes the Physics helper
  51316. * @param scene Babylon.js scene
  51317. */
  51318. constructor(scene: Scene);
  51319. /**
  51320. * Applies a radial explosion impulse
  51321. * @param origin the origin of the explosion
  51322. * @param radius the explosion radius
  51323. * @param strength the explosion strength
  51324. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51325. * @returns A physics radial explosion event, or null
  51326. */
  51327. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  51328. /**
  51329. * Applies a radial explosion force
  51330. * @param origin the origin of the explosion
  51331. * @param radius the explosion radius
  51332. * @param strength the explosion strength
  51333. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51334. * @returns A physics radial explosion event, or null
  51335. */
  51336. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  51337. /**
  51338. * Creates a gravitational field
  51339. * @param origin the origin of the explosion
  51340. * @param radius the explosion radius
  51341. * @param strength the explosion strength
  51342. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51343. * @returns A physics gravitational field event, or null
  51344. */
  51345. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  51346. /**
  51347. * Creates a physics updraft event
  51348. * @param origin the origin of the updraft
  51349. * @param radius the radius of the updraft
  51350. * @param strength the strength of the updraft
  51351. * @param height the height of the updraft
  51352. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  51353. * @returns A physics updraft event, or null
  51354. */
  51355. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  51356. /**
  51357. * Creates a physics vortex event
  51358. * @param origin the of the vortex
  51359. * @param radius the radius of the vortex
  51360. * @param strength the strength of the vortex
  51361. * @param height the height of the vortex
  51362. * @returns a Physics vortex event, or null
  51363. * A physics vortex event or null
  51364. */
  51365. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  51366. }
  51367. /**
  51368. * Represents a physics radial explosion event
  51369. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51370. */
  51371. export class PhysicsRadialExplosionEvent {
  51372. private _scene;
  51373. private _sphere;
  51374. private _sphereOptions;
  51375. private _rays;
  51376. private _dataFetched;
  51377. /**
  51378. * Initializes a radial explosioin event
  51379. * @param scene BabylonJS scene
  51380. */
  51381. constructor(scene: Scene);
  51382. /**
  51383. * Returns the data related to the radial explosion event (sphere & rays).
  51384. * @returns The radial explosion event data
  51385. */
  51386. getData(): PhysicsRadialExplosionEventData;
  51387. /**
  51388. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  51389. * @param impostor A physics imposter
  51390. * @param origin the origin of the explosion
  51391. * @param radius the explosion radius
  51392. * @param strength the explosion strength
  51393. * @param falloff possible options: Constant & Linear
  51394. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  51395. */
  51396. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  51397. /**
  51398. * Disposes the sphere.
  51399. * @param force Specifies if the sphere should be disposed by force
  51400. */
  51401. dispose(force?: boolean): void;
  51402. /*** Helpers ***/
  51403. private _prepareSphere;
  51404. private _intersectsWithSphere;
  51405. }
  51406. /**
  51407. * Represents a gravitational field event
  51408. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51409. */
  51410. export class PhysicsGravitationalFieldEvent {
  51411. private _physicsHelper;
  51412. private _scene;
  51413. private _origin;
  51414. private _radius;
  51415. private _strength;
  51416. private _falloff;
  51417. private _tickCallback;
  51418. private _sphere;
  51419. private _dataFetched;
  51420. /**
  51421. * Initializes the physics gravitational field event
  51422. * @param physicsHelper A physics helper
  51423. * @param scene BabylonJS scene
  51424. * @param origin The origin position of the gravitational field event
  51425. * @param radius The radius of the gravitational field event
  51426. * @param strength The strength of the gravitational field event
  51427. * @param falloff The falloff for the gravitational field event
  51428. */
  51429. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  51430. /**
  51431. * Returns the data related to the gravitational field event (sphere).
  51432. * @returns A gravitational field event
  51433. */
  51434. getData(): PhysicsGravitationalFieldEventData;
  51435. /**
  51436. * Enables the gravitational field.
  51437. */
  51438. enable(): void;
  51439. /**
  51440. * Disables the gravitational field.
  51441. */
  51442. disable(): void;
  51443. /**
  51444. * Disposes the sphere.
  51445. * @param force The force to dispose from the gravitational field event
  51446. */
  51447. dispose(force?: boolean): void;
  51448. private _tick;
  51449. }
  51450. /**
  51451. * Represents a physics updraft event
  51452. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51453. */
  51454. export class PhysicsUpdraftEvent {
  51455. private _scene;
  51456. private _origin;
  51457. private _radius;
  51458. private _strength;
  51459. private _height;
  51460. private _updraftMode;
  51461. private _physicsEngine;
  51462. private _originTop;
  51463. private _originDirection;
  51464. private _tickCallback;
  51465. private _cylinder;
  51466. private _cylinderPosition;
  51467. private _dataFetched;
  51468. /**
  51469. * Initializes the physics updraft event
  51470. * @param _scene BabylonJS scene
  51471. * @param _origin The origin position of the updraft
  51472. * @param _radius The radius of the updraft
  51473. * @param _strength The strength of the updraft
  51474. * @param _height The height of the updraft
  51475. * @param _updraftMode The mode of the updraft
  51476. */
  51477. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  51478. /**
  51479. * Returns the data related to the updraft event (cylinder).
  51480. * @returns A physics updraft event
  51481. */
  51482. getData(): PhysicsUpdraftEventData;
  51483. /**
  51484. * Enables the updraft.
  51485. */
  51486. enable(): void;
  51487. /**
  51488. * Disables the cortex.
  51489. */
  51490. disable(): void;
  51491. /**
  51492. * Disposes the sphere.
  51493. * @param force Specifies if the updraft should be disposed by force
  51494. */
  51495. dispose(force?: boolean): void;
  51496. private getImpostorForceAndContactPoint;
  51497. private _tick;
  51498. /*** Helpers ***/
  51499. private _prepareCylinder;
  51500. private _intersectsWithCylinder;
  51501. }
  51502. /**
  51503. * Represents a physics vortex event
  51504. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51505. */
  51506. export class PhysicsVortexEvent {
  51507. private _scene;
  51508. private _origin;
  51509. private _radius;
  51510. private _strength;
  51511. private _height;
  51512. private _physicsEngine;
  51513. private _originTop;
  51514. private _centripetalForceThreshold;
  51515. private _updraftMultiplier;
  51516. private _tickCallback;
  51517. private _cylinder;
  51518. private _cylinderPosition;
  51519. private _dataFetched;
  51520. /**
  51521. * Initializes the physics vortex event
  51522. * @param _scene The BabylonJS scene
  51523. * @param _origin The origin position of the vortex
  51524. * @param _radius The radius of the vortex
  51525. * @param _strength The strength of the vortex
  51526. * @param _height The height of the vortex
  51527. */
  51528. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  51529. /**
  51530. * Returns the data related to the vortex event (cylinder).
  51531. * @returns The physics vortex event data
  51532. */
  51533. getData(): PhysicsVortexEventData;
  51534. /**
  51535. * Enables the vortex.
  51536. */
  51537. enable(): void;
  51538. /**
  51539. * Disables the cortex.
  51540. */
  51541. disable(): void;
  51542. /**
  51543. * Disposes the sphere.
  51544. * @param force
  51545. */
  51546. dispose(force?: boolean): void;
  51547. private getImpostorForceAndContactPoint;
  51548. private _tick;
  51549. /*** Helpers ***/
  51550. private _prepareCylinder;
  51551. private _intersectsWithCylinder;
  51552. }
  51553. /**
  51554. * The strenght of the force in correspondence to the distance of the affected object
  51555. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51556. */
  51557. export enum PhysicsRadialImpulseFalloff {
  51558. /** Defines that impulse is constant in strength across it's whole radius */
  51559. Constant = 0,
  51560. /** DEfines that impulse gets weaker if it's further from the origin */
  51561. Linear = 1
  51562. }
  51563. /**
  51564. * The strength of the force in correspondence to the distance of the affected object
  51565. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51566. */
  51567. export enum PhysicsUpdraftMode {
  51568. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  51569. Center = 0,
  51570. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  51571. Perpendicular = 1
  51572. }
  51573. /**
  51574. * Interface for a physics force and contact point
  51575. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51576. */
  51577. export interface PhysicsForceAndContactPoint {
  51578. /**
  51579. * The force applied at the contact point
  51580. */
  51581. force: Vector3;
  51582. /**
  51583. * The contact point
  51584. */
  51585. contactPoint: Vector3;
  51586. }
  51587. /**
  51588. * Interface for radial explosion event data
  51589. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51590. */
  51591. export interface PhysicsRadialExplosionEventData {
  51592. /**
  51593. * A sphere used for the radial explosion event
  51594. */
  51595. sphere: Mesh;
  51596. /**
  51597. * An array of rays for the radial explosion event
  51598. */
  51599. rays: Array<Ray>;
  51600. }
  51601. /**
  51602. * Interface for gravitational field event data
  51603. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51604. */
  51605. export interface PhysicsGravitationalFieldEventData {
  51606. /**
  51607. * A sphere mesh used for the gravitational field event
  51608. */
  51609. sphere: Mesh;
  51610. }
  51611. /**
  51612. * Interface for updraft event data
  51613. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51614. */
  51615. export interface PhysicsUpdraftEventData {
  51616. /**
  51617. * A cylinder used for the updraft event
  51618. */
  51619. cylinder: Mesh;
  51620. }
  51621. /**
  51622. * Interface for vortex event data
  51623. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51624. */
  51625. export interface PhysicsVortexEventData {
  51626. /**
  51627. * A cylinder used for the vortex event
  51628. */
  51629. cylinder: Mesh;
  51630. }
  51631. }
  51632. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  51633. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  51634. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51635. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51636. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51637. import { Nullable } from "babylonjs/types";
  51638. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51639. /**
  51640. * AmmoJS Physics plugin
  51641. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51642. * @see https://github.com/kripken/ammo.js/
  51643. */
  51644. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  51645. private _useDeltaForWorldStep;
  51646. /**
  51647. * Reference to the Ammo library
  51648. */
  51649. bjsAMMO: any;
  51650. /**
  51651. * Created ammoJS world which physics bodies are added to
  51652. */
  51653. world: any;
  51654. /**
  51655. * Name of the plugin
  51656. */
  51657. name: string;
  51658. private _timeStep;
  51659. private _fixedTimeStep;
  51660. private _maxSteps;
  51661. private _tmpQuaternion;
  51662. private _tmpAmmoTransform;
  51663. private _tmpAmmoQuaternion;
  51664. private _tmpAmmoConcreteContactResultCallback;
  51665. private _collisionConfiguration;
  51666. private _dispatcher;
  51667. private _overlappingPairCache;
  51668. private _solver;
  51669. private _tmpAmmoVectorA;
  51670. private _tmpAmmoVectorB;
  51671. private _tmpAmmoVectorC;
  51672. private _tmpContactCallbackResult;
  51673. private static readonly DISABLE_COLLISION_FLAG;
  51674. private static readonly KINEMATIC_FLAG;
  51675. private static readonly DISABLE_DEACTIVATION_FLAG;
  51676. /**
  51677. * Initializes the ammoJS plugin
  51678. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  51679. * @param ammoInjection can be used to inject your own ammo reference
  51680. */
  51681. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  51682. /**
  51683. * Sets the gravity of the physics world (m/(s^2))
  51684. * @param gravity Gravity to set
  51685. */
  51686. setGravity(gravity: Vector3): void;
  51687. /**
  51688. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  51689. * @param timeStep timestep to use in seconds
  51690. */
  51691. setTimeStep(timeStep: number): void;
  51692. /**
  51693. * 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)
  51694. * @param fixedTimeStep fixedTimeStep to use in seconds
  51695. */
  51696. setFixedTimeStep(fixedTimeStep: number): void;
  51697. /**
  51698. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  51699. * @param maxSteps the maximum number of steps by the physics engine per frame
  51700. */
  51701. setMaxSteps(maxSteps: number): void;
  51702. /**
  51703. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  51704. * @returns the current timestep in seconds
  51705. */
  51706. getTimeStep(): number;
  51707. private _isImpostorInContact;
  51708. private _isImpostorPairInContact;
  51709. private _stepSimulation;
  51710. /**
  51711. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  51712. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  51713. * After the step the babylon meshes are set to the position of the physics imposters
  51714. * @param delta amount of time to step forward
  51715. * @param impostors array of imposters to update before/after the step
  51716. */
  51717. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51718. private _tmpVector;
  51719. private _tmpMatrix;
  51720. /**
  51721. * Applies an implulse on the imposter
  51722. * @param impostor imposter to apply impulse
  51723. * @param force amount of force to be applied to the imposter
  51724. * @param contactPoint the location to apply the impulse on the imposter
  51725. */
  51726. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51727. /**
  51728. * Applies a force on the imposter
  51729. * @param impostor imposter to apply force
  51730. * @param force amount of force to be applied to the imposter
  51731. * @param contactPoint the location to apply the force on the imposter
  51732. */
  51733. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51734. /**
  51735. * Creates a physics body using the plugin
  51736. * @param impostor the imposter to create the physics body on
  51737. */
  51738. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51739. /**
  51740. * Removes the physics body from the imposter and disposes of the body's memory
  51741. * @param impostor imposter to remove the physics body from
  51742. */
  51743. removePhysicsBody(impostor: PhysicsImpostor): void;
  51744. /**
  51745. * Generates a joint
  51746. * @param impostorJoint the imposter joint to create the joint with
  51747. */
  51748. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51749. /**
  51750. * Removes a joint
  51751. * @param impostorJoint the imposter joint to remove the joint from
  51752. */
  51753. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51754. private _addMeshVerts;
  51755. private _createShape;
  51756. /**
  51757. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  51758. * @param impostor imposter containing the physics body and babylon object
  51759. */
  51760. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51761. /**
  51762. * Sets the babylon object's position/rotation from the physics body's position/rotation
  51763. * @param impostor imposter containing the physics body and babylon object
  51764. * @param newPosition new position
  51765. * @param newRotation new rotation
  51766. */
  51767. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51768. /**
  51769. * If this plugin is supported
  51770. * @returns true if its supported
  51771. */
  51772. isSupported(): boolean;
  51773. /**
  51774. * Sets the linear velocity of the physics body
  51775. * @param impostor imposter to set the velocity on
  51776. * @param velocity velocity to set
  51777. */
  51778. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51779. /**
  51780. * Sets the angular velocity of the physics body
  51781. * @param impostor imposter to set the velocity on
  51782. * @param velocity velocity to set
  51783. */
  51784. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51785. /**
  51786. * gets the linear velocity
  51787. * @param impostor imposter to get linear velocity from
  51788. * @returns linear velocity
  51789. */
  51790. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51791. /**
  51792. * gets the angular velocity
  51793. * @param impostor imposter to get angular velocity from
  51794. * @returns angular velocity
  51795. */
  51796. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51797. /**
  51798. * Sets the mass of physics body
  51799. * @param impostor imposter to set the mass on
  51800. * @param mass mass to set
  51801. */
  51802. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51803. /**
  51804. * Gets the mass of the physics body
  51805. * @param impostor imposter to get the mass from
  51806. * @returns mass
  51807. */
  51808. getBodyMass(impostor: PhysicsImpostor): number;
  51809. /**
  51810. * Gets friction of the impostor
  51811. * @param impostor impostor to get friction from
  51812. * @returns friction value
  51813. */
  51814. getBodyFriction(impostor: PhysicsImpostor): number;
  51815. /**
  51816. * Sets friction of the impostor
  51817. * @param impostor impostor to set friction on
  51818. * @param friction friction value
  51819. */
  51820. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51821. /**
  51822. * Gets restitution of the impostor
  51823. * @param impostor impostor to get restitution from
  51824. * @returns restitution value
  51825. */
  51826. getBodyRestitution(impostor: PhysicsImpostor): number;
  51827. /**
  51828. * Sets resitution of the impostor
  51829. * @param impostor impostor to set resitution on
  51830. * @param restitution resitution value
  51831. */
  51832. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51833. /**
  51834. * Sleeps the physics body and stops it from being active
  51835. * @param impostor impostor to sleep
  51836. */
  51837. sleepBody(impostor: PhysicsImpostor): void;
  51838. /**
  51839. * Activates the physics body
  51840. * @param impostor impostor to activate
  51841. */
  51842. wakeUpBody(impostor: PhysicsImpostor): void;
  51843. /**
  51844. * Updates the distance parameters of the joint
  51845. * @param joint joint to update
  51846. * @param maxDistance maximum distance of the joint
  51847. * @param minDistance minimum distance of the joint
  51848. */
  51849. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51850. /**
  51851. * Sets a motor on the joint
  51852. * @param joint joint to set motor on
  51853. * @param speed speed of the motor
  51854. * @param maxForce maximum force of the motor
  51855. * @param motorIndex index of the motor
  51856. */
  51857. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51858. /**
  51859. * Sets the motors limit
  51860. * @param joint joint to set limit on
  51861. * @param upperLimit upper limit
  51862. * @param lowerLimit lower limit
  51863. */
  51864. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51865. /**
  51866. * Syncs the position and rotation of a mesh with the impostor
  51867. * @param mesh mesh to sync
  51868. * @param impostor impostor to update the mesh with
  51869. */
  51870. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51871. /**
  51872. * Gets the radius of the impostor
  51873. * @param impostor impostor to get radius from
  51874. * @returns the radius
  51875. */
  51876. getRadius(impostor: PhysicsImpostor): number;
  51877. /**
  51878. * Gets the box size of the impostor
  51879. * @param impostor impostor to get box size from
  51880. * @param result the resulting box size
  51881. */
  51882. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51883. /**
  51884. * Disposes of the impostor
  51885. */
  51886. dispose(): void;
  51887. }
  51888. }
  51889. declare module "babylonjs/Physics/Plugins/index" {
  51890. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  51891. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  51892. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  51893. }
  51894. declare module "babylonjs/Physics/index" {
  51895. export * from "babylonjs/Physics/IPhysicsEngine";
  51896. export * from "babylonjs/Physics/physicsEngine";
  51897. export * from "babylonjs/Physics/physicsEngineComponent";
  51898. export * from "babylonjs/Physics/physicsHelper";
  51899. export * from "babylonjs/Physics/physicsImpostor";
  51900. export * from "babylonjs/Physics/physicsJoint";
  51901. export * from "babylonjs/Physics/Plugins/index";
  51902. }
  51903. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  51904. /** @hidden */
  51905. export var blackAndWhitePixelShader: {
  51906. name: string;
  51907. shader: string;
  51908. };
  51909. }
  51910. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  51911. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51912. import { Camera } from "babylonjs/Cameras/camera";
  51913. import { Engine } from "babylonjs/Engines/engine";
  51914. import "babylonjs/Shaders/blackAndWhite.fragment";
  51915. /**
  51916. * Post process used to render in black and white
  51917. */
  51918. export class BlackAndWhitePostProcess extends PostProcess {
  51919. /**
  51920. * Linear about to convert he result to black and white (default: 1)
  51921. */
  51922. degree: number;
  51923. /**
  51924. * Creates a black and white post process
  51925. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  51926. * @param name The name of the effect.
  51927. * @param options The required width/height ratio to downsize to before computing the render pass.
  51928. * @param camera The camera to apply the render pass to.
  51929. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51930. * @param engine The engine which the post process will be applied. (default: current engine)
  51931. * @param reusable If the post process can be reused on the same frame. (default: false)
  51932. */
  51933. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51934. }
  51935. }
  51936. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  51937. import { Nullable } from "babylonjs/types";
  51938. import { Camera } from "babylonjs/Cameras/camera";
  51939. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51940. import { Engine } from "babylonjs/Engines/engine";
  51941. /**
  51942. * This represents a set of one or more post processes in Babylon.
  51943. * A post process can be used to apply a shader to a texture after it is rendered.
  51944. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  51945. */
  51946. export class PostProcessRenderEffect {
  51947. private _postProcesses;
  51948. private _getPostProcesses;
  51949. private _singleInstance;
  51950. private _cameras;
  51951. private _indicesForCamera;
  51952. /**
  51953. * Name of the effect
  51954. * @hidden
  51955. */
  51956. _name: string;
  51957. /**
  51958. * Instantiates a post process render effect.
  51959. * A post process can be used to apply a shader to a texture after it is rendered.
  51960. * @param engine The engine the effect is tied to
  51961. * @param name The name of the effect
  51962. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  51963. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  51964. */
  51965. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  51966. /**
  51967. * Checks if all the post processes in the effect are supported.
  51968. */
  51969. readonly isSupported: boolean;
  51970. /**
  51971. * Updates the current state of the effect
  51972. * @hidden
  51973. */
  51974. _update(): void;
  51975. /**
  51976. * Attaches the effect on cameras
  51977. * @param cameras The camera to attach to.
  51978. * @hidden
  51979. */
  51980. _attachCameras(cameras: Camera): void;
  51981. /**
  51982. * Attaches the effect on cameras
  51983. * @param cameras The camera to attach to.
  51984. * @hidden
  51985. */
  51986. _attachCameras(cameras: Camera[]): void;
  51987. /**
  51988. * Detatches the effect on cameras
  51989. * @param cameras The camera to detatch from.
  51990. * @hidden
  51991. */
  51992. _detachCameras(cameras: Camera): void;
  51993. /**
  51994. * Detatches the effect on cameras
  51995. * @param cameras The camera to detatch from.
  51996. * @hidden
  51997. */
  51998. _detachCameras(cameras: Camera[]): void;
  51999. /**
  52000. * Enables the effect on given cameras
  52001. * @param cameras The camera to enable.
  52002. * @hidden
  52003. */
  52004. _enable(cameras: Camera): void;
  52005. /**
  52006. * Enables the effect on given cameras
  52007. * @param cameras The camera to enable.
  52008. * @hidden
  52009. */
  52010. _enable(cameras: Nullable<Camera[]>): void;
  52011. /**
  52012. * Disables the effect on the given cameras
  52013. * @param cameras The camera to disable.
  52014. * @hidden
  52015. */
  52016. _disable(cameras: Camera): void;
  52017. /**
  52018. * Disables the effect on the given cameras
  52019. * @param cameras The camera to disable.
  52020. * @hidden
  52021. */
  52022. _disable(cameras: Nullable<Camera[]>): void;
  52023. /**
  52024. * Gets a list of the post processes contained in the effect.
  52025. * @param camera The camera to get the post processes on.
  52026. * @returns The list of the post processes in the effect.
  52027. */
  52028. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  52029. }
  52030. }
  52031. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  52032. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52033. /** @hidden */
  52034. export var extractHighlightsPixelShader: {
  52035. name: string;
  52036. shader: string;
  52037. };
  52038. }
  52039. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  52040. import { Nullable } from "babylonjs/types";
  52041. import { Camera } from "babylonjs/Cameras/camera";
  52042. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52043. import { Engine } from "babylonjs/Engines/engine";
  52044. import "babylonjs/Shaders/extractHighlights.fragment";
  52045. /**
  52046. * 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.
  52047. */
  52048. export class ExtractHighlightsPostProcess extends PostProcess {
  52049. /**
  52050. * The luminance threshold, pixels below this value will be set to black.
  52051. */
  52052. threshold: number;
  52053. /** @hidden */
  52054. _exposure: number;
  52055. /**
  52056. * Post process which has the input texture to be used when performing highlight extraction
  52057. * @hidden
  52058. */
  52059. _inputPostProcess: Nullable<PostProcess>;
  52060. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52061. }
  52062. }
  52063. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  52064. /** @hidden */
  52065. export var bloomMergePixelShader: {
  52066. name: string;
  52067. shader: string;
  52068. };
  52069. }
  52070. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  52071. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52072. import { Nullable } from "babylonjs/types";
  52073. import { Engine } from "babylonjs/Engines/engine";
  52074. import { Camera } from "babylonjs/Cameras/camera";
  52075. import "babylonjs/Shaders/bloomMerge.fragment";
  52076. /**
  52077. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  52078. */
  52079. export class BloomMergePostProcess extends PostProcess {
  52080. /** Weight of the bloom to be added to the original input. */
  52081. weight: number;
  52082. /**
  52083. * Creates a new instance of @see BloomMergePostProcess
  52084. * @param name The name of the effect.
  52085. * @param originalFromInput Post process which's input will be used for the merge.
  52086. * @param blurred Blurred highlights post process which's output will be used.
  52087. * @param weight Weight of the bloom to be added to the original input.
  52088. * @param options The required width/height ratio to downsize to before computing the render pass.
  52089. * @param camera The camera to apply the render pass to.
  52090. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52091. * @param engine The engine which the post process will be applied. (default: current engine)
  52092. * @param reusable If the post process can be reused on the same frame. (default: false)
  52093. * @param textureType Type of textures used when performing the post process. (default: 0)
  52094. * @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)
  52095. */
  52096. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  52097. /** Weight of the bloom to be added to the original input. */
  52098. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52099. }
  52100. }
  52101. declare module "babylonjs/PostProcesses/bloomEffect" {
  52102. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  52103. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52104. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  52105. import { Camera } from "babylonjs/Cameras/camera";
  52106. import { Scene } from "babylonjs/scene";
  52107. /**
  52108. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  52109. */
  52110. export class BloomEffect extends PostProcessRenderEffect {
  52111. private bloomScale;
  52112. /**
  52113. * @hidden Internal
  52114. */
  52115. _effects: Array<PostProcess>;
  52116. /**
  52117. * @hidden Internal
  52118. */
  52119. _downscale: ExtractHighlightsPostProcess;
  52120. private _blurX;
  52121. private _blurY;
  52122. private _merge;
  52123. /**
  52124. * The luminance threshold to find bright areas of the image to bloom.
  52125. */
  52126. threshold: number;
  52127. /**
  52128. * The strength of the bloom.
  52129. */
  52130. weight: number;
  52131. /**
  52132. * Specifies the size of the bloom blur kernel, relative to the final output size
  52133. */
  52134. kernel: number;
  52135. /**
  52136. * Creates a new instance of @see BloomEffect
  52137. * @param scene The scene the effect belongs to.
  52138. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  52139. * @param bloomKernel The size of the kernel to be used when applying the blur.
  52140. * @param bloomWeight The the strength of bloom.
  52141. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52142. * @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)
  52143. */
  52144. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  52145. /**
  52146. * Disposes each of the internal effects for a given camera.
  52147. * @param camera The camera to dispose the effect on.
  52148. */
  52149. disposeEffects(camera: Camera): void;
  52150. /**
  52151. * @hidden Internal
  52152. */
  52153. _updateEffects(): void;
  52154. /**
  52155. * Internal
  52156. * @returns if all the contained post processes are ready.
  52157. * @hidden
  52158. */
  52159. _isReady(): boolean;
  52160. }
  52161. }
  52162. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  52163. /** @hidden */
  52164. export var chromaticAberrationPixelShader: {
  52165. name: string;
  52166. shader: string;
  52167. };
  52168. }
  52169. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  52170. import { Vector2 } from "babylonjs/Maths/math";
  52171. import { Nullable } from "babylonjs/types";
  52172. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52173. import { Camera } from "babylonjs/Cameras/camera";
  52174. import { Engine } from "babylonjs/Engines/engine";
  52175. import "babylonjs/Shaders/chromaticAberration.fragment";
  52176. /**
  52177. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  52178. */
  52179. export class ChromaticAberrationPostProcess extends PostProcess {
  52180. /**
  52181. * The amount of seperation of rgb channels (default: 30)
  52182. */
  52183. aberrationAmount: number;
  52184. /**
  52185. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  52186. */
  52187. radialIntensity: number;
  52188. /**
  52189. * 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))
  52190. */
  52191. direction: Vector2;
  52192. /**
  52193. * 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))
  52194. */
  52195. centerPosition: Vector2;
  52196. /**
  52197. * Creates a new instance ChromaticAberrationPostProcess
  52198. * @param name The name of the effect.
  52199. * @param screenWidth The width of the screen to apply the effect on.
  52200. * @param screenHeight The height of the screen to apply the effect on.
  52201. * @param options The required width/height ratio to downsize to before computing the render pass.
  52202. * @param camera The camera to apply the render pass to.
  52203. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52204. * @param engine The engine which the post process will be applied. (default: current engine)
  52205. * @param reusable If the post process can be reused on the same frame. (default: false)
  52206. * @param textureType Type of textures used when performing the post process. (default: 0)
  52207. * @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)
  52208. */
  52209. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52210. }
  52211. }
  52212. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  52213. /** @hidden */
  52214. export var circleOfConfusionPixelShader: {
  52215. name: string;
  52216. shader: string;
  52217. };
  52218. }
  52219. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  52220. import { Nullable } from "babylonjs/types";
  52221. import { Engine } from "babylonjs/Engines/engine";
  52222. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52223. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52224. import { Camera } from "babylonjs/Cameras/camera";
  52225. import "babylonjs/Shaders/circleOfConfusion.fragment";
  52226. /**
  52227. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  52228. */
  52229. export class CircleOfConfusionPostProcess extends PostProcess {
  52230. /**
  52231. * 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.
  52232. */
  52233. lensSize: number;
  52234. /**
  52235. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  52236. */
  52237. fStop: number;
  52238. /**
  52239. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  52240. */
  52241. focusDistance: number;
  52242. /**
  52243. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  52244. */
  52245. focalLength: number;
  52246. private _depthTexture;
  52247. /**
  52248. * Creates a new instance CircleOfConfusionPostProcess
  52249. * @param name The name of the effect.
  52250. * @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.
  52251. * @param options The required width/height ratio to downsize to before computing the render pass.
  52252. * @param camera The camera to apply the render pass to.
  52253. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52254. * @param engine The engine which the post process will be applied. (default: current engine)
  52255. * @param reusable If the post process can be reused on the same frame. (default: false)
  52256. * @param textureType Type of textures used when performing the post process. (default: 0)
  52257. * @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)
  52258. */
  52259. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52260. /**
  52261. * 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.
  52262. */
  52263. depthTexture: RenderTargetTexture;
  52264. }
  52265. }
  52266. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  52267. /** @hidden */
  52268. export var colorCorrectionPixelShader: {
  52269. name: string;
  52270. shader: string;
  52271. };
  52272. }
  52273. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  52274. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52275. import { Engine } from "babylonjs/Engines/engine";
  52276. import { Camera } from "babylonjs/Cameras/camera";
  52277. import "babylonjs/Shaders/colorCorrection.fragment";
  52278. /**
  52279. *
  52280. * This post-process allows the modification of rendered colors by using
  52281. * a 'look-up table' (LUT). This effect is also called Color Grading.
  52282. *
  52283. * The object needs to be provided an url to a texture containing the color
  52284. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  52285. * Use an image editing software to tweak the LUT to match your needs.
  52286. *
  52287. * For an example of a color LUT, see here:
  52288. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  52289. * For explanations on color grading, see here:
  52290. * @see http://udn.epicgames.com/Three/ColorGrading.html
  52291. *
  52292. */
  52293. export class ColorCorrectionPostProcess extends PostProcess {
  52294. private _colorTableTexture;
  52295. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52296. }
  52297. }
  52298. declare module "babylonjs/Shaders/convolution.fragment" {
  52299. /** @hidden */
  52300. export var convolutionPixelShader: {
  52301. name: string;
  52302. shader: string;
  52303. };
  52304. }
  52305. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  52306. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52307. import { Nullable } from "babylonjs/types";
  52308. import { Camera } from "babylonjs/Cameras/camera";
  52309. import { Engine } from "babylonjs/Engines/engine";
  52310. import "babylonjs/Shaders/convolution.fragment";
  52311. /**
  52312. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  52313. * input texture to perform effects such as edge detection or sharpening
  52314. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  52315. */
  52316. export class ConvolutionPostProcess extends PostProcess {
  52317. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  52318. kernel: number[];
  52319. /**
  52320. * Creates a new instance ConvolutionPostProcess
  52321. * @param name The name of the effect.
  52322. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  52323. * @param options The required width/height ratio to downsize to before computing the render pass.
  52324. * @param camera The camera to apply the render pass to.
  52325. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52326. * @param engine The engine which the post process will be applied. (default: current engine)
  52327. * @param reusable If the post process can be reused on the same frame. (default: false)
  52328. * @param textureType Type of textures used when performing the post process. (default: 0)
  52329. */
  52330. constructor(name: string,
  52331. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  52332. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52333. /**
  52334. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52335. */
  52336. static EdgeDetect0Kernel: number[];
  52337. /**
  52338. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52339. */
  52340. static EdgeDetect1Kernel: number[];
  52341. /**
  52342. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52343. */
  52344. static EdgeDetect2Kernel: number[];
  52345. /**
  52346. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52347. */
  52348. static SharpenKernel: number[];
  52349. /**
  52350. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52351. */
  52352. static EmbossKernel: number[];
  52353. /**
  52354. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52355. */
  52356. static GaussianKernel: number[];
  52357. }
  52358. }
  52359. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  52360. import { Nullable } from "babylonjs/types";
  52361. import { Vector2 } from "babylonjs/Maths/math";
  52362. import { Camera } from "babylonjs/Cameras/camera";
  52363. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52364. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  52365. import { Engine } from "babylonjs/Engines/engine";
  52366. import { Scene } from "babylonjs/scene";
  52367. /**
  52368. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  52369. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  52370. * based on samples that have a large difference in distance than the center pixel.
  52371. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  52372. */
  52373. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  52374. direction: Vector2;
  52375. /**
  52376. * Creates a new instance CircleOfConfusionPostProcess
  52377. * @param name The name of the effect.
  52378. * @param scene The scene the effect belongs to.
  52379. * @param direction The direction the blur should be applied.
  52380. * @param kernel The size of the kernel used to blur.
  52381. * @param options The required width/height ratio to downsize to before computing the render pass.
  52382. * @param camera The camera to apply the render pass to.
  52383. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  52384. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  52385. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52386. * @param engine The engine which the post process will be applied. (default: current engine)
  52387. * @param reusable If the post process can be reused on the same frame. (default: false)
  52388. * @param textureType Type of textures used when performing the post process. (default: 0)
  52389. * @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)
  52390. */
  52391. 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);
  52392. }
  52393. }
  52394. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  52395. /** @hidden */
  52396. export var depthOfFieldMergePixelShader: {
  52397. name: string;
  52398. shader: string;
  52399. };
  52400. }
  52401. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  52402. import { Nullable } from "babylonjs/types";
  52403. import { Camera } from "babylonjs/Cameras/camera";
  52404. import { Effect } from "babylonjs/Materials/effect";
  52405. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52406. import { Engine } from "babylonjs/Engines/engine";
  52407. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  52408. /**
  52409. * Options to be set when merging outputs from the default pipeline.
  52410. */
  52411. export class DepthOfFieldMergePostProcessOptions {
  52412. /**
  52413. * The original image to merge on top of
  52414. */
  52415. originalFromInput: PostProcess;
  52416. /**
  52417. * Parameters to perform the merge of the depth of field effect
  52418. */
  52419. depthOfField?: {
  52420. circleOfConfusion: PostProcess;
  52421. blurSteps: Array<PostProcess>;
  52422. };
  52423. /**
  52424. * Parameters to perform the merge of bloom effect
  52425. */
  52426. bloom?: {
  52427. blurred: PostProcess;
  52428. weight: number;
  52429. };
  52430. }
  52431. /**
  52432. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  52433. */
  52434. export class DepthOfFieldMergePostProcess extends PostProcess {
  52435. private blurSteps;
  52436. /**
  52437. * Creates a new instance of DepthOfFieldMergePostProcess
  52438. * @param name The name of the effect.
  52439. * @param originalFromInput Post process which's input will be used for the merge.
  52440. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  52441. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  52442. * @param options The required width/height ratio to downsize to before computing the render pass.
  52443. * @param camera The camera to apply the render pass to.
  52444. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52445. * @param engine The engine which the post process will be applied. (default: current engine)
  52446. * @param reusable If the post process can be reused on the same frame. (default: false)
  52447. * @param textureType Type of textures used when performing the post process. (default: 0)
  52448. * @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)
  52449. */
  52450. 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);
  52451. /**
  52452. * Updates the effect with the current post process compile time values and recompiles the shader.
  52453. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  52454. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  52455. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  52456. * @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
  52457. * @param onCompiled Called when the shader has been compiled.
  52458. * @param onError Called if there is an error when compiling a shader.
  52459. */
  52460. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  52461. }
  52462. }
  52463. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  52464. import { Nullable } from "babylonjs/types";
  52465. import { Camera } from "babylonjs/Cameras/camera";
  52466. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52467. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52468. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  52469. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  52470. import { Scene } from "babylonjs/scene";
  52471. /**
  52472. * Specifies the level of max blur that should be applied when using the depth of field effect
  52473. */
  52474. export enum DepthOfFieldEffectBlurLevel {
  52475. /**
  52476. * Subtle blur
  52477. */
  52478. Low = 0,
  52479. /**
  52480. * Medium blur
  52481. */
  52482. Medium = 1,
  52483. /**
  52484. * Large blur
  52485. */
  52486. High = 2
  52487. }
  52488. /**
  52489. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  52490. */
  52491. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  52492. private _circleOfConfusion;
  52493. /**
  52494. * @hidden Internal, blurs from high to low
  52495. */
  52496. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  52497. private _depthOfFieldBlurY;
  52498. private _dofMerge;
  52499. /**
  52500. * @hidden Internal post processes in depth of field effect
  52501. */
  52502. _effects: Array<PostProcess>;
  52503. /**
  52504. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  52505. */
  52506. focalLength: number;
  52507. /**
  52508. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  52509. */
  52510. fStop: number;
  52511. /**
  52512. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  52513. */
  52514. focusDistance: number;
  52515. /**
  52516. * 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.
  52517. */
  52518. lensSize: number;
  52519. /**
  52520. * Creates a new instance DepthOfFieldEffect
  52521. * @param scene The scene the effect belongs to.
  52522. * @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.
  52523. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52524. * @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)
  52525. */
  52526. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  52527. /**
  52528. * 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.
  52529. */
  52530. depthTexture: RenderTargetTexture;
  52531. /**
  52532. * Disposes each of the internal effects for a given camera.
  52533. * @param camera The camera to dispose the effect on.
  52534. */
  52535. disposeEffects(camera: Camera): void;
  52536. /**
  52537. * @hidden Internal
  52538. */
  52539. _updateEffects(): void;
  52540. /**
  52541. * Internal
  52542. * @returns if all the contained post processes are ready.
  52543. * @hidden
  52544. */
  52545. _isReady(): boolean;
  52546. }
  52547. }
  52548. declare module "babylonjs/Shaders/displayPass.fragment" {
  52549. /** @hidden */
  52550. export var displayPassPixelShader: {
  52551. name: string;
  52552. shader: string;
  52553. };
  52554. }
  52555. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  52556. import { Nullable } from "babylonjs/types";
  52557. import { Camera } from "babylonjs/Cameras/camera";
  52558. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52559. import { Engine } from "babylonjs/Engines/engine";
  52560. import "babylonjs/Shaders/displayPass.fragment";
  52561. /**
  52562. * DisplayPassPostProcess which produces an output the same as it's input
  52563. */
  52564. export class DisplayPassPostProcess extends PostProcess {
  52565. /**
  52566. * Creates the DisplayPassPostProcess
  52567. * @param name The name of the effect.
  52568. * @param options The required width/height ratio to downsize to before computing the render pass.
  52569. * @param camera The camera to apply the render pass to.
  52570. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52571. * @param engine The engine which the post process will be applied. (default: current engine)
  52572. * @param reusable If the post process can be reused on the same frame. (default: false)
  52573. */
  52574. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52575. }
  52576. }
  52577. declare module "babylonjs/Shaders/filter.fragment" {
  52578. /** @hidden */
  52579. export var filterPixelShader: {
  52580. name: string;
  52581. shader: string;
  52582. };
  52583. }
  52584. declare module "babylonjs/PostProcesses/filterPostProcess" {
  52585. import { Nullable } from "babylonjs/types";
  52586. import { Matrix } from "babylonjs/Maths/math";
  52587. import { Camera } from "babylonjs/Cameras/camera";
  52588. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52589. import { Engine } from "babylonjs/Engines/engine";
  52590. import "babylonjs/Shaders/filter.fragment";
  52591. /**
  52592. * Applies a kernel filter to the image
  52593. */
  52594. export class FilterPostProcess extends PostProcess {
  52595. /** The matrix to be applied to the image */
  52596. kernelMatrix: Matrix;
  52597. /**
  52598. *
  52599. * @param name The name of the effect.
  52600. * @param kernelMatrix The matrix to be applied to the image
  52601. * @param options The required width/height ratio to downsize to before computing the render pass.
  52602. * @param camera The camera to apply the render pass to.
  52603. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52604. * @param engine The engine which the post process will be applied. (default: current engine)
  52605. * @param reusable If the post process can be reused on the same frame. (default: false)
  52606. */
  52607. constructor(name: string,
  52608. /** The matrix to be applied to the image */
  52609. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52610. }
  52611. }
  52612. declare module "babylonjs/Shaders/fxaa.fragment" {
  52613. /** @hidden */
  52614. export var fxaaPixelShader: {
  52615. name: string;
  52616. shader: string;
  52617. };
  52618. }
  52619. declare module "babylonjs/Shaders/fxaa.vertex" {
  52620. /** @hidden */
  52621. export var fxaaVertexShader: {
  52622. name: string;
  52623. shader: string;
  52624. };
  52625. }
  52626. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  52627. import { Nullable } from "babylonjs/types";
  52628. import { Camera } from "babylonjs/Cameras/camera";
  52629. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52630. import { Engine } from "babylonjs/Engines/engine";
  52631. import "babylonjs/Shaders/fxaa.fragment";
  52632. import "babylonjs/Shaders/fxaa.vertex";
  52633. /**
  52634. * Fxaa post process
  52635. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  52636. */
  52637. export class FxaaPostProcess extends PostProcess {
  52638. /** @hidden */
  52639. texelWidth: number;
  52640. /** @hidden */
  52641. texelHeight: number;
  52642. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52643. private _getDefines;
  52644. }
  52645. }
  52646. declare module "babylonjs/Shaders/grain.fragment" {
  52647. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52648. /** @hidden */
  52649. export var grainPixelShader: {
  52650. name: string;
  52651. shader: string;
  52652. };
  52653. }
  52654. declare module "babylonjs/PostProcesses/grainPostProcess" {
  52655. import { Nullable } from "babylonjs/types";
  52656. import { Camera } from "babylonjs/Cameras/camera";
  52657. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52658. import { Engine } from "babylonjs/Engines/engine";
  52659. import "babylonjs/Shaders/grain.fragment";
  52660. /**
  52661. * The GrainPostProcess adds noise to the image at mid luminance levels
  52662. */
  52663. export class GrainPostProcess extends PostProcess {
  52664. /**
  52665. * The intensity of the grain added (default: 30)
  52666. */
  52667. intensity: number;
  52668. /**
  52669. * If the grain should be randomized on every frame
  52670. */
  52671. animated: boolean;
  52672. /**
  52673. * Creates a new instance of @see GrainPostProcess
  52674. * @param name The name of the effect.
  52675. * @param options The required width/height ratio to downsize to before computing the render pass.
  52676. * @param camera The camera to apply the render pass to.
  52677. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52678. * @param engine The engine which the post process will be applied. (default: current engine)
  52679. * @param reusable If the post process can be reused on the same frame. (default: false)
  52680. * @param textureType Type of textures used when performing the post process. (default: 0)
  52681. * @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)
  52682. */
  52683. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52684. }
  52685. }
  52686. declare module "babylonjs/Shaders/highlights.fragment" {
  52687. /** @hidden */
  52688. export var highlightsPixelShader: {
  52689. name: string;
  52690. shader: string;
  52691. };
  52692. }
  52693. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  52694. import { Nullable } from "babylonjs/types";
  52695. import { Camera } from "babylonjs/Cameras/camera";
  52696. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52697. import { Engine } from "babylonjs/Engines/engine";
  52698. import "babylonjs/Shaders/highlights.fragment";
  52699. /**
  52700. * Extracts highlights from the image
  52701. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  52702. */
  52703. export class HighlightsPostProcess extends PostProcess {
  52704. /**
  52705. * Extracts highlights from the image
  52706. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  52707. * @param name The name of the effect.
  52708. * @param options The required width/height ratio to downsize to before computing the render pass.
  52709. * @param camera The camera to apply the render pass to.
  52710. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52711. * @param engine The engine which the post process will be applied. (default: current engine)
  52712. * @param reusable If the post process can be reused on the same frame. (default: false)
  52713. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  52714. */
  52715. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52716. }
  52717. }
  52718. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  52719. /** @hidden */
  52720. export var mrtFragmentDeclaration: {
  52721. name: string;
  52722. shader: string;
  52723. };
  52724. }
  52725. declare module "babylonjs/Shaders/geometry.fragment" {
  52726. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  52727. /** @hidden */
  52728. export var geometryPixelShader: {
  52729. name: string;
  52730. shader: string;
  52731. };
  52732. }
  52733. declare module "babylonjs/Shaders/geometry.vertex" {
  52734. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  52735. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  52736. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  52737. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  52738. /** @hidden */
  52739. export var geometryVertexShader: {
  52740. name: string;
  52741. shader: string;
  52742. };
  52743. }
  52744. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  52745. import { Matrix } from "babylonjs/Maths/math";
  52746. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52747. import { Mesh } from "babylonjs/Meshes/mesh";
  52748. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  52749. import { Effect } from "babylonjs/Materials/effect";
  52750. import { Scene } from "babylonjs/scene";
  52751. import "babylonjs/Shaders/geometry.fragment";
  52752. import "babylonjs/Shaders/geometry.vertex";
  52753. /**
  52754. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  52755. */
  52756. export class GeometryBufferRenderer {
  52757. /**
  52758. * Constant used to retrieve the position texture index in the G-Buffer textures array
  52759. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  52760. */
  52761. static readonly POSITION_TEXTURE_TYPE: number;
  52762. /**
  52763. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  52764. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  52765. */
  52766. static readonly VELOCITY_TEXTURE_TYPE: number;
  52767. /**
  52768. * Dictionary used to store the previous transformation matrices of each rendered mesh
  52769. * in order to compute objects velocities when enableVelocity is set to "true"
  52770. * @hidden
  52771. */
  52772. _previousTransformationMatrices: {
  52773. [index: number]: Matrix;
  52774. };
  52775. private _scene;
  52776. private _multiRenderTarget;
  52777. private _ratio;
  52778. private _enablePosition;
  52779. private _enableVelocity;
  52780. private _positionIndex;
  52781. private _velocityIndex;
  52782. protected _effect: Effect;
  52783. protected _cachedDefines: string;
  52784. /**
  52785. * Set the render list (meshes to be rendered) used in the G buffer.
  52786. */
  52787. renderList: Mesh[];
  52788. /**
  52789. * Gets wether or not G buffer are supported by the running hardware.
  52790. * This requires draw buffer supports
  52791. */
  52792. readonly isSupported: boolean;
  52793. /**
  52794. * Returns the index of the given texture type in the G-Buffer textures array
  52795. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  52796. * @returns the index of the given texture type in the G-Buffer textures array
  52797. */
  52798. getTextureIndex(textureType: number): number;
  52799. /**
  52800. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  52801. */
  52802. /**
  52803. * Sets whether or not objects positions are enabled for the G buffer.
  52804. */
  52805. enablePosition: boolean;
  52806. /**
  52807. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  52808. */
  52809. /**
  52810. * Sets wether or not objects velocities are enabled for the G buffer.
  52811. */
  52812. enableVelocity: boolean;
  52813. /**
  52814. * Gets the scene associated with the buffer.
  52815. */
  52816. readonly scene: Scene;
  52817. /**
  52818. * Gets the ratio used by the buffer during its creation.
  52819. * How big is the buffer related to the main canvas.
  52820. */
  52821. readonly ratio: number;
  52822. /** @hidden */
  52823. static _SceneComponentInitialization: (scene: Scene) => void;
  52824. /**
  52825. * Creates a new G Buffer for the scene
  52826. * @param scene The scene the buffer belongs to
  52827. * @param ratio How big is the buffer related to the main canvas.
  52828. */
  52829. constructor(scene: Scene, ratio?: number);
  52830. /**
  52831. * Checks wether everything is ready to render a submesh to the G buffer.
  52832. * @param subMesh the submesh to check readiness for
  52833. * @param useInstances is the mesh drawn using instance or not
  52834. * @returns true if ready otherwise false
  52835. */
  52836. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52837. /**
  52838. * Gets the current underlying G Buffer.
  52839. * @returns the buffer
  52840. */
  52841. getGBuffer(): MultiRenderTarget;
  52842. /**
  52843. * Gets the number of samples used to render the buffer (anti aliasing).
  52844. */
  52845. /**
  52846. * Sets the number of samples used to render the buffer (anti aliasing).
  52847. */
  52848. samples: number;
  52849. /**
  52850. * Disposes the renderer and frees up associated resources.
  52851. */
  52852. dispose(): void;
  52853. protected _createRenderTargets(): void;
  52854. }
  52855. }
  52856. declare module "babylonjs/Shaders/motionBlur.fragment" {
  52857. /** @hidden */
  52858. export var motionBlurPixelShader: {
  52859. name: string;
  52860. shader: string;
  52861. };
  52862. }
  52863. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  52864. import { Nullable } from "babylonjs/types";
  52865. import { Camera } from "babylonjs/Cameras/camera";
  52866. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52867. import { Scene } from "babylonjs/scene";
  52868. import "babylonjs/Shaders/motionBlur.fragment";
  52869. import { Engine } from "babylonjs/Engines/engine";
  52870. /**
  52871. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  52872. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  52873. * As an example, all you have to do is to create the post-process:
  52874. * var mb = new BABYLON.MotionBlurPostProcess(
  52875. * 'mb', // The name of the effect.
  52876. * scene, // The scene containing the objects to blur according to their velocity.
  52877. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  52878. * camera // The camera to apply the render pass to.
  52879. * );
  52880. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  52881. */
  52882. export class MotionBlurPostProcess extends PostProcess {
  52883. /**
  52884. * Defines how much the image is blurred by the movement. Default value is equal to 1
  52885. */
  52886. motionStrength: number;
  52887. /**
  52888. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  52889. */
  52890. /**
  52891. * Sets the number of iterations to be used for motion blur quality
  52892. */
  52893. motionBlurSamples: number;
  52894. private _motionBlurSamples;
  52895. private _geometryBufferRenderer;
  52896. /**
  52897. * Creates a new instance MotionBlurPostProcess
  52898. * @param name The name of the effect.
  52899. * @param scene The scene containing the objects to blur according to their velocity.
  52900. * @param options The required width/height ratio to downsize to before computing the render pass.
  52901. * @param camera The camera to apply the render pass to.
  52902. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52903. * @param engine The engine which the post process will be applied. (default: current engine)
  52904. * @param reusable If the post process can be reused on the same frame. (default: false)
  52905. * @param textureType Type of textures used when performing the post process. (default: 0)
  52906. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  52907. */
  52908. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52909. /**
  52910. * Disposes the post process.
  52911. * @param camera The camera to dispose the post process on.
  52912. */
  52913. dispose(camera?: Camera): void;
  52914. }
  52915. }
  52916. declare module "babylonjs/Shaders/refraction.fragment" {
  52917. /** @hidden */
  52918. export var refractionPixelShader: {
  52919. name: string;
  52920. shader: string;
  52921. };
  52922. }
  52923. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  52924. import { Color3 } from "babylonjs/Maths/math";
  52925. import { Camera } from "babylonjs/Cameras/camera";
  52926. import { Texture } from "babylonjs/Materials/Textures/texture";
  52927. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52928. import { Engine } from "babylonjs/Engines/engine";
  52929. import "babylonjs/Shaders/refraction.fragment";
  52930. /**
  52931. * Post process which applies a refractin texture
  52932. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  52933. */
  52934. export class RefractionPostProcess extends PostProcess {
  52935. /** the base color of the refraction (used to taint the rendering) */
  52936. color: Color3;
  52937. /** simulated refraction depth */
  52938. depth: number;
  52939. /** the coefficient of the base color (0 to remove base color tainting) */
  52940. colorLevel: number;
  52941. private _refTexture;
  52942. private _ownRefractionTexture;
  52943. /**
  52944. * Gets or sets the refraction texture
  52945. * Please note that you are responsible for disposing the texture if you set it manually
  52946. */
  52947. refractionTexture: Texture;
  52948. /**
  52949. * Initializes the RefractionPostProcess
  52950. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  52951. * @param name The name of the effect.
  52952. * @param refractionTextureUrl Url of the refraction texture to use
  52953. * @param color the base color of the refraction (used to taint the rendering)
  52954. * @param depth simulated refraction depth
  52955. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  52956. * @param camera The camera to apply the render pass to.
  52957. * @param options The required width/height ratio to downsize to before computing the render pass.
  52958. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52959. * @param engine The engine which the post process will be applied. (default: current engine)
  52960. * @param reusable If the post process can be reused on the same frame. (default: false)
  52961. */
  52962. constructor(name: string, refractionTextureUrl: string,
  52963. /** the base color of the refraction (used to taint the rendering) */
  52964. color: Color3,
  52965. /** simulated refraction depth */
  52966. depth: number,
  52967. /** the coefficient of the base color (0 to remove base color tainting) */
  52968. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52969. /**
  52970. * Disposes of the post process
  52971. * @param camera Camera to dispose post process on
  52972. */
  52973. dispose(camera: Camera): void;
  52974. }
  52975. }
  52976. declare module "babylonjs/Shaders/sharpen.fragment" {
  52977. /** @hidden */
  52978. export var sharpenPixelShader: {
  52979. name: string;
  52980. shader: string;
  52981. };
  52982. }
  52983. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  52984. import { Nullable } from "babylonjs/types";
  52985. import { Camera } from "babylonjs/Cameras/camera";
  52986. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52987. import "babylonjs/Shaders/sharpen.fragment";
  52988. import { Engine } from "babylonjs/Engines/engine";
  52989. /**
  52990. * The SharpenPostProcess applies a sharpen kernel to every pixel
  52991. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  52992. */
  52993. export class SharpenPostProcess extends PostProcess {
  52994. /**
  52995. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  52996. */
  52997. colorAmount: number;
  52998. /**
  52999. * How much sharpness should be applied (default: 0.3)
  53000. */
  53001. edgeAmount: number;
  53002. /**
  53003. * Creates a new instance ConvolutionPostProcess
  53004. * @param name The name of the effect.
  53005. * @param options The required width/height ratio to downsize to before computing the render pass.
  53006. * @param camera The camera to apply the render pass to.
  53007. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53008. * @param engine The engine which the post process will be applied. (default: current engine)
  53009. * @param reusable If the post process can be reused on the same frame. (default: false)
  53010. * @param textureType Type of textures used when performing the post process. (default: 0)
  53011. * @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)
  53012. */
  53013. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53014. }
  53015. }
  53016. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  53017. import { Nullable } from "babylonjs/types";
  53018. import { Camera } from "babylonjs/Cameras/camera";
  53019. import { Engine } from "babylonjs/Engines/engine";
  53020. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  53021. /**
  53022. * PostProcessRenderPipeline
  53023. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53024. */
  53025. export class PostProcessRenderPipeline {
  53026. private engine;
  53027. private _renderEffects;
  53028. private _renderEffectsForIsolatedPass;
  53029. /**
  53030. * @hidden
  53031. */
  53032. protected _cameras: Camera[];
  53033. /** @hidden */
  53034. _name: string;
  53035. /**
  53036. * Gets pipeline name
  53037. */
  53038. readonly name: string;
  53039. /**
  53040. * Initializes a PostProcessRenderPipeline
  53041. * @param engine engine to add the pipeline to
  53042. * @param name name of the pipeline
  53043. */
  53044. constructor(engine: Engine, name: string);
  53045. /**
  53046. * Gets the class name
  53047. * @returns "PostProcessRenderPipeline"
  53048. */
  53049. getClassName(): string;
  53050. /**
  53051. * If all the render effects in the pipeline are supported
  53052. */
  53053. readonly isSupported: boolean;
  53054. /**
  53055. * Adds an effect to the pipeline
  53056. * @param renderEffect the effect to add
  53057. */
  53058. addEffect(renderEffect: PostProcessRenderEffect): void;
  53059. /** @hidden */
  53060. _rebuild(): void;
  53061. /** @hidden */
  53062. _enableEffect(renderEffectName: string, cameras: Camera): void;
  53063. /** @hidden */
  53064. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  53065. /** @hidden */
  53066. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  53067. /** @hidden */
  53068. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  53069. /** @hidden */
  53070. _attachCameras(cameras: Camera, unique: boolean): void;
  53071. /** @hidden */
  53072. _attachCameras(cameras: Camera[], unique: boolean): void;
  53073. /** @hidden */
  53074. _detachCameras(cameras: Camera): void;
  53075. /** @hidden */
  53076. _detachCameras(cameras: Nullable<Camera[]>): void;
  53077. /** @hidden */
  53078. _update(): void;
  53079. /** @hidden */
  53080. _reset(): void;
  53081. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  53082. /**
  53083. * Disposes of the pipeline
  53084. */
  53085. dispose(): void;
  53086. }
  53087. }
  53088. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  53089. import { IAnimatable } from "babylonjs/Misc/tools";
  53090. import { Camera } from "babylonjs/Cameras/camera";
  53091. import { IDisposable } from "babylonjs/scene";
  53092. import { Scene } from "babylonjs/scene";
  53093. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  53094. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  53095. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  53096. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  53097. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  53098. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53099. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  53100. import { Animation } from "babylonjs/Animations/animation";
  53101. /**
  53102. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  53103. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  53104. */
  53105. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  53106. private _scene;
  53107. private _camerasToBeAttached;
  53108. /**
  53109. * ID of the sharpen post process,
  53110. */
  53111. private readonly SharpenPostProcessId;
  53112. /**
  53113. * @ignore
  53114. * ID of the image processing post process;
  53115. */
  53116. readonly ImageProcessingPostProcessId: string;
  53117. /**
  53118. * @ignore
  53119. * ID of the Fast Approximate Anti-Aliasing post process;
  53120. */
  53121. readonly FxaaPostProcessId: string;
  53122. /**
  53123. * ID of the chromatic aberration post process,
  53124. */
  53125. private readonly ChromaticAberrationPostProcessId;
  53126. /**
  53127. * ID of the grain post process
  53128. */
  53129. private readonly GrainPostProcessId;
  53130. /**
  53131. * Sharpen post process which will apply a sharpen convolution to enhance edges
  53132. */
  53133. sharpen: SharpenPostProcess;
  53134. private _sharpenEffect;
  53135. private bloom;
  53136. /**
  53137. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  53138. */
  53139. depthOfField: DepthOfFieldEffect;
  53140. /**
  53141. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  53142. */
  53143. fxaa: FxaaPostProcess;
  53144. /**
  53145. * Image post processing pass used to perform operations such as tone mapping or color grading.
  53146. */
  53147. imageProcessing: ImageProcessingPostProcess;
  53148. /**
  53149. * Chromatic aberration post process which will shift rgb colors in the image
  53150. */
  53151. chromaticAberration: ChromaticAberrationPostProcess;
  53152. private _chromaticAberrationEffect;
  53153. /**
  53154. * Grain post process which add noise to the image
  53155. */
  53156. grain: GrainPostProcess;
  53157. private _grainEffect;
  53158. /**
  53159. * Glow post process which adds a glow to emissive areas of the image
  53160. */
  53161. private _glowLayer;
  53162. /**
  53163. * Animations which can be used to tweak settings over a period of time
  53164. */
  53165. animations: Animation[];
  53166. private _imageProcessingConfigurationObserver;
  53167. private _sharpenEnabled;
  53168. private _bloomEnabled;
  53169. private _depthOfFieldEnabled;
  53170. private _depthOfFieldBlurLevel;
  53171. private _fxaaEnabled;
  53172. private _imageProcessingEnabled;
  53173. private _defaultPipelineTextureType;
  53174. private _bloomScale;
  53175. private _chromaticAberrationEnabled;
  53176. private _grainEnabled;
  53177. private _buildAllowed;
  53178. /**
  53179. * Gets active scene
  53180. */
  53181. readonly scene: Scene;
  53182. /**
  53183. * Enable or disable the sharpen process from the pipeline
  53184. */
  53185. sharpenEnabled: boolean;
  53186. private _resizeObserver;
  53187. private _hardwareScaleLevel;
  53188. private _bloomKernel;
  53189. /**
  53190. * Specifies the size of the bloom blur kernel, relative to the final output size
  53191. */
  53192. bloomKernel: number;
  53193. /**
  53194. * Specifies the weight of the bloom in the final rendering
  53195. */
  53196. private _bloomWeight;
  53197. /**
  53198. * Specifies the luma threshold for the area that will be blurred by the bloom
  53199. */
  53200. private _bloomThreshold;
  53201. private _hdr;
  53202. /**
  53203. * The strength of the bloom.
  53204. */
  53205. bloomWeight: number;
  53206. /**
  53207. * The strength of the bloom.
  53208. */
  53209. bloomThreshold: number;
  53210. /**
  53211. * The scale of the bloom, lower value will provide better performance.
  53212. */
  53213. bloomScale: number;
  53214. /**
  53215. * Enable or disable the bloom from the pipeline
  53216. */
  53217. bloomEnabled: boolean;
  53218. private _rebuildBloom;
  53219. /**
  53220. * If the depth of field is enabled.
  53221. */
  53222. depthOfFieldEnabled: boolean;
  53223. /**
  53224. * Blur level of the depth of field effect. (Higher blur will effect performance)
  53225. */
  53226. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  53227. /**
  53228. * If the anti aliasing is enabled.
  53229. */
  53230. fxaaEnabled: boolean;
  53231. private _samples;
  53232. /**
  53233. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  53234. */
  53235. samples: number;
  53236. /**
  53237. * If image processing is enabled.
  53238. */
  53239. imageProcessingEnabled: boolean;
  53240. /**
  53241. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  53242. */
  53243. glowLayerEnabled: boolean;
  53244. /**
  53245. * Enable or disable the chromaticAberration process from the pipeline
  53246. */
  53247. chromaticAberrationEnabled: boolean;
  53248. /**
  53249. * Enable or disable the grain process from the pipeline
  53250. */
  53251. grainEnabled: boolean;
  53252. /**
  53253. * @constructor
  53254. * @param name - The rendering pipeline name (default: "")
  53255. * @param hdr - If high dynamic range textures should be used (default: true)
  53256. * @param scene - The scene linked to this pipeline (default: the last created scene)
  53257. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  53258. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  53259. */
  53260. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  53261. /**
  53262. * Get the class name
  53263. * @returns "DefaultRenderingPipeline"
  53264. */
  53265. getClassName(): string;
  53266. /**
  53267. * Force the compilation of the entire pipeline.
  53268. */
  53269. prepare(): void;
  53270. private _hasCleared;
  53271. private _prevPostProcess;
  53272. private _prevPrevPostProcess;
  53273. private _setAutoClearAndTextureSharing;
  53274. private _depthOfFieldSceneObserver;
  53275. private _buildPipeline;
  53276. private _disposePostProcesses;
  53277. /**
  53278. * Adds a camera to the pipeline
  53279. * @param camera the camera to be added
  53280. */
  53281. addCamera(camera: Camera): void;
  53282. /**
  53283. * Removes a camera from the pipeline
  53284. * @param camera the camera to remove
  53285. */
  53286. removeCamera(camera: Camera): void;
  53287. /**
  53288. * Dispose of the pipeline and stop all post processes
  53289. */
  53290. dispose(): void;
  53291. /**
  53292. * Serialize the rendering pipeline (Used when exporting)
  53293. * @returns the serialized object
  53294. */
  53295. serialize(): any;
  53296. /**
  53297. * Parse the serialized pipeline
  53298. * @param source Source pipeline.
  53299. * @param scene The scene to load the pipeline to.
  53300. * @param rootUrl The URL of the serialized pipeline.
  53301. * @returns An instantiated pipeline from the serialized object.
  53302. */
  53303. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  53304. }
  53305. }
  53306. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  53307. /** @hidden */
  53308. export var lensHighlightsPixelShader: {
  53309. name: string;
  53310. shader: string;
  53311. };
  53312. }
  53313. declare module "babylonjs/Shaders/depthOfField.fragment" {
  53314. /** @hidden */
  53315. export var depthOfFieldPixelShader: {
  53316. name: string;
  53317. shader: string;
  53318. };
  53319. }
  53320. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  53321. import { Camera } from "babylonjs/Cameras/camera";
  53322. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53323. import { Scene } from "babylonjs/scene";
  53324. import "babylonjs/Shaders/chromaticAberration.fragment";
  53325. import "babylonjs/Shaders/lensHighlights.fragment";
  53326. import "babylonjs/Shaders/depthOfField.fragment";
  53327. /**
  53328. * BABYLON.JS Chromatic Aberration GLSL Shader
  53329. * Author: Olivier Guyot
  53330. * Separates very slightly R, G and B colors on the edges of the screen
  53331. * Inspired by Francois Tarlier & Martins Upitis
  53332. */
  53333. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  53334. /**
  53335. * @ignore
  53336. * The chromatic aberration PostProcess id in the pipeline
  53337. */
  53338. LensChromaticAberrationEffect: string;
  53339. /**
  53340. * @ignore
  53341. * The highlights enhancing PostProcess id in the pipeline
  53342. */
  53343. HighlightsEnhancingEffect: string;
  53344. /**
  53345. * @ignore
  53346. * The depth-of-field PostProcess id in the pipeline
  53347. */
  53348. LensDepthOfFieldEffect: string;
  53349. private _scene;
  53350. private _depthTexture;
  53351. private _grainTexture;
  53352. private _chromaticAberrationPostProcess;
  53353. private _highlightsPostProcess;
  53354. private _depthOfFieldPostProcess;
  53355. private _edgeBlur;
  53356. private _grainAmount;
  53357. private _chromaticAberration;
  53358. private _distortion;
  53359. private _highlightsGain;
  53360. private _highlightsThreshold;
  53361. private _dofDistance;
  53362. private _dofAperture;
  53363. private _dofDarken;
  53364. private _dofPentagon;
  53365. private _blurNoise;
  53366. /**
  53367. * @constructor
  53368. *
  53369. * Effect parameters are as follow:
  53370. * {
  53371. * chromatic_aberration: number; // from 0 to x (1 for realism)
  53372. * edge_blur: number; // from 0 to x (1 for realism)
  53373. * distortion: number; // from 0 to x (1 for realism)
  53374. * grain_amount: number; // from 0 to 1
  53375. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  53376. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  53377. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  53378. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  53379. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  53380. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  53381. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  53382. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  53383. * }
  53384. * Note: if an effect parameter is unset, effect is disabled
  53385. *
  53386. * @param name The rendering pipeline name
  53387. * @param parameters - An object containing all parameters (see above)
  53388. * @param scene The scene linked to this pipeline
  53389. * @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)
  53390. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53391. */
  53392. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  53393. /**
  53394. * Sets the amount of blur at the edges
  53395. * @param amount blur amount
  53396. */
  53397. setEdgeBlur(amount: number): void;
  53398. /**
  53399. * Sets edge blur to 0
  53400. */
  53401. disableEdgeBlur(): void;
  53402. /**
  53403. * Sets the amout of grain
  53404. * @param amount Amount of grain
  53405. */
  53406. setGrainAmount(amount: number): void;
  53407. /**
  53408. * Set grain amount to 0
  53409. */
  53410. disableGrain(): void;
  53411. /**
  53412. * Sets the chromatic aberration amount
  53413. * @param amount amount of chromatic aberration
  53414. */
  53415. setChromaticAberration(amount: number): void;
  53416. /**
  53417. * Sets chromatic aberration amount to 0
  53418. */
  53419. disableChromaticAberration(): void;
  53420. /**
  53421. * Sets the EdgeDistortion amount
  53422. * @param amount amount of EdgeDistortion
  53423. */
  53424. setEdgeDistortion(amount: number): void;
  53425. /**
  53426. * Sets edge distortion to 0
  53427. */
  53428. disableEdgeDistortion(): void;
  53429. /**
  53430. * Sets the FocusDistance amount
  53431. * @param amount amount of FocusDistance
  53432. */
  53433. setFocusDistance(amount: number): void;
  53434. /**
  53435. * Disables depth of field
  53436. */
  53437. disableDepthOfField(): void;
  53438. /**
  53439. * Sets the Aperture amount
  53440. * @param amount amount of Aperture
  53441. */
  53442. setAperture(amount: number): void;
  53443. /**
  53444. * Sets the DarkenOutOfFocus amount
  53445. * @param amount amount of DarkenOutOfFocus
  53446. */
  53447. setDarkenOutOfFocus(amount: number): void;
  53448. /**
  53449. * Creates a pentagon bokeh effect
  53450. */
  53451. enablePentagonBokeh(): void;
  53452. /**
  53453. * Disables the pentagon bokeh effect
  53454. */
  53455. disablePentagonBokeh(): void;
  53456. /**
  53457. * Enables noise blur
  53458. */
  53459. enableNoiseBlur(): void;
  53460. /**
  53461. * Disables noise blur
  53462. */
  53463. disableNoiseBlur(): void;
  53464. /**
  53465. * Sets the HighlightsGain amount
  53466. * @param amount amount of HighlightsGain
  53467. */
  53468. setHighlightsGain(amount: number): void;
  53469. /**
  53470. * Sets the HighlightsThreshold amount
  53471. * @param amount amount of HighlightsThreshold
  53472. */
  53473. setHighlightsThreshold(amount: number): void;
  53474. /**
  53475. * Disables highlights
  53476. */
  53477. disableHighlights(): void;
  53478. /**
  53479. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  53480. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  53481. */
  53482. dispose(disableDepthRender?: boolean): void;
  53483. private _createChromaticAberrationPostProcess;
  53484. private _createHighlightsPostProcess;
  53485. private _createDepthOfFieldPostProcess;
  53486. private _createGrainTexture;
  53487. }
  53488. }
  53489. declare module "babylonjs/Shaders/ssao2.fragment" {
  53490. /** @hidden */
  53491. export var ssao2PixelShader: {
  53492. name: string;
  53493. shader: string;
  53494. };
  53495. }
  53496. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  53497. /** @hidden */
  53498. export var ssaoCombinePixelShader: {
  53499. name: string;
  53500. shader: string;
  53501. };
  53502. }
  53503. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  53504. import { Camera } from "babylonjs/Cameras/camera";
  53505. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53506. import { Scene } from "babylonjs/scene";
  53507. import "babylonjs/Shaders/ssao2.fragment";
  53508. import "babylonjs/Shaders/ssaoCombine.fragment";
  53509. /**
  53510. * Render pipeline to produce ssao effect
  53511. */
  53512. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  53513. /**
  53514. * @ignore
  53515. * The PassPostProcess id in the pipeline that contains the original scene color
  53516. */
  53517. SSAOOriginalSceneColorEffect: string;
  53518. /**
  53519. * @ignore
  53520. * The SSAO PostProcess id in the pipeline
  53521. */
  53522. SSAORenderEffect: string;
  53523. /**
  53524. * @ignore
  53525. * The horizontal blur PostProcess id in the pipeline
  53526. */
  53527. SSAOBlurHRenderEffect: string;
  53528. /**
  53529. * @ignore
  53530. * The vertical blur PostProcess id in the pipeline
  53531. */
  53532. SSAOBlurVRenderEffect: string;
  53533. /**
  53534. * @ignore
  53535. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  53536. */
  53537. SSAOCombineRenderEffect: string;
  53538. /**
  53539. * The output strength of the SSAO post-process. Default value is 1.0.
  53540. */
  53541. totalStrength: number;
  53542. /**
  53543. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  53544. */
  53545. maxZ: number;
  53546. /**
  53547. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  53548. */
  53549. minZAspect: number;
  53550. private _samples;
  53551. /**
  53552. * Number of samples used for the SSAO calculations. Default value is 8
  53553. */
  53554. samples: number;
  53555. private _textureSamples;
  53556. /**
  53557. * Number of samples to use for antialiasing
  53558. */
  53559. textureSamples: number;
  53560. /**
  53561. * Ratio object used for SSAO ratio and blur ratio
  53562. */
  53563. private _ratio;
  53564. /**
  53565. * Dynamically generated sphere sampler.
  53566. */
  53567. private _sampleSphere;
  53568. /**
  53569. * Blur filter offsets
  53570. */
  53571. private _samplerOffsets;
  53572. private _expensiveBlur;
  53573. /**
  53574. * If bilateral blur should be used
  53575. */
  53576. expensiveBlur: boolean;
  53577. /**
  53578. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  53579. */
  53580. radius: number;
  53581. /**
  53582. * The base color of the SSAO post-process
  53583. * The final result is "base + ssao" between [0, 1]
  53584. */
  53585. base: number;
  53586. /**
  53587. * Support test.
  53588. */
  53589. static readonly IsSupported: boolean;
  53590. private _scene;
  53591. private _depthTexture;
  53592. private _normalTexture;
  53593. private _randomTexture;
  53594. private _originalColorPostProcess;
  53595. private _ssaoPostProcess;
  53596. private _blurHPostProcess;
  53597. private _blurVPostProcess;
  53598. private _ssaoCombinePostProcess;
  53599. private _firstUpdate;
  53600. /**
  53601. * Gets active scene
  53602. */
  53603. readonly scene: Scene;
  53604. /**
  53605. * @constructor
  53606. * @param name The rendering pipeline name
  53607. * @param scene The scene linked to this pipeline
  53608. * @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 }
  53609. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53610. */
  53611. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  53612. /**
  53613. * Get the class name
  53614. * @returns "SSAO2RenderingPipeline"
  53615. */
  53616. getClassName(): string;
  53617. /**
  53618. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  53619. */
  53620. dispose(disableGeometryBufferRenderer?: boolean): void;
  53621. private _createBlurPostProcess;
  53622. /** @hidden */
  53623. _rebuild(): void;
  53624. private _bits;
  53625. private _radicalInverse_VdC;
  53626. private _hammersley;
  53627. private _hemisphereSample_uniform;
  53628. private _generateHemisphere;
  53629. private _createSSAOPostProcess;
  53630. private _createSSAOCombinePostProcess;
  53631. private _createRandomTexture;
  53632. /**
  53633. * Serialize the rendering pipeline (Used when exporting)
  53634. * @returns the serialized object
  53635. */
  53636. serialize(): any;
  53637. /**
  53638. * Parse the serialized pipeline
  53639. * @param source Source pipeline.
  53640. * @param scene The scene to load the pipeline to.
  53641. * @param rootUrl The URL of the serialized pipeline.
  53642. * @returns An instantiated pipeline from the serialized object.
  53643. */
  53644. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  53645. }
  53646. }
  53647. declare module "babylonjs/Shaders/ssao.fragment" {
  53648. /** @hidden */
  53649. export var ssaoPixelShader: {
  53650. name: string;
  53651. shader: string;
  53652. };
  53653. }
  53654. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  53655. import { Camera } from "babylonjs/Cameras/camera";
  53656. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53657. import { Scene } from "babylonjs/scene";
  53658. import "babylonjs/Shaders/ssao.fragment";
  53659. import "babylonjs/Shaders/ssaoCombine.fragment";
  53660. /**
  53661. * Render pipeline to produce ssao effect
  53662. */
  53663. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  53664. /**
  53665. * @ignore
  53666. * The PassPostProcess id in the pipeline that contains the original scene color
  53667. */
  53668. SSAOOriginalSceneColorEffect: string;
  53669. /**
  53670. * @ignore
  53671. * The SSAO PostProcess id in the pipeline
  53672. */
  53673. SSAORenderEffect: string;
  53674. /**
  53675. * @ignore
  53676. * The horizontal blur PostProcess id in the pipeline
  53677. */
  53678. SSAOBlurHRenderEffect: string;
  53679. /**
  53680. * @ignore
  53681. * The vertical blur PostProcess id in the pipeline
  53682. */
  53683. SSAOBlurVRenderEffect: string;
  53684. /**
  53685. * @ignore
  53686. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  53687. */
  53688. SSAOCombineRenderEffect: string;
  53689. /**
  53690. * The output strength of the SSAO post-process. Default value is 1.0.
  53691. */
  53692. totalStrength: number;
  53693. /**
  53694. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  53695. */
  53696. radius: number;
  53697. /**
  53698. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  53699. * Must not be equal to fallOff and superior to fallOff.
  53700. * Default value is 0.0075
  53701. */
  53702. area: number;
  53703. /**
  53704. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  53705. * Must not be equal to area and inferior to area.
  53706. * Default value is 0.000001
  53707. */
  53708. fallOff: number;
  53709. /**
  53710. * The base color of the SSAO post-process
  53711. * The final result is "base + ssao" between [0, 1]
  53712. */
  53713. base: number;
  53714. private _scene;
  53715. private _depthTexture;
  53716. private _randomTexture;
  53717. private _originalColorPostProcess;
  53718. private _ssaoPostProcess;
  53719. private _blurHPostProcess;
  53720. private _blurVPostProcess;
  53721. private _ssaoCombinePostProcess;
  53722. private _firstUpdate;
  53723. /**
  53724. * Gets active scene
  53725. */
  53726. readonly scene: Scene;
  53727. /**
  53728. * @constructor
  53729. * @param name - The rendering pipeline name
  53730. * @param scene - The scene linked to this pipeline
  53731. * @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 }
  53732. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  53733. */
  53734. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  53735. /**
  53736. * Get the class name
  53737. * @returns "SSAORenderingPipeline"
  53738. */
  53739. getClassName(): string;
  53740. /**
  53741. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  53742. */
  53743. dispose(disableDepthRender?: boolean): void;
  53744. private _createBlurPostProcess;
  53745. /** @hidden */
  53746. _rebuild(): void;
  53747. private _createSSAOPostProcess;
  53748. private _createSSAOCombinePostProcess;
  53749. private _createRandomTexture;
  53750. }
  53751. }
  53752. declare module "babylonjs/Shaders/standard.fragment" {
  53753. /** @hidden */
  53754. export var standardPixelShader: {
  53755. name: string;
  53756. shader: string;
  53757. };
  53758. }
  53759. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  53760. import { Nullable } from "babylonjs/types";
  53761. import { IAnimatable } from "babylonjs/Misc/tools";
  53762. import { Camera } from "babylonjs/Cameras/camera";
  53763. import { Texture } from "babylonjs/Materials/Textures/texture";
  53764. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53765. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53766. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  53767. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  53768. import { IDisposable } from "babylonjs/scene";
  53769. import { SpotLight } from "babylonjs/Lights/spotLight";
  53770. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  53771. import { Scene } from "babylonjs/scene";
  53772. import { Animation } from "babylonjs/Animations/animation";
  53773. import "babylonjs/Shaders/standard.fragment";
  53774. /**
  53775. * Standard rendering pipeline
  53776. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  53777. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  53778. */
  53779. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  53780. /**
  53781. * Public members
  53782. */
  53783. /**
  53784. * Post-process which contains the original scene color before the pipeline applies all the effects
  53785. */
  53786. originalPostProcess: Nullable<PostProcess>;
  53787. /**
  53788. * Post-process used to down scale an image x4
  53789. */
  53790. downSampleX4PostProcess: Nullable<PostProcess>;
  53791. /**
  53792. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  53793. */
  53794. brightPassPostProcess: Nullable<PostProcess>;
  53795. /**
  53796. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  53797. */
  53798. blurHPostProcesses: PostProcess[];
  53799. /**
  53800. * Post-process array storing all the vertical blur post-processes used by the pipeline
  53801. */
  53802. blurVPostProcesses: PostProcess[];
  53803. /**
  53804. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  53805. */
  53806. textureAdderPostProcess: Nullable<PostProcess>;
  53807. /**
  53808. * Post-process used to create volumetric lighting effect
  53809. */
  53810. volumetricLightPostProcess: Nullable<PostProcess>;
  53811. /**
  53812. * Post-process used to smooth the previous volumetric light post-process on the X axis
  53813. */
  53814. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  53815. /**
  53816. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  53817. */
  53818. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  53819. /**
  53820. * Post-process used to merge the volumetric light effect and the real scene color
  53821. */
  53822. volumetricLightMergePostProces: Nullable<PostProcess>;
  53823. /**
  53824. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  53825. */
  53826. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  53827. /**
  53828. * Base post-process used to calculate the average luminance of the final image for HDR
  53829. */
  53830. luminancePostProcess: Nullable<PostProcess>;
  53831. /**
  53832. * Post-processes used to create down sample post-processes in order to get
  53833. * the average luminance of the final image for HDR
  53834. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  53835. */
  53836. luminanceDownSamplePostProcesses: PostProcess[];
  53837. /**
  53838. * Post-process used to create a HDR effect (light adaptation)
  53839. */
  53840. hdrPostProcess: Nullable<PostProcess>;
  53841. /**
  53842. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  53843. */
  53844. textureAdderFinalPostProcess: Nullable<PostProcess>;
  53845. /**
  53846. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  53847. */
  53848. lensFlareFinalPostProcess: Nullable<PostProcess>;
  53849. /**
  53850. * Post-process used to merge the final HDR post-process and the real scene color
  53851. */
  53852. hdrFinalPostProcess: Nullable<PostProcess>;
  53853. /**
  53854. * Post-process used to create a lens flare effect
  53855. */
  53856. lensFlarePostProcess: Nullable<PostProcess>;
  53857. /**
  53858. * Post-process that merges the result of the lens flare post-process and the real scene color
  53859. */
  53860. lensFlareComposePostProcess: Nullable<PostProcess>;
  53861. /**
  53862. * Post-process used to create a motion blur effect
  53863. */
  53864. motionBlurPostProcess: Nullable<PostProcess>;
  53865. /**
  53866. * Post-process used to create a depth of field effect
  53867. */
  53868. depthOfFieldPostProcess: Nullable<PostProcess>;
  53869. /**
  53870. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  53871. */
  53872. fxaaPostProcess: Nullable<FxaaPostProcess>;
  53873. /**
  53874. * Represents the brightness threshold in order to configure the illuminated surfaces
  53875. */
  53876. brightThreshold: number;
  53877. /**
  53878. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  53879. */
  53880. blurWidth: number;
  53881. /**
  53882. * Sets if the blur for highlighted surfaces must be only horizontal
  53883. */
  53884. horizontalBlur: boolean;
  53885. /**
  53886. * Sets the overall exposure used by the pipeline
  53887. */
  53888. exposure: number;
  53889. /**
  53890. * Texture used typically to simulate "dirty" on camera lens
  53891. */
  53892. lensTexture: Nullable<Texture>;
  53893. /**
  53894. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  53895. */
  53896. volumetricLightCoefficient: number;
  53897. /**
  53898. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  53899. */
  53900. volumetricLightPower: number;
  53901. /**
  53902. * Used the set the blur intensity to smooth the volumetric lights
  53903. */
  53904. volumetricLightBlurScale: number;
  53905. /**
  53906. * Light (spot or directional) used to generate the volumetric lights rays
  53907. * The source light must have a shadow generate so the pipeline can get its
  53908. * depth map
  53909. */
  53910. sourceLight: Nullable<SpotLight | DirectionalLight>;
  53911. /**
  53912. * For eye adaptation, represents the minimum luminance the eye can see
  53913. */
  53914. hdrMinimumLuminance: number;
  53915. /**
  53916. * For eye adaptation, represents the decrease luminance speed
  53917. */
  53918. hdrDecreaseRate: number;
  53919. /**
  53920. * For eye adaptation, represents the increase luminance speed
  53921. */
  53922. hdrIncreaseRate: number;
  53923. /**
  53924. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  53925. */
  53926. lensColorTexture: Nullable<Texture>;
  53927. /**
  53928. * The overall strengh for the lens flare effect
  53929. */
  53930. lensFlareStrength: number;
  53931. /**
  53932. * Dispersion coefficient for lens flare ghosts
  53933. */
  53934. lensFlareGhostDispersal: number;
  53935. /**
  53936. * Main lens flare halo width
  53937. */
  53938. lensFlareHaloWidth: number;
  53939. /**
  53940. * Based on the lens distortion effect, defines how much the lens flare result
  53941. * is distorted
  53942. */
  53943. lensFlareDistortionStrength: number;
  53944. /**
  53945. * Lens star texture must be used to simulate rays on the flares and is available
  53946. * in the documentation
  53947. */
  53948. lensStarTexture: Nullable<Texture>;
  53949. /**
  53950. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  53951. * flare effect by taking account of the dirt texture
  53952. */
  53953. lensFlareDirtTexture: Nullable<Texture>;
  53954. /**
  53955. * Represents the focal length for the depth of field effect
  53956. */
  53957. depthOfFieldDistance: number;
  53958. /**
  53959. * Represents the blur intensity for the blurred part of the depth of field effect
  53960. */
  53961. depthOfFieldBlurWidth: number;
  53962. /**
  53963. * For motion blur, defines how much the image is blurred by the movement
  53964. */
  53965. motionStrength: number;
  53966. /**
  53967. * List of animations for the pipeline (IAnimatable implementation)
  53968. */
  53969. animations: Animation[];
  53970. /**
  53971. * Private members
  53972. */
  53973. private _scene;
  53974. private _currentDepthOfFieldSource;
  53975. private _basePostProcess;
  53976. private _hdrCurrentLuminance;
  53977. private _floatTextureType;
  53978. private _ratio;
  53979. private _bloomEnabled;
  53980. private _depthOfFieldEnabled;
  53981. private _vlsEnabled;
  53982. private _lensFlareEnabled;
  53983. private _hdrEnabled;
  53984. private _motionBlurEnabled;
  53985. private _fxaaEnabled;
  53986. private _motionBlurSamples;
  53987. private _volumetricLightStepsCount;
  53988. private _samples;
  53989. /**
  53990. * @ignore
  53991. * Specifies if the bloom pipeline is enabled
  53992. */
  53993. BloomEnabled: boolean;
  53994. /**
  53995. * @ignore
  53996. * Specifies if the depth of field pipeline is enabed
  53997. */
  53998. DepthOfFieldEnabled: boolean;
  53999. /**
  54000. * @ignore
  54001. * Specifies if the lens flare pipeline is enabed
  54002. */
  54003. LensFlareEnabled: boolean;
  54004. /**
  54005. * @ignore
  54006. * Specifies if the HDR pipeline is enabled
  54007. */
  54008. HDREnabled: boolean;
  54009. /**
  54010. * @ignore
  54011. * Specifies if the volumetric lights scattering effect is enabled
  54012. */
  54013. VLSEnabled: boolean;
  54014. /**
  54015. * @ignore
  54016. * Specifies if the motion blur effect is enabled
  54017. */
  54018. MotionBlurEnabled: boolean;
  54019. /**
  54020. * Specifies if anti-aliasing is enabled
  54021. */
  54022. fxaaEnabled: boolean;
  54023. /**
  54024. * Specifies the number of steps used to calculate the volumetric lights
  54025. * Typically in interval [50, 200]
  54026. */
  54027. volumetricLightStepsCount: number;
  54028. /**
  54029. * Specifies the number of samples used for the motion blur effect
  54030. * Typically in interval [16, 64]
  54031. */
  54032. motionBlurSamples: number;
  54033. /**
  54034. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  54035. */
  54036. samples: number;
  54037. /**
  54038. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  54039. * @constructor
  54040. * @param name The rendering pipeline name
  54041. * @param scene The scene linked to this pipeline
  54042. * @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)
  54043. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  54044. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54045. */
  54046. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  54047. private _buildPipeline;
  54048. private _createDownSampleX4PostProcess;
  54049. private _createBrightPassPostProcess;
  54050. private _createBlurPostProcesses;
  54051. private _createTextureAdderPostProcess;
  54052. private _createVolumetricLightPostProcess;
  54053. private _createLuminancePostProcesses;
  54054. private _createHdrPostProcess;
  54055. private _createLensFlarePostProcess;
  54056. private _createDepthOfFieldPostProcess;
  54057. private _createMotionBlurPostProcess;
  54058. private _getDepthTexture;
  54059. private _disposePostProcesses;
  54060. /**
  54061. * Dispose of the pipeline and stop all post processes
  54062. */
  54063. dispose(): void;
  54064. /**
  54065. * Serialize the rendering pipeline (Used when exporting)
  54066. * @returns the serialized object
  54067. */
  54068. serialize(): any;
  54069. /**
  54070. * Parse the serialized pipeline
  54071. * @param source Source pipeline.
  54072. * @param scene The scene to load the pipeline to.
  54073. * @param rootUrl The URL of the serialized pipeline.
  54074. * @returns An instantiated pipeline from the serialized object.
  54075. */
  54076. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  54077. /**
  54078. * Luminance steps
  54079. */
  54080. static LuminanceSteps: number;
  54081. }
  54082. }
  54083. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  54084. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  54085. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  54086. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  54087. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  54088. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  54089. }
  54090. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  54091. import { Camera } from "babylonjs/Cameras/camera";
  54092. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54093. /**
  54094. * PostProcessRenderPipelineManager class
  54095. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54096. */
  54097. export class PostProcessRenderPipelineManager {
  54098. private _renderPipelines;
  54099. /**
  54100. * Initializes a PostProcessRenderPipelineManager
  54101. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54102. */
  54103. constructor();
  54104. /**
  54105. * Gets the list of supported render pipelines
  54106. */
  54107. readonly supportedPipelines: PostProcessRenderPipeline[];
  54108. /**
  54109. * Adds a pipeline to the manager
  54110. * @param renderPipeline The pipeline to add
  54111. */
  54112. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  54113. /**
  54114. * Attaches a camera to the pipeline
  54115. * @param renderPipelineName The name of the pipeline to attach to
  54116. * @param cameras the camera to attach
  54117. * @param unique if the camera can be attached multiple times to the pipeline
  54118. */
  54119. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  54120. /**
  54121. * Detaches a camera from the pipeline
  54122. * @param renderPipelineName The name of the pipeline to detach from
  54123. * @param cameras the camera to detach
  54124. */
  54125. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  54126. /**
  54127. * Enables an effect by name on a pipeline
  54128. * @param renderPipelineName the name of the pipeline to enable the effect in
  54129. * @param renderEffectName the name of the effect to enable
  54130. * @param cameras the cameras that the effect should be enabled on
  54131. */
  54132. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  54133. /**
  54134. * Disables an effect by name on a pipeline
  54135. * @param renderPipelineName the name of the pipeline to disable the effect in
  54136. * @param renderEffectName the name of the effect to disable
  54137. * @param cameras the cameras that the effect should be disabled on
  54138. */
  54139. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  54140. /**
  54141. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  54142. */
  54143. update(): void;
  54144. /** @hidden */
  54145. _rebuild(): void;
  54146. /**
  54147. * Disposes of the manager and pipelines
  54148. */
  54149. dispose(): void;
  54150. }
  54151. }
  54152. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  54153. import { ISceneComponent } from "babylonjs/sceneComponent";
  54154. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  54155. import { Scene } from "babylonjs/scene";
  54156. module "babylonjs/scene" {
  54157. interface Scene {
  54158. /** @hidden (Backing field) */
  54159. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  54160. /**
  54161. * Gets the postprocess render pipeline manager
  54162. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54163. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  54164. */
  54165. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  54166. }
  54167. }
  54168. /**
  54169. * Defines the Render Pipeline scene component responsible to rendering pipelines
  54170. */
  54171. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  54172. /**
  54173. * The component name helpfull to identify the component in the list of scene components.
  54174. */
  54175. readonly name: string;
  54176. /**
  54177. * The scene the component belongs to.
  54178. */
  54179. scene: Scene;
  54180. /**
  54181. * Creates a new instance of the component for the given scene
  54182. * @param scene Defines the scene to register the component in
  54183. */
  54184. constructor(scene: Scene);
  54185. /**
  54186. * Registers the component in a given scene
  54187. */
  54188. register(): void;
  54189. /**
  54190. * Rebuilds the elements related to this component in case of
  54191. * context lost for instance.
  54192. */
  54193. rebuild(): void;
  54194. /**
  54195. * Disposes the component and the associated ressources
  54196. */
  54197. dispose(): void;
  54198. private _gatherRenderTargets;
  54199. }
  54200. }
  54201. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  54202. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  54203. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54204. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54205. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  54206. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  54207. }
  54208. declare module "babylonjs/Shaders/tonemap.fragment" {
  54209. /** @hidden */
  54210. export var tonemapPixelShader: {
  54211. name: string;
  54212. shader: string;
  54213. };
  54214. }
  54215. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  54216. import { Camera } from "babylonjs/Cameras/camera";
  54217. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54218. import "babylonjs/Shaders/tonemap.fragment";
  54219. import { Engine } from "babylonjs/Engines/engine";
  54220. /** Defines operator used for tonemapping */
  54221. export enum TonemappingOperator {
  54222. /** Hable */
  54223. Hable = 0,
  54224. /** Reinhard */
  54225. Reinhard = 1,
  54226. /** HejiDawson */
  54227. HejiDawson = 2,
  54228. /** Photographic */
  54229. Photographic = 3
  54230. }
  54231. /**
  54232. * Defines a post process to apply tone mapping
  54233. */
  54234. export class TonemapPostProcess extends PostProcess {
  54235. private _operator;
  54236. /** Defines the required exposure adjustement */
  54237. exposureAdjustment: number;
  54238. /**
  54239. * Creates a new TonemapPostProcess
  54240. * @param name defines the name of the postprocess
  54241. * @param _operator defines the operator to use
  54242. * @param exposureAdjustment defines the required exposure adjustement
  54243. * @param camera defines the camera to use (can be null)
  54244. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  54245. * @param engine defines the hosting engine (can be ignore if camera is set)
  54246. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54247. */
  54248. constructor(name: string, _operator: TonemappingOperator,
  54249. /** Defines the required exposure adjustement */
  54250. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  54251. }
  54252. }
  54253. declare module "babylonjs/Shaders/depth.vertex" {
  54254. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54255. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54256. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54257. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54258. /** @hidden */
  54259. export var depthVertexShader: {
  54260. name: string;
  54261. shader: string;
  54262. };
  54263. }
  54264. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  54265. /** @hidden */
  54266. export var volumetricLightScatteringPixelShader: {
  54267. name: string;
  54268. shader: string;
  54269. };
  54270. }
  54271. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  54272. /** @hidden */
  54273. export var volumetricLightScatteringPassPixelShader: {
  54274. name: string;
  54275. shader: string;
  54276. };
  54277. }
  54278. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  54279. import { Vector3 } from "babylonjs/Maths/math";
  54280. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54281. import { Mesh } from "babylonjs/Meshes/mesh";
  54282. import { Camera } from "babylonjs/Cameras/camera";
  54283. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54284. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54285. import { Scene } from "babylonjs/scene";
  54286. import "babylonjs/Meshes/Builders/planeBuilder";
  54287. import "babylonjs/Shaders/depth.vertex";
  54288. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  54289. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  54290. import { Engine } from "babylonjs/Engines/engine";
  54291. /**
  54292. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  54293. */
  54294. export class VolumetricLightScatteringPostProcess extends PostProcess {
  54295. private _volumetricLightScatteringPass;
  54296. private _volumetricLightScatteringRTT;
  54297. private _viewPort;
  54298. private _screenCoordinates;
  54299. private _cachedDefines;
  54300. /**
  54301. * If not undefined, the mesh position is computed from the attached node position
  54302. */
  54303. attachedNode: {
  54304. position: Vector3;
  54305. };
  54306. /**
  54307. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  54308. */
  54309. customMeshPosition: Vector3;
  54310. /**
  54311. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  54312. */
  54313. useCustomMeshPosition: boolean;
  54314. /**
  54315. * If the post-process should inverse the light scattering direction
  54316. */
  54317. invert: boolean;
  54318. /**
  54319. * The internal mesh used by the post-process
  54320. */
  54321. mesh: Mesh;
  54322. /**
  54323. * @hidden
  54324. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  54325. */
  54326. useDiffuseColor: boolean;
  54327. /**
  54328. * Array containing the excluded meshes not rendered in the internal pass
  54329. */
  54330. excludedMeshes: AbstractMesh[];
  54331. /**
  54332. * Controls the overall intensity of the post-process
  54333. */
  54334. exposure: number;
  54335. /**
  54336. * Dissipates each sample's contribution in range [0, 1]
  54337. */
  54338. decay: number;
  54339. /**
  54340. * Controls the overall intensity of each sample
  54341. */
  54342. weight: number;
  54343. /**
  54344. * Controls the density of each sample
  54345. */
  54346. density: number;
  54347. /**
  54348. * @constructor
  54349. * @param name The post-process name
  54350. * @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)
  54351. * @param camera The camera that the post-process will be attached to
  54352. * @param mesh The mesh used to create the light scattering
  54353. * @param samples The post-process quality, default 100
  54354. * @param samplingModeThe post-process filtering mode
  54355. * @param engine The babylon engine
  54356. * @param reusable If the post-process is reusable
  54357. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  54358. */
  54359. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  54360. /**
  54361. * Returns the string "VolumetricLightScatteringPostProcess"
  54362. * @returns "VolumetricLightScatteringPostProcess"
  54363. */
  54364. getClassName(): string;
  54365. private _isReady;
  54366. /**
  54367. * Sets the new light position for light scattering effect
  54368. * @param position The new custom light position
  54369. */
  54370. setCustomMeshPosition(position: Vector3): void;
  54371. /**
  54372. * Returns the light position for light scattering effect
  54373. * @return Vector3 The custom light position
  54374. */
  54375. getCustomMeshPosition(): Vector3;
  54376. /**
  54377. * Disposes the internal assets and detaches the post-process from the camera
  54378. */
  54379. dispose(camera: Camera): void;
  54380. /**
  54381. * Returns the render target texture used by the post-process
  54382. * @return the render target texture used by the post-process
  54383. */
  54384. getPass(): RenderTargetTexture;
  54385. private _meshExcluded;
  54386. private _createPass;
  54387. private _updateMeshScreenCoordinates;
  54388. /**
  54389. * Creates a default mesh for the Volumeric Light Scattering post-process
  54390. * @param name The mesh name
  54391. * @param scene The scene where to create the mesh
  54392. * @return the default mesh
  54393. */
  54394. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  54395. }
  54396. }
  54397. declare module "babylonjs/PostProcesses/index" {
  54398. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  54399. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  54400. export * from "babylonjs/PostProcesses/bloomEffect";
  54401. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  54402. export * from "babylonjs/PostProcesses/blurPostProcess";
  54403. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  54404. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  54405. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  54406. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  54407. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  54408. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  54409. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  54410. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  54411. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  54412. export * from "babylonjs/PostProcesses/filterPostProcess";
  54413. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  54414. export * from "babylonjs/PostProcesses/grainPostProcess";
  54415. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  54416. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  54417. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  54418. export * from "babylonjs/PostProcesses/passPostProcess";
  54419. export * from "babylonjs/PostProcesses/postProcess";
  54420. export * from "babylonjs/PostProcesses/postProcessManager";
  54421. export * from "babylonjs/PostProcesses/refractionPostProcess";
  54422. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  54423. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  54424. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  54425. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  54426. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  54427. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  54428. }
  54429. declare module "babylonjs/Probes/index" {
  54430. export * from "babylonjs/Probes/reflectionProbe";
  54431. }
  54432. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  54433. import { Scene } from "babylonjs/scene";
  54434. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54435. import { Color3 } from "babylonjs/Maths/math";
  54436. import { SmartArray } from "babylonjs/Misc/smartArray";
  54437. import { ISceneComponent } from "babylonjs/sceneComponent";
  54438. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  54439. import "babylonjs/Meshes/Builders/boxBuilder";
  54440. import "babylonjs/Shaders/color.fragment";
  54441. import "babylonjs/Shaders/color.vertex";
  54442. module "babylonjs/scene" {
  54443. interface Scene {
  54444. /** @hidden (Backing field) */
  54445. _boundingBoxRenderer: BoundingBoxRenderer;
  54446. /** @hidden (Backing field) */
  54447. _forceShowBoundingBoxes: boolean;
  54448. /**
  54449. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  54450. */
  54451. forceShowBoundingBoxes: boolean;
  54452. /**
  54453. * Gets the bounding box renderer associated with the scene
  54454. * @returns a BoundingBoxRenderer
  54455. */
  54456. getBoundingBoxRenderer(): BoundingBoxRenderer;
  54457. }
  54458. }
  54459. module "babylonjs/Meshes/abstractMesh" {
  54460. interface AbstractMesh {
  54461. /** @hidden (Backing field) */
  54462. _showBoundingBox: boolean;
  54463. /**
  54464. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  54465. */
  54466. showBoundingBox: boolean;
  54467. }
  54468. }
  54469. /**
  54470. * Component responsible of rendering the bounding box of the meshes in a scene.
  54471. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  54472. */
  54473. export class BoundingBoxRenderer implements ISceneComponent {
  54474. /**
  54475. * The component name helpfull to identify the component in the list of scene components.
  54476. */
  54477. readonly name: string;
  54478. /**
  54479. * The scene the component belongs to.
  54480. */
  54481. scene: Scene;
  54482. /**
  54483. * Color of the bounding box lines placed in front of an object
  54484. */
  54485. frontColor: Color3;
  54486. /**
  54487. * Color of the bounding box lines placed behind an object
  54488. */
  54489. backColor: Color3;
  54490. /**
  54491. * Defines if the renderer should show the back lines or not
  54492. */
  54493. showBackLines: boolean;
  54494. /**
  54495. * @hidden
  54496. */
  54497. renderList: SmartArray<BoundingBox>;
  54498. private _colorShader;
  54499. private _vertexBuffers;
  54500. private _indexBuffer;
  54501. /**
  54502. * Instantiates a new bounding box renderer in a scene.
  54503. * @param scene the scene the renderer renders in
  54504. */
  54505. constructor(scene: Scene);
  54506. /**
  54507. * Registers the component in a given scene
  54508. */
  54509. register(): void;
  54510. private _evaluateSubMesh;
  54511. private _activeMesh;
  54512. private _prepareRessources;
  54513. private _createIndexBuffer;
  54514. /**
  54515. * Rebuilds the elements related to this component in case of
  54516. * context lost for instance.
  54517. */
  54518. rebuild(): void;
  54519. /**
  54520. * @hidden
  54521. */
  54522. reset(): void;
  54523. /**
  54524. * Render the bounding boxes of a specific rendering group
  54525. * @param renderingGroupId defines the rendering group to render
  54526. */
  54527. render(renderingGroupId: number): void;
  54528. /**
  54529. * In case of occlusion queries, we can render the occlusion bounding box through this method
  54530. * @param mesh Define the mesh to render the occlusion bounding box for
  54531. */
  54532. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  54533. /**
  54534. * Dispose and release the resources attached to this renderer.
  54535. */
  54536. dispose(): void;
  54537. }
  54538. }
  54539. declare module "babylonjs/Shaders/depth.fragment" {
  54540. /** @hidden */
  54541. export var depthPixelShader: {
  54542. name: string;
  54543. shader: string;
  54544. };
  54545. }
  54546. declare module "babylonjs/Rendering/depthRenderer" {
  54547. import { Nullable } from "babylonjs/types";
  54548. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54549. import { Scene } from "babylonjs/scene";
  54550. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54551. import { Camera } from "babylonjs/Cameras/camera";
  54552. import "babylonjs/Shaders/depth.fragment";
  54553. import "babylonjs/Shaders/depth.vertex";
  54554. /**
  54555. * This represents a depth renderer in Babylon.
  54556. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54557. */
  54558. export class DepthRenderer {
  54559. private _scene;
  54560. private _depthMap;
  54561. private _effect;
  54562. private _cachedDefines;
  54563. private _camera;
  54564. /**
  54565. * Specifiess that the depth renderer will only be used within
  54566. * the camera it is created for.
  54567. * This can help forcing its rendering during the camera processing.
  54568. */
  54569. useOnlyInActiveCamera: boolean;
  54570. /** @hidden */
  54571. static _SceneComponentInitialization: (scene: Scene) => void;
  54572. /**
  54573. * Instantiates a depth renderer
  54574. * @param scene The scene the renderer belongs to
  54575. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54576. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54577. */
  54578. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  54579. /**
  54580. * Creates the depth rendering effect and checks if the effect is ready.
  54581. * @param subMesh The submesh to be used to render the depth map of
  54582. * @param useInstances If multiple world instances should be used
  54583. * @returns if the depth renderer is ready to render the depth map
  54584. */
  54585. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54586. /**
  54587. * Gets the texture which the depth map will be written to.
  54588. * @returns The depth map texture
  54589. */
  54590. getDepthMap(): RenderTargetTexture;
  54591. /**
  54592. * Disposes of the depth renderer.
  54593. */
  54594. dispose(): void;
  54595. }
  54596. }
  54597. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  54598. import { Nullable } from "babylonjs/types";
  54599. import { Scene } from "babylonjs/scene";
  54600. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  54601. import { Camera } from "babylonjs/Cameras/camera";
  54602. import { ISceneComponent } from "babylonjs/sceneComponent";
  54603. module "babylonjs/scene" {
  54604. interface Scene {
  54605. /** @hidden (Backing field) */
  54606. _depthRenderer: {
  54607. [id: string]: DepthRenderer;
  54608. };
  54609. /**
  54610. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  54611. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  54612. * @returns the created depth renderer
  54613. */
  54614. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  54615. /**
  54616. * Disables a depth renderer for a given camera
  54617. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  54618. */
  54619. disableDepthRenderer(camera?: Nullable<Camera>): void;
  54620. }
  54621. }
  54622. /**
  54623. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  54624. * in several rendering techniques.
  54625. */
  54626. export class DepthRendererSceneComponent implements ISceneComponent {
  54627. /**
  54628. * The component name helpfull to identify the component in the list of scene components.
  54629. */
  54630. readonly name: string;
  54631. /**
  54632. * The scene the component belongs to.
  54633. */
  54634. scene: Scene;
  54635. /**
  54636. * Creates a new instance of the component for the given scene
  54637. * @param scene Defines the scene to register the component in
  54638. */
  54639. constructor(scene: Scene);
  54640. /**
  54641. * Registers the component in a given scene
  54642. */
  54643. register(): void;
  54644. /**
  54645. * Rebuilds the elements related to this component in case of
  54646. * context lost for instance.
  54647. */
  54648. rebuild(): void;
  54649. /**
  54650. * Disposes the component and the associated ressources
  54651. */
  54652. dispose(): void;
  54653. private _gatherRenderTargets;
  54654. private _gatherActiveCameraRenderTargets;
  54655. }
  54656. }
  54657. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  54658. import { Nullable } from "babylonjs/types";
  54659. import { Scene } from "babylonjs/scene";
  54660. import { ISceneComponent } from "babylonjs/sceneComponent";
  54661. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  54662. module "babylonjs/scene" {
  54663. interface Scene {
  54664. /** @hidden (Backing field) */
  54665. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  54666. /**
  54667. * Gets or Sets the current geometry buffer associated to the scene.
  54668. */
  54669. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  54670. /**
  54671. * Enables a GeometryBufferRender and associates it with the scene
  54672. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  54673. * @returns the GeometryBufferRenderer
  54674. */
  54675. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  54676. /**
  54677. * Disables the GeometryBufferRender associated with the scene
  54678. */
  54679. disableGeometryBufferRenderer(): void;
  54680. }
  54681. }
  54682. /**
  54683. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  54684. * in several rendering techniques.
  54685. */
  54686. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  54687. /**
  54688. * The component name helpful to identify the component in the list of scene components.
  54689. */
  54690. readonly name: string;
  54691. /**
  54692. * The scene the component belongs to.
  54693. */
  54694. scene: Scene;
  54695. /**
  54696. * Creates a new instance of the component for the given scene
  54697. * @param scene Defines the scene to register the component in
  54698. */
  54699. constructor(scene: Scene);
  54700. /**
  54701. * Registers the component in a given scene
  54702. */
  54703. register(): void;
  54704. /**
  54705. * Rebuilds the elements related to this component in case of
  54706. * context lost for instance.
  54707. */
  54708. rebuild(): void;
  54709. /**
  54710. * Disposes the component and the associated ressources
  54711. */
  54712. dispose(): void;
  54713. private _gatherRenderTargets;
  54714. }
  54715. }
  54716. declare module "babylonjs/Shaders/outline.fragment" {
  54717. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  54718. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  54719. /** @hidden */
  54720. export var outlinePixelShader: {
  54721. name: string;
  54722. shader: string;
  54723. };
  54724. }
  54725. declare module "babylonjs/Shaders/outline.vertex" {
  54726. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54727. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54728. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  54729. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54730. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54731. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  54732. /** @hidden */
  54733. export var outlineVertexShader: {
  54734. name: string;
  54735. shader: string;
  54736. };
  54737. }
  54738. declare module "babylonjs/Rendering/outlineRenderer" {
  54739. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54740. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  54741. import { Scene } from "babylonjs/scene";
  54742. import { ISceneComponent } from "babylonjs/sceneComponent";
  54743. import "babylonjs/Shaders/outline.fragment";
  54744. import "babylonjs/Shaders/outline.vertex";
  54745. module "babylonjs/scene" {
  54746. interface Scene {
  54747. /** @hidden */
  54748. _outlineRenderer: OutlineRenderer;
  54749. /**
  54750. * Gets the outline renderer associated with the scene
  54751. * @returns a OutlineRenderer
  54752. */
  54753. getOutlineRenderer(): OutlineRenderer;
  54754. }
  54755. }
  54756. module "babylonjs/Meshes/abstractMesh" {
  54757. interface AbstractMesh {
  54758. /** @hidden (Backing field) */
  54759. _renderOutline: boolean;
  54760. /**
  54761. * Gets or sets a boolean indicating if the outline must be rendered as well
  54762. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  54763. */
  54764. renderOutline: boolean;
  54765. /** @hidden (Backing field) */
  54766. _renderOverlay: boolean;
  54767. /**
  54768. * Gets or sets a boolean indicating if the overlay must be rendered as well
  54769. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  54770. */
  54771. renderOverlay: boolean;
  54772. }
  54773. }
  54774. /**
  54775. * This class is responsible to draw bothe outline/overlay of meshes.
  54776. * It should not be used directly but through the available method on mesh.
  54777. */
  54778. export class OutlineRenderer implements ISceneComponent {
  54779. /**
  54780. * The name of the component. Each component must have a unique name.
  54781. */
  54782. name: string;
  54783. /**
  54784. * The scene the component belongs to.
  54785. */
  54786. scene: Scene;
  54787. /**
  54788. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  54789. */
  54790. zOffset: number;
  54791. private _engine;
  54792. private _effect;
  54793. private _cachedDefines;
  54794. private _savedDepthWrite;
  54795. /**
  54796. * Instantiates a new outline renderer. (There could be only one per scene).
  54797. * @param scene Defines the scene it belongs to
  54798. */
  54799. constructor(scene: Scene);
  54800. /**
  54801. * Register the component to one instance of a scene.
  54802. */
  54803. register(): void;
  54804. /**
  54805. * Rebuilds the elements related to this component in case of
  54806. * context lost for instance.
  54807. */
  54808. rebuild(): void;
  54809. /**
  54810. * Disposes the component and the associated ressources.
  54811. */
  54812. dispose(): void;
  54813. /**
  54814. * Renders the outline in the canvas.
  54815. * @param subMesh Defines the sumesh to render
  54816. * @param batch Defines the batch of meshes in case of instances
  54817. * @param useOverlay Defines if the rendering is for the overlay or the outline
  54818. */
  54819. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  54820. /**
  54821. * Returns whether or not the outline renderer is ready for a given submesh.
  54822. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  54823. * @param subMesh Defines the submesh to check readyness for
  54824. * @param useInstances Defines wheter wee are trying to render instances or not
  54825. * @returns true if ready otherwise false
  54826. */
  54827. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54828. private _beforeRenderingMesh;
  54829. private _afterRenderingMesh;
  54830. }
  54831. }
  54832. declare module "babylonjs/Rendering/index" {
  54833. export * from "babylonjs/Rendering/boundingBoxRenderer";
  54834. export * from "babylonjs/Rendering/depthRenderer";
  54835. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  54836. export * from "babylonjs/Rendering/edgesRenderer";
  54837. export * from "babylonjs/Rendering/geometryBufferRenderer";
  54838. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  54839. export * from "babylonjs/Rendering/outlineRenderer";
  54840. export * from "babylonjs/Rendering/renderingGroup";
  54841. export * from "babylonjs/Rendering/renderingManager";
  54842. export * from "babylonjs/Rendering/utilityLayerRenderer";
  54843. }
  54844. declare module "babylonjs/Sprites/index" {
  54845. export * from "babylonjs/Sprites/sprite";
  54846. export * from "babylonjs/Sprites/spriteManager";
  54847. export * from "babylonjs/Sprites/spriteSceneComponent";
  54848. }
  54849. declare module "babylonjs/Misc/assetsManager" {
  54850. import { Scene } from "babylonjs/scene";
  54851. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54852. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  54853. import { Skeleton } from "babylonjs/Bones/skeleton";
  54854. import { Observable } from "babylonjs/Misc/observable";
  54855. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54856. import { Texture } from "babylonjs/Materials/Textures/texture";
  54857. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  54858. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  54859. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  54860. /**
  54861. * Defines the list of states available for a task inside a AssetsManager
  54862. */
  54863. export enum AssetTaskState {
  54864. /**
  54865. * Initialization
  54866. */
  54867. INIT = 0,
  54868. /**
  54869. * Running
  54870. */
  54871. RUNNING = 1,
  54872. /**
  54873. * Done
  54874. */
  54875. DONE = 2,
  54876. /**
  54877. * Error
  54878. */
  54879. ERROR = 3
  54880. }
  54881. /**
  54882. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  54883. */
  54884. export abstract class AbstractAssetTask {
  54885. /**
  54886. * Task name
  54887. */ name: string;
  54888. /**
  54889. * Callback called when the task is successful
  54890. */
  54891. onSuccess: (task: any) => void;
  54892. /**
  54893. * Callback called when the task is not successful
  54894. */
  54895. onError: (task: any, message?: string, exception?: any) => void;
  54896. /**
  54897. * Creates a new AssetsManager
  54898. * @param name defines the name of the task
  54899. */
  54900. constructor(
  54901. /**
  54902. * Task name
  54903. */ name: string);
  54904. private _isCompleted;
  54905. private _taskState;
  54906. private _errorObject;
  54907. /**
  54908. * Get if the task is completed
  54909. */
  54910. readonly isCompleted: boolean;
  54911. /**
  54912. * Gets the current state of the task
  54913. */
  54914. readonly taskState: AssetTaskState;
  54915. /**
  54916. * Gets the current error object (if task is in error)
  54917. */
  54918. readonly errorObject: {
  54919. message?: string;
  54920. exception?: any;
  54921. };
  54922. /**
  54923. * Internal only
  54924. * @hidden
  54925. */
  54926. _setErrorObject(message?: string, exception?: any): void;
  54927. /**
  54928. * Execute the current task
  54929. * @param scene defines the scene where you want your assets to be loaded
  54930. * @param onSuccess is a callback called when the task is successfully executed
  54931. * @param onError is a callback called if an error occurs
  54932. */
  54933. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54934. /**
  54935. * Execute the current task
  54936. * @param scene defines the scene where you want your assets to be loaded
  54937. * @param onSuccess is a callback called when the task is successfully executed
  54938. * @param onError is a callback called if an error occurs
  54939. */
  54940. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54941. /**
  54942. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  54943. * This can be used with failed tasks that have the reason for failure fixed.
  54944. */
  54945. reset(): void;
  54946. private onErrorCallback;
  54947. private onDoneCallback;
  54948. }
  54949. /**
  54950. * Define the interface used by progress events raised during assets loading
  54951. */
  54952. export interface IAssetsProgressEvent {
  54953. /**
  54954. * Defines the number of remaining tasks to process
  54955. */
  54956. remainingCount: number;
  54957. /**
  54958. * Defines the total number of tasks
  54959. */
  54960. totalCount: number;
  54961. /**
  54962. * Defines the task that was just processed
  54963. */
  54964. task: AbstractAssetTask;
  54965. }
  54966. /**
  54967. * Class used to share progress information about assets loading
  54968. */
  54969. export class AssetsProgressEvent implements IAssetsProgressEvent {
  54970. /**
  54971. * Defines the number of remaining tasks to process
  54972. */
  54973. remainingCount: number;
  54974. /**
  54975. * Defines the total number of tasks
  54976. */
  54977. totalCount: number;
  54978. /**
  54979. * Defines the task that was just processed
  54980. */
  54981. task: AbstractAssetTask;
  54982. /**
  54983. * Creates a AssetsProgressEvent
  54984. * @param remainingCount defines the number of remaining tasks to process
  54985. * @param totalCount defines the total number of tasks
  54986. * @param task defines the task that was just processed
  54987. */
  54988. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  54989. }
  54990. /**
  54991. * Define a task used by AssetsManager to load meshes
  54992. */
  54993. export class MeshAssetTask extends AbstractAssetTask {
  54994. /**
  54995. * Defines the name of the task
  54996. */
  54997. name: string;
  54998. /**
  54999. * Defines the list of mesh's names you want to load
  55000. */
  55001. meshesNames: any;
  55002. /**
  55003. * Defines the root url to use as a base to load your meshes and associated resources
  55004. */
  55005. rootUrl: string;
  55006. /**
  55007. * Defines the filename of the scene to load from
  55008. */
  55009. sceneFilename: string;
  55010. /**
  55011. * Gets the list of loaded meshes
  55012. */
  55013. loadedMeshes: Array<AbstractMesh>;
  55014. /**
  55015. * Gets the list of loaded particle systems
  55016. */
  55017. loadedParticleSystems: Array<IParticleSystem>;
  55018. /**
  55019. * Gets the list of loaded skeletons
  55020. */
  55021. loadedSkeletons: Array<Skeleton>;
  55022. /**
  55023. * Gets the list of loaded animation groups
  55024. */
  55025. loadedAnimationGroups: Array<AnimationGroup>;
  55026. /**
  55027. * Callback called when the task is successful
  55028. */
  55029. onSuccess: (task: MeshAssetTask) => void;
  55030. /**
  55031. * Callback called when the task is successful
  55032. */
  55033. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  55034. /**
  55035. * Creates a new MeshAssetTask
  55036. * @param name defines the name of the task
  55037. * @param meshesNames defines the list of mesh's names you want to load
  55038. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  55039. * @param sceneFilename defines the filename of the scene to load from
  55040. */
  55041. constructor(
  55042. /**
  55043. * Defines the name of the task
  55044. */
  55045. name: string,
  55046. /**
  55047. * Defines the list of mesh's names you want to load
  55048. */
  55049. meshesNames: any,
  55050. /**
  55051. * Defines the root url to use as a base to load your meshes and associated resources
  55052. */
  55053. rootUrl: string,
  55054. /**
  55055. * Defines the filename of the scene to load from
  55056. */
  55057. sceneFilename: string);
  55058. /**
  55059. * Execute the current task
  55060. * @param scene defines the scene where you want your assets to be loaded
  55061. * @param onSuccess is a callback called when the task is successfully executed
  55062. * @param onError is a callback called if an error occurs
  55063. */
  55064. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55065. }
  55066. /**
  55067. * Define a task used by AssetsManager to load text content
  55068. */
  55069. export class TextFileAssetTask extends AbstractAssetTask {
  55070. /**
  55071. * Defines the name of the task
  55072. */
  55073. name: string;
  55074. /**
  55075. * Defines the location of the file to load
  55076. */
  55077. url: string;
  55078. /**
  55079. * Gets the loaded text string
  55080. */
  55081. text: string;
  55082. /**
  55083. * Callback called when the task is successful
  55084. */
  55085. onSuccess: (task: TextFileAssetTask) => void;
  55086. /**
  55087. * Callback called when the task is successful
  55088. */
  55089. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  55090. /**
  55091. * Creates a new TextFileAssetTask object
  55092. * @param name defines the name of the task
  55093. * @param url defines the location of the file to load
  55094. */
  55095. constructor(
  55096. /**
  55097. * Defines the name of the task
  55098. */
  55099. name: string,
  55100. /**
  55101. * Defines the location of the file to load
  55102. */
  55103. url: string);
  55104. /**
  55105. * Execute the current task
  55106. * @param scene defines the scene where you want your assets to be loaded
  55107. * @param onSuccess is a callback called when the task is successfully executed
  55108. * @param onError is a callback called if an error occurs
  55109. */
  55110. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55111. }
  55112. /**
  55113. * Define a task used by AssetsManager to load binary data
  55114. */
  55115. export class BinaryFileAssetTask extends AbstractAssetTask {
  55116. /**
  55117. * Defines the name of the task
  55118. */
  55119. name: string;
  55120. /**
  55121. * Defines the location of the file to load
  55122. */
  55123. url: string;
  55124. /**
  55125. * Gets the lodaded data (as an array buffer)
  55126. */
  55127. data: ArrayBuffer;
  55128. /**
  55129. * Callback called when the task is successful
  55130. */
  55131. onSuccess: (task: BinaryFileAssetTask) => void;
  55132. /**
  55133. * Callback called when the task is successful
  55134. */
  55135. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  55136. /**
  55137. * Creates a new BinaryFileAssetTask object
  55138. * @param name defines the name of the new task
  55139. * @param url defines the location of the file to load
  55140. */
  55141. constructor(
  55142. /**
  55143. * Defines the name of the task
  55144. */
  55145. name: string,
  55146. /**
  55147. * Defines the location of the file to load
  55148. */
  55149. url: string);
  55150. /**
  55151. * Execute the current task
  55152. * @param scene defines the scene where you want your assets to be loaded
  55153. * @param onSuccess is a callback called when the task is successfully executed
  55154. * @param onError is a callback called if an error occurs
  55155. */
  55156. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55157. }
  55158. /**
  55159. * Define a task used by AssetsManager to load images
  55160. */
  55161. export class ImageAssetTask extends AbstractAssetTask {
  55162. /**
  55163. * Defines the name of the task
  55164. */
  55165. name: string;
  55166. /**
  55167. * Defines the location of the image to load
  55168. */
  55169. url: string;
  55170. /**
  55171. * Gets the loaded images
  55172. */
  55173. image: HTMLImageElement;
  55174. /**
  55175. * Callback called when the task is successful
  55176. */
  55177. onSuccess: (task: ImageAssetTask) => void;
  55178. /**
  55179. * Callback called when the task is successful
  55180. */
  55181. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  55182. /**
  55183. * Creates a new ImageAssetTask
  55184. * @param name defines the name of the task
  55185. * @param url defines the location of the image to load
  55186. */
  55187. constructor(
  55188. /**
  55189. * Defines the name of the task
  55190. */
  55191. name: string,
  55192. /**
  55193. * Defines the location of the image to load
  55194. */
  55195. url: string);
  55196. /**
  55197. * Execute the current task
  55198. * @param scene defines the scene where you want your assets to be loaded
  55199. * @param onSuccess is a callback called when the task is successfully executed
  55200. * @param onError is a callback called if an error occurs
  55201. */
  55202. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55203. }
  55204. /**
  55205. * Defines the interface used by texture loading tasks
  55206. */
  55207. export interface ITextureAssetTask<TEX extends BaseTexture> {
  55208. /**
  55209. * Gets the loaded texture
  55210. */
  55211. texture: TEX;
  55212. }
  55213. /**
  55214. * Define a task used by AssetsManager to load 2D textures
  55215. */
  55216. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  55217. /**
  55218. * Defines the name of the task
  55219. */
  55220. name: string;
  55221. /**
  55222. * Defines the location of the file to load
  55223. */
  55224. url: string;
  55225. /**
  55226. * Defines if mipmap should not be generated (default is false)
  55227. */
  55228. noMipmap?: boolean | undefined;
  55229. /**
  55230. * Defines if texture must be inverted on Y axis (default is false)
  55231. */
  55232. invertY?: boolean | undefined;
  55233. /**
  55234. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55235. */
  55236. samplingMode: number;
  55237. /**
  55238. * Gets the loaded texture
  55239. */
  55240. texture: Texture;
  55241. /**
  55242. * Callback called when the task is successful
  55243. */
  55244. onSuccess: (task: TextureAssetTask) => void;
  55245. /**
  55246. * Callback called when the task is successful
  55247. */
  55248. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  55249. /**
  55250. * Creates a new TextureAssetTask object
  55251. * @param name defines the name of the task
  55252. * @param url defines the location of the file to load
  55253. * @param noMipmap defines if mipmap should not be generated (default is false)
  55254. * @param invertY defines if texture must be inverted on Y axis (default is false)
  55255. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55256. */
  55257. constructor(
  55258. /**
  55259. * Defines the name of the task
  55260. */
  55261. name: string,
  55262. /**
  55263. * Defines the location of the file to load
  55264. */
  55265. url: string,
  55266. /**
  55267. * Defines if mipmap should not be generated (default is false)
  55268. */
  55269. noMipmap?: boolean | undefined,
  55270. /**
  55271. * Defines if texture must be inverted on Y axis (default is false)
  55272. */
  55273. invertY?: boolean | undefined,
  55274. /**
  55275. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55276. */
  55277. samplingMode?: number);
  55278. /**
  55279. * Execute the current task
  55280. * @param scene defines the scene where you want your assets to be loaded
  55281. * @param onSuccess is a callback called when the task is successfully executed
  55282. * @param onError is a callback called if an error occurs
  55283. */
  55284. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55285. }
  55286. /**
  55287. * Define a task used by AssetsManager to load cube textures
  55288. */
  55289. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  55290. /**
  55291. * Defines the name of the task
  55292. */
  55293. name: string;
  55294. /**
  55295. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55296. */
  55297. url: string;
  55298. /**
  55299. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55300. */
  55301. extensions?: string[] | undefined;
  55302. /**
  55303. * Defines if mipmaps should not be generated (default is false)
  55304. */
  55305. noMipmap?: boolean | undefined;
  55306. /**
  55307. * Defines the explicit list of files (undefined by default)
  55308. */
  55309. files?: string[] | undefined;
  55310. /**
  55311. * Gets the loaded texture
  55312. */
  55313. texture: CubeTexture;
  55314. /**
  55315. * Callback called when the task is successful
  55316. */
  55317. onSuccess: (task: CubeTextureAssetTask) => void;
  55318. /**
  55319. * Callback called when the task is successful
  55320. */
  55321. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  55322. /**
  55323. * Creates a new CubeTextureAssetTask
  55324. * @param name defines the name of the task
  55325. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55326. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55327. * @param noMipmap defines if mipmaps should not be generated (default is false)
  55328. * @param files defines the explicit list of files (undefined by default)
  55329. */
  55330. constructor(
  55331. /**
  55332. * Defines the name of the task
  55333. */
  55334. name: string,
  55335. /**
  55336. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55337. */
  55338. url: string,
  55339. /**
  55340. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55341. */
  55342. extensions?: string[] | undefined,
  55343. /**
  55344. * Defines if mipmaps should not be generated (default is false)
  55345. */
  55346. noMipmap?: boolean | undefined,
  55347. /**
  55348. * Defines the explicit list of files (undefined by default)
  55349. */
  55350. files?: string[] | undefined);
  55351. /**
  55352. * Execute the current task
  55353. * @param scene defines the scene where you want your assets to be loaded
  55354. * @param onSuccess is a callback called when the task is successfully executed
  55355. * @param onError is a callback called if an error occurs
  55356. */
  55357. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55358. }
  55359. /**
  55360. * Define a task used by AssetsManager to load HDR cube textures
  55361. */
  55362. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  55363. /**
  55364. * Defines the name of the task
  55365. */
  55366. name: string;
  55367. /**
  55368. * Defines the location of the file to load
  55369. */
  55370. url: string;
  55371. /**
  55372. * Defines the desired size (the more it increases the longer the generation will be)
  55373. */
  55374. size: number;
  55375. /**
  55376. * Defines if mipmaps should not be generated (default is false)
  55377. */
  55378. noMipmap: boolean;
  55379. /**
  55380. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55381. */
  55382. generateHarmonics: boolean;
  55383. /**
  55384. * 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)
  55385. */
  55386. gammaSpace: boolean;
  55387. /**
  55388. * Internal Use Only
  55389. */
  55390. reserved: boolean;
  55391. /**
  55392. * Gets the loaded texture
  55393. */
  55394. texture: HDRCubeTexture;
  55395. /**
  55396. * Callback called when the task is successful
  55397. */
  55398. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  55399. /**
  55400. * Callback called when the task is successful
  55401. */
  55402. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  55403. /**
  55404. * Creates a new HDRCubeTextureAssetTask object
  55405. * @param name defines the name of the task
  55406. * @param url defines the location of the file to load
  55407. * @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.
  55408. * @param noMipmap defines if mipmaps should not be generated (default is false)
  55409. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55410. * @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)
  55411. * @param reserved Internal use only
  55412. */
  55413. constructor(
  55414. /**
  55415. * Defines the name of the task
  55416. */
  55417. name: string,
  55418. /**
  55419. * Defines the location of the file to load
  55420. */
  55421. url: string,
  55422. /**
  55423. * Defines the desired size (the more it increases the longer the generation will be)
  55424. */
  55425. size: number,
  55426. /**
  55427. * Defines if mipmaps should not be generated (default is false)
  55428. */
  55429. noMipmap?: boolean,
  55430. /**
  55431. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55432. */
  55433. generateHarmonics?: boolean,
  55434. /**
  55435. * 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)
  55436. */
  55437. gammaSpace?: boolean,
  55438. /**
  55439. * Internal Use Only
  55440. */
  55441. reserved?: boolean);
  55442. /**
  55443. * Execute the current task
  55444. * @param scene defines the scene where you want your assets to be loaded
  55445. * @param onSuccess is a callback called when the task is successfully executed
  55446. * @param onError is a callback called if an error occurs
  55447. */
  55448. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55449. }
  55450. /**
  55451. * This class can be used to easily import assets into a scene
  55452. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  55453. */
  55454. export class AssetsManager {
  55455. private _scene;
  55456. private _isLoading;
  55457. protected _tasks: AbstractAssetTask[];
  55458. protected _waitingTasksCount: number;
  55459. protected _totalTasksCount: number;
  55460. /**
  55461. * Callback called when all tasks are processed
  55462. */
  55463. onFinish: (tasks: AbstractAssetTask[]) => void;
  55464. /**
  55465. * Callback called when a task is successful
  55466. */
  55467. onTaskSuccess: (task: AbstractAssetTask) => void;
  55468. /**
  55469. * Callback called when a task had an error
  55470. */
  55471. onTaskError: (task: AbstractAssetTask) => void;
  55472. /**
  55473. * Callback called when a task is done (whatever the result is)
  55474. */
  55475. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  55476. /**
  55477. * Observable called when all tasks are processed
  55478. */
  55479. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  55480. /**
  55481. * Observable called when a task had an error
  55482. */
  55483. onTaskErrorObservable: Observable<AbstractAssetTask>;
  55484. /**
  55485. * Observable called when a task is successful
  55486. */
  55487. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  55488. /**
  55489. * Observable called when a task is done (whatever the result is)
  55490. */
  55491. onProgressObservable: Observable<IAssetsProgressEvent>;
  55492. /**
  55493. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  55494. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  55495. */
  55496. useDefaultLoadingScreen: boolean;
  55497. /**
  55498. * Creates a new AssetsManager
  55499. * @param scene defines the scene to work on
  55500. */
  55501. constructor(scene: Scene);
  55502. /**
  55503. * Add a MeshAssetTask to the list of active tasks
  55504. * @param taskName defines the name of the new task
  55505. * @param meshesNames defines the name of meshes to load
  55506. * @param rootUrl defines the root url to use to locate files
  55507. * @param sceneFilename defines the filename of the scene file
  55508. * @returns a new MeshAssetTask object
  55509. */
  55510. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  55511. /**
  55512. * Add a TextFileAssetTask to the list of active tasks
  55513. * @param taskName defines the name of the new task
  55514. * @param url defines the url of the file to load
  55515. * @returns a new TextFileAssetTask object
  55516. */
  55517. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  55518. /**
  55519. * Add a BinaryFileAssetTask to the list of active tasks
  55520. * @param taskName defines the name of the new task
  55521. * @param url defines the url of the file to load
  55522. * @returns a new BinaryFileAssetTask object
  55523. */
  55524. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  55525. /**
  55526. * Add a ImageAssetTask to the list of active tasks
  55527. * @param taskName defines the name of the new task
  55528. * @param url defines the url of the file to load
  55529. * @returns a new ImageAssetTask object
  55530. */
  55531. addImageTask(taskName: string, url: string): ImageAssetTask;
  55532. /**
  55533. * Add a TextureAssetTask to the list of active tasks
  55534. * @param taskName defines the name of the new task
  55535. * @param url defines the url of the file to load
  55536. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55537. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  55538. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55539. * @returns a new TextureAssetTask object
  55540. */
  55541. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  55542. /**
  55543. * Add a CubeTextureAssetTask to the list of active tasks
  55544. * @param taskName defines the name of the new task
  55545. * @param url defines the url of the file to load
  55546. * @param extensions defines the extension to use to load the cube map (can be null)
  55547. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55548. * @param files defines the list of files to load (can be null)
  55549. * @returns a new CubeTextureAssetTask object
  55550. */
  55551. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  55552. /**
  55553. *
  55554. * Add a HDRCubeTextureAssetTask to the list of active tasks
  55555. * @param taskName defines the name of the new task
  55556. * @param url defines the url of the file to load
  55557. * @param size defines the size you want for the cubemap (can be null)
  55558. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55559. * @param generateHarmonics defines if you want to automatically generate (true by default)
  55560. * @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)
  55561. * @param reserved Internal use only
  55562. * @returns a new HDRCubeTextureAssetTask object
  55563. */
  55564. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  55565. /**
  55566. * Remove a task from the assets manager.
  55567. * @param task the task to remove
  55568. */
  55569. removeTask(task: AbstractAssetTask): void;
  55570. private _decreaseWaitingTasksCount;
  55571. private _runTask;
  55572. /**
  55573. * Reset the AssetsManager and remove all tasks
  55574. * @return the current instance of the AssetsManager
  55575. */
  55576. reset(): AssetsManager;
  55577. /**
  55578. * Start the loading process
  55579. * @return the current instance of the AssetsManager
  55580. */
  55581. load(): AssetsManager;
  55582. }
  55583. }
  55584. declare module "babylonjs/Misc/deferred" {
  55585. /**
  55586. * Wrapper class for promise with external resolve and reject.
  55587. */
  55588. export class Deferred<T> {
  55589. /**
  55590. * The promise associated with this deferred object.
  55591. */
  55592. readonly promise: Promise<T>;
  55593. private _resolve;
  55594. private _reject;
  55595. /**
  55596. * The resolve method of the promise associated with this deferred object.
  55597. */
  55598. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  55599. /**
  55600. * The reject method of the promise associated with this deferred object.
  55601. */
  55602. readonly reject: (reason?: any) => void;
  55603. /**
  55604. * Constructor for this deferred object.
  55605. */
  55606. constructor();
  55607. }
  55608. }
  55609. declare module "babylonjs/Misc/filesInput" {
  55610. import { Engine } from "babylonjs/Engines/engine";
  55611. import { Scene } from "babylonjs/scene";
  55612. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  55613. /**
  55614. * Class used to help managing file picking and drag'n'drop
  55615. */
  55616. export class FilesInput {
  55617. /**
  55618. * List of files ready to be loaded
  55619. */
  55620. static readonly FilesToLoad: {
  55621. [key: string]: File;
  55622. };
  55623. /**
  55624. * Callback called when a file is processed
  55625. */
  55626. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  55627. private _engine;
  55628. private _currentScene;
  55629. private _sceneLoadedCallback;
  55630. private _progressCallback;
  55631. private _additionalRenderLoopLogicCallback;
  55632. private _textureLoadingCallback;
  55633. private _startingProcessingFilesCallback;
  55634. private _onReloadCallback;
  55635. private _errorCallback;
  55636. private _elementToMonitor;
  55637. private _sceneFileToLoad;
  55638. private _filesToLoad;
  55639. /**
  55640. * Creates a new FilesInput
  55641. * @param engine defines the rendering engine
  55642. * @param scene defines the hosting scene
  55643. * @param sceneLoadedCallback callback called when scene is loaded
  55644. * @param progressCallback callback called to track progress
  55645. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  55646. * @param textureLoadingCallback callback called when a texture is loading
  55647. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  55648. * @param onReloadCallback callback called when a reload is requested
  55649. * @param errorCallback callback call if an error occurs
  55650. */
  55651. 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);
  55652. private _dragEnterHandler;
  55653. private _dragOverHandler;
  55654. private _dropHandler;
  55655. /**
  55656. * Calls this function to listen to drag'n'drop events on a specific DOM element
  55657. * @param elementToMonitor defines the DOM element to track
  55658. */
  55659. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  55660. /**
  55661. * Release all associated resources
  55662. */
  55663. dispose(): void;
  55664. private renderFunction;
  55665. private drag;
  55666. private drop;
  55667. private _traverseFolder;
  55668. private _processFiles;
  55669. /**
  55670. * Load files from a drop event
  55671. * @param event defines the drop event to use as source
  55672. */
  55673. loadFiles(event: any): void;
  55674. private _processReload;
  55675. /**
  55676. * Reload the current scene from the loaded files
  55677. */
  55678. reload(): void;
  55679. }
  55680. }
  55681. declare module "babylonjs/Misc/HighDynamicRange/index" {
  55682. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  55683. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  55684. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  55685. }
  55686. declare module "babylonjs/Misc/sceneOptimizer" {
  55687. import { Scene, IDisposable } from "babylonjs/scene";
  55688. import { Observable } from "babylonjs/Misc/observable";
  55689. /**
  55690. * Defines the root class used to create scene optimization to use with SceneOptimizer
  55691. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55692. */
  55693. export class SceneOptimization {
  55694. /**
  55695. * Defines the priority of this optimization (0 by default which means first in the list)
  55696. */
  55697. priority: number;
  55698. /**
  55699. * Gets a string describing the action executed by the current optimization
  55700. * @returns description string
  55701. */
  55702. getDescription(): string;
  55703. /**
  55704. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55705. * @param scene defines the current scene where to apply this optimization
  55706. * @param optimizer defines the current optimizer
  55707. * @returns true if everything that can be done was applied
  55708. */
  55709. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55710. /**
  55711. * Creates the SceneOptimization object
  55712. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55713. * @param desc defines the description associated with the optimization
  55714. */
  55715. constructor(
  55716. /**
  55717. * Defines the priority of this optimization (0 by default which means first in the list)
  55718. */
  55719. priority?: number);
  55720. }
  55721. /**
  55722. * Defines an optimization used to reduce the size of render target textures
  55723. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55724. */
  55725. export class TextureOptimization extends SceneOptimization {
  55726. /**
  55727. * Defines the priority of this optimization (0 by default which means first in the list)
  55728. */
  55729. priority: number;
  55730. /**
  55731. * 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
  55732. */
  55733. maximumSize: number;
  55734. /**
  55735. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55736. */
  55737. step: number;
  55738. /**
  55739. * Gets a string describing the action executed by the current optimization
  55740. * @returns description string
  55741. */
  55742. getDescription(): string;
  55743. /**
  55744. * Creates the TextureOptimization object
  55745. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55746. * @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
  55747. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55748. */
  55749. constructor(
  55750. /**
  55751. * Defines the priority of this optimization (0 by default which means first in the list)
  55752. */
  55753. priority?: number,
  55754. /**
  55755. * 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
  55756. */
  55757. maximumSize?: number,
  55758. /**
  55759. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55760. */
  55761. step?: number);
  55762. /**
  55763. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55764. * @param scene defines the current scene where to apply this optimization
  55765. * @param optimizer defines the current optimizer
  55766. * @returns true if everything that can be done was applied
  55767. */
  55768. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55769. }
  55770. /**
  55771. * Defines an optimization used to increase or decrease the rendering resolution
  55772. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55773. */
  55774. export class HardwareScalingOptimization extends SceneOptimization {
  55775. /**
  55776. * Defines the priority of this optimization (0 by default which means first in the list)
  55777. */
  55778. priority: number;
  55779. /**
  55780. * Defines the maximum scale to use (2 by default)
  55781. */
  55782. maximumScale: number;
  55783. /**
  55784. * Defines the step to use between two passes (0.5 by default)
  55785. */
  55786. step: number;
  55787. private _currentScale;
  55788. private _directionOffset;
  55789. /**
  55790. * Gets a string describing the action executed by the current optimization
  55791. * @return description string
  55792. */
  55793. getDescription(): string;
  55794. /**
  55795. * Creates the HardwareScalingOptimization object
  55796. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55797. * @param maximumScale defines the maximum scale to use (2 by default)
  55798. * @param step defines the step to use between two passes (0.5 by default)
  55799. */
  55800. constructor(
  55801. /**
  55802. * Defines the priority of this optimization (0 by default which means first in the list)
  55803. */
  55804. priority?: number,
  55805. /**
  55806. * Defines the maximum scale to use (2 by default)
  55807. */
  55808. maximumScale?: number,
  55809. /**
  55810. * Defines the step to use between two passes (0.5 by default)
  55811. */
  55812. step?: number);
  55813. /**
  55814. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55815. * @param scene defines the current scene where to apply this optimization
  55816. * @param optimizer defines the current optimizer
  55817. * @returns true if everything that can be done was applied
  55818. */
  55819. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55820. }
  55821. /**
  55822. * Defines an optimization used to remove shadows
  55823. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55824. */
  55825. export class ShadowsOptimization extends SceneOptimization {
  55826. /**
  55827. * Gets a string describing the action executed by the current optimization
  55828. * @return description string
  55829. */
  55830. getDescription(): string;
  55831. /**
  55832. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55833. * @param scene defines the current scene where to apply this optimization
  55834. * @param optimizer defines the current optimizer
  55835. * @returns true if everything that can be done was applied
  55836. */
  55837. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55838. }
  55839. /**
  55840. * Defines an optimization used to turn post-processes off
  55841. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55842. */
  55843. export class PostProcessesOptimization extends SceneOptimization {
  55844. /**
  55845. * Gets a string describing the action executed by the current optimization
  55846. * @return description string
  55847. */
  55848. getDescription(): string;
  55849. /**
  55850. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55851. * @param scene defines the current scene where to apply this optimization
  55852. * @param optimizer defines the current optimizer
  55853. * @returns true if everything that can be done was applied
  55854. */
  55855. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55856. }
  55857. /**
  55858. * Defines an optimization used to turn lens flares off
  55859. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55860. */
  55861. export class LensFlaresOptimization extends SceneOptimization {
  55862. /**
  55863. * Gets a string describing the action executed by the current optimization
  55864. * @return description string
  55865. */
  55866. getDescription(): string;
  55867. /**
  55868. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55869. * @param scene defines the current scene where to apply this optimization
  55870. * @param optimizer defines the current optimizer
  55871. * @returns true if everything that can be done was applied
  55872. */
  55873. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55874. }
  55875. /**
  55876. * Defines an optimization based on user defined callback.
  55877. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55878. */
  55879. export class CustomOptimization extends SceneOptimization {
  55880. /**
  55881. * Callback called to apply the custom optimization.
  55882. */
  55883. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  55884. /**
  55885. * Callback called to get custom description
  55886. */
  55887. onGetDescription: () => string;
  55888. /**
  55889. * Gets a string describing the action executed by the current optimization
  55890. * @returns description string
  55891. */
  55892. getDescription(): string;
  55893. /**
  55894. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55895. * @param scene defines the current scene where to apply this optimization
  55896. * @param optimizer defines the current optimizer
  55897. * @returns true if everything that can be done was applied
  55898. */
  55899. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55900. }
  55901. /**
  55902. * Defines an optimization used to turn particles off
  55903. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55904. */
  55905. export class ParticlesOptimization extends SceneOptimization {
  55906. /**
  55907. * Gets a string describing the action executed by the current optimization
  55908. * @return description string
  55909. */
  55910. getDescription(): string;
  55911. /**
  55912. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55913. * @param scene defines the current scene where to apply this optimization
  55914. * @param optimizer defines the current optimizer
  55915. * @returns true if everything that can be done was applied
  55916. */
  55917. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55918. }
  55919. /**
  55920. * Defines an optimization used to turn render targets off
  55921. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55922. */
  55923. export class RenderTargetsOptimization extends SceneOptimization {
  55924. /**
  55925. * Gets a string describing the action executed by the current optimization
  55926. * @return description string
  55927. */
  55928. getDescription(): string;
  55929. /**
  55930. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55931. * @param scene defines the current scene where to apply this optimization
  55932. * @param optimizer defines the current optimizer
  55933. * @returns true if everything that can be done was applied
  55934. */
  55935. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55936. }
  55937. /**
  55938. * Defines an optimization used to merge meshes with compatible materials
  55939. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55940. */
  55941. export class MergeMeshesOptimization extends SceneOptimization {
  55942. private static _UpdateSelectionTree;
  55943. /**
  55944. * Gets or sets a boolean which defines if optimization octree has to be updated
  55945. */
  55946. /**
  55947. * Gets or sets a boolean which defines if optimization octree has to be updated
  55948. */
  55949. static UpdateSelectionTree: boolean;
  55950. /**
  55951. * Gets a string describing the action executed by the current optimization
  55952. * @return description string
  55953. */
  55954. getDescription(): string;
  55955. private _canBeMerged;
  55956. /**
  55957. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55958. * @param scene defines the current scene where to apply this optimization
  55959. * @param optimizer defines the current optimizer
  55960. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  55961. * @returns true if everything that can be done was applied
  55962. */
  55963. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  55964. }
  55965. /**
  55966. * Defines a list of options used by SceneOptimizer
  55967. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55968. */
  55969. export class SceneOptimizerOptions {
  55970. /**
  55971. * Defines the target frame rate to reach (60 by default)
  55972. */
  55973. targetFrameRate: number;
  55974. /**
  55975. * Defines the interval between two checkes (2000ms by default)
  55976. */
  55977. trackerDuration: number;
  55978. /**
  55979. * Gets the list of optimizations to apply
  55980. */
  55981. optimizations: SceneOptimization[];
  55982. /**
  55983. * Creates a new list of options used by SceneOptimizer
  55984. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  55985. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  55986. */
  55987. constructor(
  55988. /**
  55989. * Defines the target frame rate to reach (60 by default)
  55990. */
  55991. targetFrameRate?: number,
  55992. /**
  55993. * Defines the interval between two checkes (2000ms by default)
  55994. */
  55995. trackerDuration?: number);
  55996. /**
  55997. * Add a new optimization
  55998. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  55999. * @returns the current SceneOptimizerOptions
  56000. */
  56001. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  56002. /**
  56003. * Add a new custom optimization
  56004. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  56005. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  56006. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56007. * @returns the current SceneOptimizerOptions
  56008. */
  56009. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  56010. /**
  56011. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  56012. * @param targetFrameRate defines the target frame rate (60 by default)
  56013. * @returns a SceneOptimizerOptions object
  56014. */
  56015. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56016. /**
  56017. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  56018. * @param targetFrameRate defines the target frame rate (60 by default)
  56019. * @returns a SceneOptimizerOptions object
  56020. */
  56021. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56022. /**
  56023. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  56024. * @param targetFrameRate defines the target frame rate (60 by default)
  56025. * @returns a SceneOptimizerOptions object
  56026. */
  56027. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56028. }
  56029. /**
  56030. * Class used to run optimizations in order to reach a target frame rate
  56031. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56032. */
  56033. export class SceneOptimizer implements IDisposable {
  56034. private _isRunning;
  56035. private _options;
  56036. private _scene;
  56037. private _currentPriorityLevel;
  56038. private _targetFrameRate;
  56039. private _trackerDuration;
  56040. private _currentFrameRate;
  56041. private _sceneDisposeObserver;
  56042. private _improvementMode;
  56043. /**
  56044. * Defines an observable called when the optimizer reaches the target frame rate
  56045. */
  56046. onSuccessObservable: Observable<SceneOptimizer>;
  56047. /**
  56048. * Defines an observable called when the optimizer enables an optimization
  56049. */
  56050. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  56051. /**
  56052. * Defines an observable called when the optimizer is not able to reach the target frame rate
  56053. */
  56054. onFailureObservable: Observable<SceneOptimizer>;
  56055. /**
  56056. * Gets a boolean indicating if the optimizer is in improvement mode
  56057. */
  56058. readonly isInImprovementMode: boolean;
  56059. /**
  56060. * Gets the current priority level (0 at start)
  56061. */
  56062. readonly currentPriorityLevel: number;
  56063. /**
  56064. * Gets the current frame rate checked by the SceneOptimizer
  56065. */
  56066. readonly currentFrameRate: number;
  56067. /**
  56068. * Gets or sets the current target frame rate (60 by default)
  56069. */
  56070. /**
  56071. * Gets or sets the current target frame rate (60 by default)
  56072. */
  56073. targetFrameRate: number;
  56074. /**
  56075. * Gets or sets the current interval between two checks (every 2000ms by default)
  56076. */
  56077. /**
  56078. * Gets or sets the current interval between two checks (every 2000ms by default)
  56079. */
  56080. trackerDuration: number;
  56081. /**
  56082. * Gets the list of active optimizations
  56083. */
  56084. readonly optimizations: SceneOptimization[];
  56085. /**
  56086. * Creates a new SceneOptimizer
  56087. * @param scene defines the scene to work on
  56088. * @param options defines the options to use with the SceneOptimizer
  56089. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  56090. * @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)
  56091. */
  56092. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  56093. /**
  56094. * Stops the current optimizer
  56095. */
  56096. stop(): void;
  56097. /**
  56098. * Reset the optimizer to initial step (current priority level = 0)
  56099. */
  56100. reset(): void;
  56101. /**
  56102. * Start the optimizer. By default it will try to reach a specific framerate
  56103. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  56104. */
  56105. start(): void;
  56106. private _checkCurrentState;
  56107. /**
  56108. * Release all resources
  56109. */
  56110. dispose(): void;
  56111. /**
  56112. * Helper function to create a SceneOptimizer with one single line of code
  56113. * @param scene defines the scene to work on
  56114. * @param options defines the options to use with the SceneOptimizer
  56115. * @param onSuccess defines a callback to call on success
  56116. * @param onFailure defines a callback to call on failure
  56117. * @returns the new SceneOptimizer object
  56118. */
  56119. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  56120. }
  56121. }
  56122. declare module "babylonjs/Misc/sceneSerializer" {
  56123. import { Scene } from "babylonjs/scene";
  56124. /**
  56125. * Class used to serialize a scene into a string
  56126. */
  56127. export class SceneSerializer {
  56128. /**
  56129. * Clear cache used by a previous serialization
  56130. */
  56131. static ClearCache(): void;
  56132. /**
  56133. * Serialize a scene into a JSON compatible object
  56134. * @param scene defines the scene to serialize
  56135. * @returns a JSON compatible object
  56136. */
  56137. static Serialize(scene: Scene): any;
  56138. /**
  56139. * Serialize a mesh into a JSON compatible object
  56140. * @param toSerialize defines the mesh to serialize
  56141. * @param withParents defines if parents must be serialized as well
  56142. * @param withChildren defines if children must be serialized as well
  56143. * @returns a JSON compatible object
  56144. */
  56145. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  56146. }
  56147. }
  56148. declare module "babylonjs/Misc/videoRecorder" {
  56149. import { Nullable } from "babylonjs/types";
  56150. import { Engine } from "babylonjs/Engines/engine";
  56151. /**
  56152. * This represents the different options avilable for the video capture.
  56153. */
  56154. export interface VideoRecorderOptions {
  56155. /** Defines the mime type of the video */
  56156. mimeType: string;
  56157. /** Defines the video the video should be recorded at */
  56158. fps: number;
  56159. /** Defines the chunk size for the recording data */
  56160. recordChunckSize: number;
  56161. /** The audio tracks to attach to the record */
  56162. audioTracks?: MediaStreamTrack[];
  56163. }
  56164. /**
  56165. * This can helps recording videos from BabylonJS.
  56166. * This is based on the available WebRTC functionalities of the browser.
  56167. *
  56168. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  56169. */
  56170. export class VideoRecorder {
  56171. private static readonly _defaultOptions;
  56172. /**
  56173. * Returns wehther or not the VideoRecorder is available in your browser.
  56174. * @param engine Defines the Babylon Engine to check the support for
  56175. * @returns true if supported otherwise false
  56176. */
  56177. static IsSupported(engine: Engine): boolean;
  56178. private readonly _options;
  56179. private _canvas;
  56180. private _mediaRecorder;
  56181. private _recordedChunks;
  56182. private _fileName;
  56183. private _resolve;
  56184. private _reject;
  56185. /**
  56186. * True wether a recording is already in progress.
  56187. */
  56188. readonly isRecording: boolean;
  56189. /**
  56190. * Create a new VideoCapture object which can help converting what you see in Babylon to
  56191. * a video file.
  56192. * @param engine Defines the BabylonJS Engine you wish to record
  56193. * @param options Defines options that can be used to customized the capture
  56194. */
  56195. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  56196. /**
  56197. * Stops the current recording before the default capture timeout passed in the startRecording
  56198. * functions.
  56199. */
  56200. stopRecording(): void;
  56201. /**
  56202. * Starts recording the canvas for a max duration specified in parameters.
  56203. * @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.
  56204. * @param maxDuration Defines the maximum recording time in seconds.
  56205. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  56206. * @return a promise callback at the end of the recording with the video data in Blob.
  56207. */
  56208. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  56209. /**
  56210. * Releases internal resources used during the recording.
  56211. */
  56212. dispose(): void;
  56213. private _handleDataAvailable;
  56214. private _handleError;
  56215. private _handleStop;
  56216. }
  56217. }
  56218. declare module "babylonjs/Misc/workerPool" {
  56219. import { IDisposable } from "babylonjs/scene";
  56220. /**
  56221. * Helper class to push actions to a pool of workers.
  56222. */
  56223. export class WorkerPool implements IDisposable {
  56224. private _workerInfos;
  56225. private _pendingActions;
  56226. /**
  56227. * Constructor
  56228. * @param workers Array of workers to use for actions
  56229. */
  56230. constructor(workers: Array<Worker>);
  56231. /**
  56232. * Terminates all workers and clears any pending actions.
  56233. */
  56234. dispose(): void;
  56235. /**
  56236. * Pushes an action to the worker pool. If all the workers are active, the action will be
  56237. * pended until a worker has completed its action.
  56238. * @param action The action to perform. Call onComplete when the action is complete.
  56239. */
  56240. push(action: (worker: Worker, onComplete: () => void) => void): void;
  56241. private _execute;
  56242. }
  56243. }
  56244. declare module "babylonjs/Misc/screenshotTools" {
  56245. import { Camera } from "babylonjs/Cameras/camera";
  56246. import { Engine } from "babylonjs/Engines/engine";
  56247. /**
  56248. * Class containing a set of static utilities functions for screenshots
  56249. */
  56250. export class ScreenshotTools {
  56251. /**
  56252. * Captures a screenshot of the current rendering
  56253. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  56254. * @param engine defines the rendering engine
  56255. * @param camera defines the source camera
  56256. * @param size This parameter can be set to a single number or to an object with the
  56257. * following (optional) properties: precision, width, height. If a single number is passed,
  56258. * it will be used for both width and height. If an object is passed, the screenshot size
  56259. * will be derived from the parameters. The precision property is a multiplier allowing
  56260. * rendering at a higher or lower resolution
  56261. * @param successCallback defines the callback receives a single parameter which contains the
  56262. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  56263. * src parameter of an <img> to display it
  56264. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  56265. * Check your browser for supported MIME types
  56266. */
  56267. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  56268. /**
  56269. * Generates an image screenshot from the specified camera.
  56270. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  56271. * @param engine The engine to use for rendering
  56272. * @param camera The camera to use for rendering
  56273. * @param size This parameter can be set to a single number or to an object with the
  56274. * following (optional) properties: precision, width, height. If a single number is passed,
  56275. * it will be used for both width and height. If an object is passed, the screenshot size
  56276. * will be derived from the parameters. The precision property is a multiplier allowing
  56277. * rendering at a higher or lower resolution
  56278. * @param successCallback The callback receives a single parameter which contains the
  56279. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  56280. * src parameter of an <img> to display it
  56281. * @param mimeType The MIME type of the screenshot image (default: image/png).
  56282. * Check your browser for supported MIME types
  56283. * @param samples Texture samples (default: 1)
  56284. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  56285. * @param fileName A name for for the downloaded file.
  56286. */
  56287. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  56288. }
  56289. }
  56290. declare module "babylonjs/Misc/index" {
  56291. export * from "babylonjs/Misc/andOrNotEvaluator";
  56292. export * from "babylonjs/Misc/assetsManager";
  56293. export * from "babylonjs/Misc/dds";
  56294. export * from "babylonjs/Misc/decorators";
  56295. export * from "babylonjs/Misc/deferred";
  56296. export * from "babylonjs/Misc/environmentTextureTools";
  56297. export * from "babylonjs/Misc/filesInput";
  56298. export * from "babylonjs/Misc/HighDynamicRange/index";
  56299. export * from "babylonjs/Misc/khronosTextureContainer";
  56300. export * from "babylonjs/Misc/observable";
  56301. export * from "babylonjs/Misc/performanceMonitor";
  56302. export * from "babylonjs/Misc/promise";
  56303. export * from "babylonjs/Misc/sceneOptimizer";
  56304. export * from "babylonjs/Misc/sceneSerializer";
  56305. export * from "babylonjs/Misc/smartArray";
  56306. export * from "babylonjs/Misc/stringDictionary";
  56307. export * from "babylonjs/Misc/tags";
  56308. export * from "babylonjs/Misc/textureTools";
  56309. export * from "babylonjs/Misc/tga";
  56310. export * from "babylonjs/Misc/tools";
  56311. export * from "babylonjs/Misc/videoRecorder";
  56312. export * from "babylonjs/Misc/virtualJoystick";
  56313. export * from "babylonjs/Misc/workerPool";
  56314. export * from "babylonjs/Misc/logger";
  56315. export * from "babylonjs/Misc/typeStore";
  56316. export * from "babylonjs/Misc/filesInputStore";
  56317. export * from "babylonjs/Misc/deepCopier";
  56318. export * from "babylonjs/Misc/pivotTools";
  56319. export * from "babylonjs/Misc/precisionDate";
  56320. export * from "babylonjs/Misc/screenshotTools";
  56321. export * from "babylonjs/Misc/typeStore";
  56322. }
  56323. declare module "babylonjs/index" {
  56324. export * from "babylonjs/abstractScene";
  56325. export * from "babylonjs/Actions/index";
  56326. export * from "babylonjs/Animations/index";
  56327. export * from "babylonjs/assetContainer";
  56328. export * from "babylonjs/Audio/index";
  56329. export * from "babylonjs/Behaviors/index";
  56330. export * from "babylonjs/Bones/index";
  56331. export * from "babylonjs/Cameras/index";
  56332. export * from "babylonjs/Collisions/index";
  56333. export * from "babylonjs/Culling/index";
  56334. export * from "babylonjs/Debug/index";
  56335. export * from "babylonjs/Engines/index";
  56336. export * from "babylonjs/Events/index";
  56337. export * from "babylonjs/Gamepads/index";
  56338. export * from "babylonjs/Gizmos/index";
  56339. export * from "babylonjs/Helpers/index";
  56340. export * from "babylonjs/Instrumentation/index";
  56341. export * from "babylonjs/Layers/index";
  56342. export * from "babylonjs/LensFlares/index";
  56343. export * from "babylonjs/Lights/index";
  56344. export * from "babylonjs/Loading/index";
  56345. export * from "babylonjs/Materials/index";
  56346. export * from "babylonjs/Maths/index";
  56347. export * from "babylonjs/Meshes/index";
  56348. export * from "babylonjs/Morph/index";
  56349. export * from "babylonjs/node";
  56350. export * from "babylonjs/Offline/index";
  56351. export * from "babylonjs/Particles/index";
  56352. export * from "babylonjs/Physics/index";
  56353. export * from "babylonjs/PostProcesses/index";
  56354. export * from "babylonjs/Probes/index";
  56355. export * from "babylonjs/Rendering/index";
  56356. export * from "babylonjs/scene";
  56357. export * from "babylonjs/sceneComponent";
  56358. export * from "babylonjs/Sprites/index";
  56359. export * from "babylonjs/States/index";
  56360. export * from "babylonjs/Misc/index";
  56361. export * from "babylonjs/types";
  56362. }
  56363. declare module "babylonjs/Animations/pathCursor" {
  56364. import { Path2, Vector3 } from "babylonjs/Maths/math";
  56365. /**
  56366. * A cursor which tracks a point on a path
  56367. */
  56368. export class PathCursor {
  56369. private path;
  56370. /**
  56371. * Stores path cursor callbacks for when an onchange event is triggered
  56372. */
  56373. private _onchange;
  56374. /**
  56375. * The value of the path cursor
  56376. */
  56377. value: number;
  56378. /**
  56379. * The animation array of the path cursor
  56380. */
  56381. animations: Animation[];
  56382. /**
  56383. * Initializes the path cursor
  56384. * @param path The path to track
  56385. */
  56386. constructor(path: Path2);
  56387. /**
  56388. * Gets the cursor point on the path
  56389. * @returns A point on the path cursor at the cursor location
  56390. */
  56391. getPoint(): Vector3;
  56392. /**
  56393. * Moves the cursor ahead by the step amount
  56394. * @param step The amount to move the cursor forward
  56395. * @returns This path cursor
  56396. */
  56397. moveAhead(step?: number): PathCursor;
  56398. /**
  56399. * Moves the cursor behind by the step amount
  56400. * @param step The amount to move the cursor back
  56401. * @returns This path cursor
  56402. */
  56403. moveBack(step?: number): PathCursor;
  56404. /**
  56405. * Moves the cursor by the step amount
  56406. * If the step amount is greater than one, an exception is thrown
  56407. * @param step The amount to move the cursor
  56408. * @returns This path cursor
  56409. */
  56410. move(step: number): PathCursor;
  56411. /**
  56412. * Ensures that the value is limited between zero and one
  56413. * @returns This path cursor
  56414. */
  56415. private ensureLimits;
  56416. /**
  56417. * Runs onchange callbacks on change (used by the animation engine)
  56418. * @returns This path cursor
  56419. */
  56420. private raiseOnChange;
  56421. /**
  56422. * Executes a function on change
  56423. * @param f A path cursor onchange callback
  56424. * @returns This path cursor
  56425. */
  56426. onchange(f: (cursor: PathCursor) => void): PathCursor;
  56427. }
  56428. }
  56429. declare module "babylonjs/Legacy/legacy" {
  56430. export * from "babylonjs/index";
  56431. }
  56432. declare module "babylonjs/Shaders/blur.fragment" {
  56433. /** @hidden */
  56434. export var blurPixelShader: {
  56435. name: string;
  56436. shader: string;
  56437. };
  56438. }
  56439. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  56440. /** @hidden */
  56441. export var bones300Declaration: {
  56442. name: string;
  56443. shader: string;
  56444. };
  56445. }
  56446. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  56447. /** @hidden */
  56448. export var instances300Declaration: {
  56449. name: string;
  56450. shader: string;
  56451. };
  56452. }
  56453. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  56454. /** @hidden */
  56455. export var pointCloudVertexDeclaration: {
  56456. name: string;
  56457. shader: string;
  56458. };
  56459. }
  56460. // Mixins
  56461. interface Window {
  56462. mozIndexedDB: IDBFactory;
  56463. webkitIndexedDB: IDBFactory;
  56464. msIndexedDB: IDBFactory;
  56465. webkitURL: typeof URL;
  56466. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  56467. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  56468. WebGLRenderingContext: WebGLRenderingContext;
  56469. MSGesture: MSGesture;
  56470. CANNON: any;
  56471. AudioContext: AudioContext;
  56472. webkitAudioContext: AudioContext;
  56473. PointerEvent: any;
  56474. Math: Math;
  56475. Uint8Array: Uint8ArrayConstructor;
  56476. Float32Array: Float32ArrayConstructor;
  56477. mozURL: typeof URL;
  56478. msURL: typeof URL;
  56479. VRFrameData: any; // WebVR, from specs 1.1
  56480. DracoDecoderModule: any;
  56481. setImmediate(handler: (...args: any[]) => void): number;
  56482. }
  56483. interface Document {
  56484. mozCancelFullScreen(): void;
  56485. msCancelFullScreen(): void;
  56486. webkitCancelFullScreen(): void;
  56487. requestPointerLock(): void;
  56488. exitPointerLock(): void;
  56489. mozFullScreen: boolean;
  56490. msIsFullScreen: boolean;
  56491. readonly webkitIsFullScreen: boolean;
  56492. readonly pointerLockElement: Element;
  56493. mozPointerLockElement: HTMLElement;
  56494. msPointerLockElement: HTMLElement;
  56495. webkitPointerLockElement: HTMLElement;
  56496. }
  56497. interface HTMLCanvasElement {
  56498. requestPointerLock(): void;
  56499. msRequestPointerLock?(): void;
  56500. mozRequestPointerLock?(): void;
  56501. webkitRequestPointerLock?(): void;
  56502. /** Track wether a record is in progress */
  56503. isRecording: boolean;
  56504. /** Capture Stream method defined by some browsers */
  56505. captureStream(fps?: number): MediaStream;
  56506. }
  56507. interface CanvasRenderingContext2D {
  56508. msImageSmoothingEnabled: boolean;
  56509. }
  56510. interface MouseEvent {
  56511. mozMovementX: number;
  56512. mozMovementY: number;
  56513. webkitMovementX: number;
  56514. webkitMovementY: number;
  56515. msMovementX: number;
  56516. msMovementY: number;
  56517. }
  56518. interface Navigator {
  56519. mozGetVRDevices: (any: any) => any;
  56520. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56521. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56522. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56523. webkitGetGamepads(): Gamepad[];
  56524. msGetGamepads(): Gamepad[];
  56525. webkitGamepads(): Gamepad[];
  56526. }
  56527. interface HTMLVideoElement {
  56528. mozSrcObject: any;
  56529. }
  56530. interface Math {
  56531. fround(x: number): number;
  56532. imul(a: number, b: number): number;
  56533. }
  56534. interface WebGLProgram {
  56535. context?: WebGLRenderingContext;
  56536. vertexShader?: WebGLShader;
  56537. fragmentShader?: WebGLShader;
  56538. isParallelCompiled: boolean;
  56539. onCompiled?: () => void;
  56540. }
  56541. interface WebGLRenderingContext {
  56542. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  56543. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  56544. vertexAttribDivisor(index: number, divisor: number): void;
  56545. createVertexArray(): any;
  56546. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  56547. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  56548. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  56549. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  56550. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  56551. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  56552. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  56553. // Queries
  56554. createQuery(): WebGLQuery;
  56555. deleteQuery(query: WebGLQuery): void;
  56556. beginQuery(target: number, query: WebGLQuery): void;
  56557. endQuery(target: number): void;
  56558. getQueryParameter(query: WebGLQuery, pname: number): any;
  56559. getQuery(target: number, pname: number): any;
  56560. MAX_SAMPLES: number;
  56561. RGBA8: number;
  56562. READ_FRAMEBUFFER: number;
  56563. DRAW_FRAMEBUFFER: number;
  56564. UNIFORM_BUFFER: number;
  56565. HALF_FLOAT_OES: number;
  56566. RGBA16F: number;
  56567. RGBA32F: number;
  56568. R32F: number;
  56569. RG32F: number;
  56570. RGB32F: number;
  56571. R16F: number;
  56572. RG16F: number;
  56573. RGB16F: number;
  56574. RED: number;
  56575. RG: number;
  56576. R8: number;
  56577. RG8: number;
  56578. UNSIGNED_INT_24_8: number;
  56579. DEPTH24_STENCIL8: number;
  56580. /* Multiple Render Targets */
  56581. drawBuffers(buffers: number[]): void;
  56582. readBuffer(src: number): void;
  56583. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  56584. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  56585. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  56586. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  56587. // Occlusion Query
  56588. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  56589. ANY_SAMPLES_PASSED: number;
  56590. QUERY_RESULT_AVAILABLE: number;
  56591. QUERY_RESULT: number;
  56592. }
  56593. interface WebGLBuffer {
  56594. references: number;
  56595. capacity: number;
  56596. is32Bits: boolean;
  56597. }
  56598. interface WebGLProgram {
  56599. transformFeedback?: WebGLTransformFeedback | null;
  56600. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  56601. }
  56602. interface EXT_disjoint_timer_query {
  56603. QUERY_COUNTER_BITS_EXT: number;
  56604. TIME_ELAPSED_EXT: number;
  56605. TIMESTAMP_EXT: number;
  56606. GPU_DISJOINT_EXT: number;
  56607. QUERY_RESULT_EXT: number;
  56608. QUERY_RESULT_AVAILABLE_EXT: number;
  56609. queryCounterEXT(query: WebGLQuery, target: number): void;
  56610. createQueryEXT(): WebGLQuery;
  56611. beginQueryEXT(target: number, query: WebGLQuery): void;
  56612. endQueryEXT(target: number): void;
  56613. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  56614. deleteQueryEXT(query: WebGLQuery): void;
  56615. }
  56616. interface WebGLUniformLocation {
  56617. _currentState: any;
  56618. }
  56619. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  56620. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  56621. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  56622. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  56623. interface WebGLRenderingContext {
  56624. readonly RASTERIZER_DISCARD: number;
  56625. readonly DEPTH_COMPONENT24: number;
  56626. readonly TEXTURE_3D: number;
  56627. readonly TEXTURE_2D_ARRAY: number;
  56628. readonly TEXTURE_COMPARE_FUNC: number;
  56629. readonly TEXTURE_COMPARE_MODE: number;
  56630. readonly COMPARE_REF_TO_TEXTURE: number;
  56631. readonly TEXTURE_WRAP_R: number;
  56632. readonly HALF_FLOAT: number;
  56633. readonly RGB8: number;
  56634. readonly RED_INTEGER: number;
  56635. readonly RG_INTEGER: number;
  56636. readonly RGB_INTEGER: number;
  56637. readonly RGBA_INTEGER: number;
  56638. readonly R8_SNORM: number;
  56639. readonly RG8_SNORM: number;
  56640. readonly RGB8_SNORM: number;
  56641. readonly RGBA8_SNORM: number;
  56642. readonly R8I: number;
  56643. readonly RG8I: number;
  56644. readonly RGB8I: number;
  56645. readonly RGBA8I: number;
  56646. readonly R8UI: number;
  56647. readonly RG8UI: number;
  56648. readonly RGB8UI: number;
  56649. readonly RGBA8UI: number;
  56650. readonly R16I: number;
  56651. readonly RG16I: number;
  56652. readonly RGB16I: number;
  56653. readonly RGBA16I: number;
  56654. readonly R16UI: number;
  56655. readonly RG16UI: number;
  56656. readonly RGB16UI: number;
  56657. readonly RGBA16UI: number;
  56658. readonly R32I: number;
  56659. readonly RG32I: number;
  56660. readonly RGB32I: number;
  56661. readonly RGBA32I: number;
  56662. readonly R32UI: number;
  56663. readonly RG32UI: number;
  56664. readonly RGB32UI: number;
  56665. readonly RGBA32UI: number;
  56666. readonly RGB10_A2UI: number;
  56667. readonly R11F_G11F_B10F: number;
  56668. readonly RGB9_E5: number;
  56669. readonly RGB10_A2: number;
  56670. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  56671. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  56672. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  56673. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  56674. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  56675. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  56676. 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;
  56677. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  56678. readonly TRANSFORM_FEEDBACK: number;
  56679. readonly INTERLEAVED_ATTRIBS: number;
  56680. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  56681. createTransformFeedback(): WebGLTransformFeedback;
  56682. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  56683. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  56684. beginTransformFeedback(primitiveMode: number): void;
  56685. endTransformFeedback(): void;
  56686. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  56687. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56688. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56689. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56690. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  56691. }
  56692. interface ImageBitmap {
  56693. readonly width: number;
  56694. readonly height: number;
  56695. close(): void;
  56696. }
  56697. interface WebGLQuery extends WebGLObject {
  56698. }
  56699. declare var WebGLQuery: {
  56700. prototype: WebGLQuery;
  56701. new(): WebGLQuery;
  56702. };
  56703. interface WebGLSampler extends WebGLObject {
  56704. }
  56705. declare var WebGLSampler: {
  56706. prototype: WebGLSampler;
  56707. new(): WebGLSampler;
  56708. };
  56709. interface WebGLSync extends WebGLObject {
  56710. }
  56711. declare var WebGLSync: {
  56712. prototype: WebGLSync;
  56713. new(): WebGLSync;
  56714. };
  56715. interface WebGLTransformFeedback extends WebGLObject {
  56716. }
  56717. declare var WebGLTransformFeedback: {
  56718. prototype: WebGLTransformFeedback;
  56719. new(): WebGLTransformFeedback;
  56720. };
  56721. interface WebGLVertexArrayObject extends WebGLObject {
  56722. }
  56723. declare var WebGLVertexArrayObject: {
  56724. prototype: WebGLVertexArrayObject;
  56725. new(): WebGLVertexArrayObject;
  56726. };
  56727. // Type definitions for WebVR API
  56728. // Project: https://w3c.github.io/webvr/
  56729. // Definitions by: six a <https://github.com/lostfictions>
  56730. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  56731. interface VRDisplay extends EventTarget {
  56732. /**
  56733. * Dictionary of capabilities describing the VRDisplay.
  56734. */
  56735. readonly capabilities: VRDisplayCapabilities;
  56736. /**
  56737. * z-depth defining the far plane of the eye view frustum
  56738. * enables mapping of values in the render target depth
  56739. * attachment to scene coordinates. Initially set to 10000.0.
  56740. */
  56741. depthFar: number;
  56742. /**
  56743. * z-depth defining the near plane of the eye view frustum
  56744. * enables mapping of values in the render target depth
  56745. * attachment to scene coordinates. Initially set to 0.01.
  56746. */
  56747. depthNear: number;
  56748. /**
  56749. * An identifier for this distinct VRDisplay. Used as an
  56750. * association point in the Gamepad API.
  56751. */
  56752. readonly displayId: number;
  56753. /**
  56754. * A display name, a user-readable name identifying it.
  56755. */
  56756. readonly displayName: string;
  56757. readonly isConnected: boolean;
  56758. readonly isPresenting: boolean;
  56759. /**
  56760. * If this VRDisplay supports room-scale experiences, the optional
  56761. * stage attribute contains details on the room-scale parameters.
  56762. */
  56763. readonly stageParameters: VRStageParameters | null;
  56764. /**
  56765. * Passing the value returned by `requestAnimationFrame` to
  56766. * `cancelAnimationFrame` will unregister the callback.
  56767. * @param handle Define the hanle of the request to cancel
  56768. */
  56769. cancelAnimationFrame(handle: number): void;
  56770. /**
  56771. * Stops presenting to the VRDisplay.
  56772. * @returns a promise to know when it stopped
  56773. */
  56774. exitPresent(): Promise<void>;
  56775. /**
  56776. * Return the current VREyeParameters for the given eye.
  56777. * @param whichEye Define the eye we want the parameter for
  56778. * @returns the eye parameters
  56779. */
  56780. getEyeParameters(whichEye: string): VREyeParameters;
  56781. /**
  56782. * Populates the passed VRFrameData with the information required to render
  56783. * the current frame.
  56784. * @param frameData Define the data structure to populate
  56785. * @returns true if ok otherwise false
  56786. */
  56787. getFrameData(frameData: VRFrameData): boolean;
  56788. /**
  56789. * Get the layers currently being presented.
  56790. * @returns the list of VR layers
  56791. */
  56792. getLayers(): VRLayer[];
  56793. /**
  56794. * Return a VRPose containing the future predicted pose of the VRDisplay
  56795. * when the current frame will be presented. The value returned will not
  56796. * change until JavaScript has returned control to the browser.
  56797. *
  56798. * The VRPose will contain the position, orientation, velocity,
  56799. * and acceleration of each of these properties.
  56800. * @returns the pose object
  56801. */
  56802. getPose(): VRPose;
  56803. /**
  56804. * Return the current instantaneous pose of the VRDisplay, with no
  56805. * prediction applied.
  56806. * @returns the current instantaneous pose
  56807. */
  56808. getImmediatePose(): VRPose;
  56809. /**
  56810. * The callback passed to `requestAnimationFrame` will be called
  56811. * any time a new frame should be rendered. When the VRDisplay is
  56812. * presenting the callback will be called at the native refresh
  56813. * rate of the HMD. When not presenting this function acts
  56814. * identically to how window.requestAnimationFrame acts. Content should
  56815. * make no assumptions of frame rate or vsync behavior as the HMD runs
  56816. * asynchronously from other displays and at differing refresh rates.
  56817. * @param callback Define the eaction to run next frame
  56818. * @returns the request handle it
  56819. */
  56820. requestAnimationFrame(callback: FrameRequestCallback): number;
  56821. /**
  56822. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  56823. * Repeat calls while already presenting will update the VRLayers being displayed.
  56824. * @param layers Define the list of layer to present
  56825. * @returns a promise to know when the request has been fulfilled
  56826. */
  56827. requestPresent(layers: VRLayer[]): Promise<void>;
  56828. /**
  56829. * Reset the pose for this display, treating its current position and
  56830. * orientation as the "origin/zero" values. VRPose.position,
  56831. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  56832. * updated when calling resetPose(). This should be called in only
  56833. * sitting-space experiences.
  56834. */
  56835. resetPose(): void;
  56836. /**
  56837. * The VRLayer provided to the VRDisplay will be captured and presented
  56838. * in the HMD. Calling this function has the same effect on the source
  56839. * canvas as any other operation that uses its source image, and canvases
  56840. * created without preserveDrawingBuffer set to true will be cleared.
  56841. * @param pose Define the pose to submit
  56842. */
  56843. submitFrame(pose?: VRPose): void;
  56844. }
  56845. declare var VRDisplay: {
  56846. prototype: VRDisplay;
  56847. new(): VRDisplay;
  56848. };
  56849. interface VRLayer {
  56850. leftBounds?: number[] | Float32Array | null;
  56851. rightBounds?: number[] | Float32Array | null;
  56852. source?: HTMLCanvasElement | null;
  56853. }
  56854. interface VRDisplayCapabilities {
  56855. readonly canPresent: boolean;
  56856. readonly hasExternalDisplay: boolean;
  56857. readonly hasOrientation: boolean;
  56858. readonly hasPosition: boolean;
  56859. readonly maxLayers: number;
  56860. }
  56861. interface VREyeParameters {
  56862. /** @deprecated */
  56863. readonly fieldOfView: VRFieldOfView;
  56864. readonly offset: Float32Array;
  56865. readonly renderHeight: number;
  56866. readonly renderWidth: number;
  56867. }
  56868. interface VRFieldOfView {
  56869. readonly downDegrees: number;
  56870. readonly leftDegrees: number;
  56871. readonly rightDegrees: number;
  56872. readonly upDegrees: number;
  56873. }
  56874. interface VRFrameData {
  56875. readonly leftProjectionMatrix: Float32Array;
  56876. readonly leftViewMatrix: Float32Array;
  56877. readonly pose: VRPose;
  56878. readonly rightProjectionMatrix: Float32Array;
  56879. readonly rightViewMatrix: Float32Array;
  56880. readonly timestamp: number;
  56881. }
  56882. interface VRPose {
  56883. readonly angularAcceleration: Float32Array | null;
  56884. readonly angularVelocity: Float32Array | null;
  56885. readonly linearAcceleration: Float32Array | null;
  56886. readonly linearVelocity: Float32Array | null;
  56887. readonly orientation: Float32Array | null;
  56888. readonly position: Float32Array | null;
  56889. readonly timestamp: number;
  56890. }
  56891. interface VRStageParameters {
  56892. sittingToStandingTransform?: Float32Array;
  56893. sizeX?: number;
  56894. sizeY?: number;
  56895. }
  56896. interface Navigator {
  56897. getVRDisplays(): Promise<VRDisplay[]>;
  56898. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  56899. }
  56900. interface Window {
  56901. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  56902. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  56903. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  56904. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  56905. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  56906. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  56907. }
  56908. interface Gamepad {
  56909. readonly displayId: number;
  56910. }
  56911. interface XRDevice {
  56912. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  56913. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  56914. }
  56915. interface XRSession {
  56916. getInputSources(): Array<any>;
  56917. baseLayer: XRWebGLLayer;
  56918. requestFrameOfReference(type: string): Promise<void>;
  56919. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  56920. end(): Promise<void>;
  56921. requestAnimationFrame: Function;
  56922. addEventListener: Function;
  56923. }
  56924. interface XRSessionCreationOptions {
  56925. outputContext?: WebGLRenderingContext | null;
  56926. immersive?: boolean;
  56927. environmentIntegration?: boolean;
  56928. }
  56929. interface XRLayer {
  56930. getViewport: Function;
  56931. framebufferWidth: number;
  56932. framebufferHeight: number;
  56933. }
  56934. interface XRView {
  56935. projectionMatrix: Float32Array;
  56936. }
  56937. interface XRFrame {
  56938. getDevicePose: Function;
  56939. getInputPose: Function;
  56940. views: Array<XRView>;
  56941. baseLayer: XRLayer;
  56942. }
  56943. interface XRFrameOfReference {
  56944. }
  56945. interface XRWebGLLayer extends XRLayer {
  56946. framebuffer: WebGLFramebuffer;
  56947. }
  56948. declare var XRWebGLLayer: {
  56949. prototype: XRWebGLLayer;
  56950. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  56951. };
  56952. declare module "babylonjs" {
  56953. export * from "babylonjs/Legacy/legacy";
  56954. }
  56955. declare module BABYLON {
  56956. /** Alias type for value that can be null */
  56957. export type Nullable<T> = T | null;
  56958. /**
  56959. * Alias type for number that are floats
  56960. * @ignorenaming
  56961. */
  56962. export type float = number;
  56963. /**
  56964. * Alias type for number that are doubles.
  56965. * @ignorenaming
  56966. */
  56967. export type double = number;
  56968. /**
  56969. * Alias type for number that are integer
  56970. * @ignorenaming
  56971. */
  56972. export type int = number;
  56973. /** Alias type for number array or Float32Array */
  56974. export type FloatArray = number[] | Float32Array;
  56975. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  56976. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  56977. /**
  56978. * Alias for types that can be used by a Buffer or VertexBuffer.
  56979. */
  56980. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  56981. /**
  56982. * Alias type for primitive types
  56983. * @ignorenaming
  56984. */
  56985. type Primitive = undefined | null | boolean | string | number | Function;
  56986. /**
  56987. * Type modifier to make all the properties of an object Readonly
  56988. */
  56989. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  56990. /**
  56991. * Type modifier to make all the properties of an object Readonly recursively
  56992. */
  56993. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  56994. /** @hidden */
  56995. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  56996. }
  56997. /** @hidden */
  56998. /** @hidden */
  56999. type DeepImmutableObject<T> = {
  57000. readonly [K in keyof T]: DeepImmutable<T[K]>;
  57001. };
  57002. }
  57003. declare module BABYLON {
  57004. /**
  57005. * Class containing a set of static utilities functions for arrays.
  57006. */
  57007. export class ArrayTools {
  57008. /**
  57009. * Returns an array of the given size filled with element built from the given constructor and the paramters
  57010. * @param size the number of element to construct and put in the array
  57011. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  57012. * @returns a new array filled with new objects
  57013. */
  57014. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  57015. }
  57016. }
  57017. declare module BABYLON {
  57018. /**
  57019. * Scalar computation library
  57020. */
  57021. export class Scalar {
  57022. /**
  57023. * Two pi constants convenient for computation.
  57024. */
  57025. static TwoPi: number;
  57026. /**
  57027. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  57028. * @param a number
  57029. * @param b number
  57030. * @param epsilon (default = 1.401298E-45)
  57031. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  57032. */
  57033. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  57034. /**
  57035. * Returns a string : the upper case translation of the number i to hexadecimal.
  57036. * @param i number
  57037. * @returns the upper case translation of the number i to hexadecimal.
  57038. */
  57039. static ToHex(i: number): string;
  57040. /**
  57041. * Returns -1 if value is negative and +1 is value is positive.
  57042. * @param value the value
  57043. * @returns the value itself if it's equal to zero.
  57044. */
  57045. static Sign(value: number): number;
  57046. /**
  57047. * Returns the value itself if it's between min and max.
  57048. * Returns min if the value is lower than min.
  57049. * Returns max if the value is greater than max.
  57050. * @param value the value to clmap
  57051. * @param min the min value to clamp to (default: 0)
  57052. * @param max the max value to clamp to (default: 1)
  57053. * @returns the clamped value
  57054. */
  57055. static Clamp(value: number, min?: number, max?: number): number;
  57056. /**
  57057. * the log2 of value.
  57058. * @param value the value to compute log2 of
  57059. * @returns the log2 of value.
  57060. */
  57061. static Log2(value: number): number;
  57062. /**
  57063. * Loops the value, so that it is never larger than length and never smaller than 0.
  57064. *
  57065. * This is similar to the modulo operator but it works with floating point numbers.
  57066. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  57067. * With t = 5 and length = 2.5, the result would be 0.0.
  57068. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  57069. * @param value the value
  57070. * @param length the length
  57071. * @returns the looped value
  57072. */
  57073. static Repeat(value: number, length: number): number;
  57074. /**
  57075. * Normalize the value between 0.0 and 1.0 using min and max values
  57076. * @param value value to normalize
  57077. * @param min max to normalize between
  57078. * @param max min to normalize between
  57079. * @returns the normalized value
  57080. */
  57081. static Normalize(value: number, min: number, max: number): number;
  57082. /**
  57083. * Denormalize the value from 0.0 and 1.0 using min and max values
  57084. * @param normalized value to denormalize
  57085. * @param min max to denormalize between
  57086. * @param max min to denormalize between
  57087. * @returns the denormalized value
  57088. */
  57089. static Denormalize(normalized: number, min: number, max: number): number;
  57090. /**
  57091. * Calculates the shortest difference between two given angles given in degrees.
  57092. * @param current current angle in degrees
  57093. * @param target target angle in degrees
  57094. * @returns the delta
  57095. */
  57096. static DeltaAngle(current: number, target: number): number;
  57097. /**
  57098. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  57099. * @param tx value
  57100. * @param length length
  57101. * @returns The returned value will move back and forth between 0 and length
  57102. */
  57103. static PingPong(tx: number, length: number): number;
  57104. /**
  57105. * Interpolates between min and max with smoothing at the limits.
  57106. *
  57107. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  57108. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  57109. * @param from from
  57110. * @param to to
  57111. * @param tx value
  57112. * @returns the smooth stepped value
  57113. */
  57114. static SmoothStep(from: number, to: number, tx: number): number;
  57115. /**
  57116. * Moves a value current towards target.
  57117. *
  57118. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  57119. * Negative values of maxDelta pushes the value away from target.
  57120. * @param current current value
  57121. * @param target target value
  57122. * @param maxDelta max distance to move
  57123. * @returns resulting value
  57124. */
  57125. static MoveTowards(current: number, target: number, maxDelta: number): number;
  57126. /**
  57127. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  57128. *
  57129. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  57130. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  57131. * @param current current value
  57132. * @param target target value
  57133. * @param maxDelta max distance to move
  57134. * @returns resulting angle
  57135. */
  57136. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  57137. /**
  57138. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  57139. * @param start start value
  57140. * @param end target value
  57141. * @param amount amount to lerp between
  57142. * @returns the lerped value
  57143. */
  57144. static Lerp(start: number, end: number, amount: number): number;
  57145. /**
  57146. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  57147. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  57148. * @param start start value
  57149. * @param end target value
  57150. * @param amount amount to lerp between
  57151. * @returns the lerped value
  57152. */
  57153. static LerpAngle(start: number, end: number, amount: number): number;
  57154. /**
  57155. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  57156. * @param a start value
  57157. * @param b target value
  57158. * @param value value between a and b
  57159. * @returns the inverseLerp value
  57160. */
  57161. static InverseLerp(a: number, b: number, value: number): number;
  57162. /**
  57163. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  57164. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  57165. * @param value1 spline value
  57166. * @param tangent1 spline value
  57167. * @param value2 spline value
  57168. * @param tangent2 spline value
  57169. * @param amount input value
  57170. * @returns hermite result
  57171. */
  57172. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  57173. /**
  57174. * Returns a random float number between and min and max values
  57175. * @param min min value of random
  57176. * @param max max value of random
  57177. * @returns random value
  57178. */
  57179. static RandomRange(min: number, max: number): number;
  57180. /**
  57181. * This function returns percentage of a number in a given range.
  57182. *
  57183. * RangeToPercent(40,20,60) will return 0.5 (50%)
  57184. * RangeToPercent(34,0,100) will return 0.34 (34%)
  57185. * @param number to convert to percentage
  57186. * @param min min range
  57187. * @param max max range
  57188. * @returns the percentage
  57189. */
  57190. static RangeToPercent(number: number, min: number, max: number): number;
  57191. /**
  57192. * This function returns number that corresponds to the percentage in a given range.
  57193. *
  57194. * PercentToRange(0.34,0,100) will return 34.
  57195. * @param percent to convert to number
  57196. * @param min min range
  57197. * @param max max range
  57198. * @returns the number
  57199. */
  57200. static PercentToRange(percent: number, min: number, max: number): number;
  57201. /**
  57202. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  57203. * @param angle The angle to normalize in radian.
  57204. * @return The converted angle.
  57205. */
  57206. static NormalizeRadians(angle: number): number;
  57207. }
  57208. }
  57209. declare module BABYLON {
  57210. /**
  57211. * Constant used to convert a value to gamma space
  57212. * @ignorenaming
  57213. */
  57214. export const ToGammaSpace: number;
  57215. /**
  57216. * Constant used to convert a value to linear space
  57217. * @ignorenaming
  57218. */
  57219. export const ToLinearSpace = 2.2;
  57220. /**
  57221. * Constant used to define the minimal number value in Babylon.js
  57222. * @ignorenaming
  57223. */
  57224. export const Epsilon = 0.001;
  57225. /**
  57226. * Class used to hold a RBG color
  57227. */
  57228. export class Color3 {
  57229. /**
  57230. * Defines the red component (between 0 and 1, default is 0)
  57231. */
  57232. r: number;
  57233. /**
  57234. * Defines the green component (between 0 and 1, default is 0)
  57235. */
  57236. g: number;
  57237. /**
  57238. * Defines the blue component (between 0 and 1, default is 0)
  57239. */
  57240. b: number;
  57241. /**
  57242. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  57243. * @param r defines the red component (between 0 and 1, default is 0)
  57244. * @param g defines the green component (between 0 and 1, default is 0)
  57245. * @param b defines the blue component (between 0 and 1, default is 0)
  57246. */
  57247. constructor(
  57248. /**
  57249. * Defines the red component (between 0 and 1, default is 0)
  57250. */
  57251. r?: number,
  57252. /**
  57253. * Defines the green component (between 0 and 1, default is 0)
  57254. */
  57255. g?: number,
  57256. /**
  57257. * Defines the blue component (between 0 and 1, default is 0)
  57258. */
  57259. b?: number);
  57260. /**
  57261. * Creates a string with the Color3 current values
  57262. * @returns the string representation of the Color3 object
  57263. */
  57264. toString(): string;
  57265. /**
  57266. * Returns the string "Color3"
  57267. * @returns "Color3"
  57268. */
  57269. getClassName(): string;
  57270. /**
  57271. * Compute the Color3 hash code
  57272. * @returns an unique number that can be used to hash Color3 objects
  57273. */
  57274. getHashCode(): number;
  57275. /**
  57276. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  57277. * @param array defines the array where to store the r,g,b components
  57278. * @param index defines an optional index in the target array to define where to start storing values
  57279. * @returns the current Color3 object
  57280. */
  57281. toArray(array: FloatArray, index?: number): Color3;
  57282. /**
  57283. * Returns a new Color4 object from the current Color3 and the given alpha
  57284. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  57285. * @returns a new Color4 object
  57286. */
  57287. toColor4(alpha?: number): Color4;
  57288. /**
  57289. * Returns a new array populated with 3 numeric elements : red, green and blue values
  57290. * @returns the new array
  57291. */
  57292. asArray(): number[];
  57293. /**
  57294. * Returns the luminance value
  57295. * @returns a float value
  57296. */
  57297. toLuminance(): number;
  57298. /**
  57299. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  57300. * @param otherColor defines the second operand
  57301. * @returns the new Color3 object
  57302. */
  57303. multiply(otherColor: DeepImmutable<Color3>): Color3;
  57304. /**
  57305. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  57306. * @param otherColor defines the second operand
  57307. * @param result defines the Color3 object where to store the result
  57308. * @returns the current Color3
  57309. */
  57310. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  57311. /**
  57312. * Determines equality between Color3 objects
  57313. * @param otherColor defines the second operand
  57314. * @returns true if the rgb values are equal to the given ones
  57315. */
  57316. equals(otherColor: DeepImmutable<Color3>): boolean;
  57317. /**
  57318. * Determines equality between the current Color3 object and a set of r,b,g values
  57319. * @param r defines the red component to check
  57320. * @param g defines the green component to check
  57321. * @param b defines the blue component to check
  57322. * @returns true if the rgb values are equal to the given ones
  57323. */
  57324. equalsFloats(r: number, g: number, b: number): boolean;
  57325. /**
  57326. * Multiplies in place each rgb value by scale
  57327. * @param scale defines the scaling factor
  57328. * @returns the updated Color3
  57329. */
  57330. scale(scale: number): Color3;
  57331. /**
  57332. * Multiplies the rgb values by scale and stores the result into "result"
  57333. * @param scale defines the scaling factor
  57334. * @param result defines the Color3 object where to store the result
  57335. * @returns the unmodified current Color3
  57336. */
  57337. scaleToRef(scale: number, result: Color3): Color3;
  57338. /**
  57339. * Scale the current Color3 values by a factor and add the result to a given Color3
  57340. * @param scale defines the scale factor
  57341. * @param result defines color to store the result into
  57342. * @returns the unmodified current Color3
  57343. */
  57344. scaleAndAddToRef(scale: number, result: Color3): Color3;
  57345. /**
  57346. * Clamps the rgb values by the min and max values and stores the result into "result"
  57347. * @param min defines minimum clamping value (default is 0)
  57348. * @param max defines maximum clamping value (default is 1)
  57349. * @param result defines color to store the result into
  57350. * @returns the original Color3
  57351. */
  57352. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  57353. /**
  57354. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  57355. * @param otherColor defines the second operand
  57356. * @returns the new Color3
  57357. */
  57358. add(otherColor: DeepImmutable<Color3>): Color3;
  57359. /**
  57360. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  57361. * @param otherColor defines the second operand
  57362. * @param result defines Color3 object to store the result into
  57363. * @returns the unmodified current Color3
  57364. */
  57365. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  57366. /**
  57367. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  57368. * @param otherColor defines the second operand
  57369. * @returns the new Color3
  57370. */
  57371. subtract(otherColor: DeepImmutable<Color3>): Color3;
  57372. /**
  57373. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  57374. * @param otherColor defines the second operand
  57375. * @param result defines Color3 object to store the result into
  57376. * @returns the unmodified current Color3
  57377. */
  57378. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  57379. /**
  57380. * Copy the current object
  57381. * @returns a new Color3 copied the current one
  57382. */
  57383. clone(): Color3;
  57384. /**
  57385. * Copies the rgb values from the source in the current Color3
  57386. * @param source defines the source Color3 object
  57387. * @returns the updated Color3 object
  57388. */
  57389. copyFrom(source: DeepImmutable<Color3>): Color3;
  57390. /**
  57391. * Updates the Color3 rgb values from the given floats
  57392. * @param r defines the red component to read from
  57393. * @param g defines the green component to read from
  57394. * @param b defines the blue component to read from
  57395. * @returns the current Color3 object
  57396. */
  57397. copyFromFloats(r: number, g: number, b: number): Color3;
  57398. /**
  57399. * Updates the Color3 rgb values from the given floats
  57400. * @param r defines the red component to read from
  57401. * @param g defines the green component to read from
  57402. * @param b defines the blue component to read from
  57403. * @returns the current Color3 object
  57404. */
  57405. set(r: number, g: number, b: number): Color3;
  57406. /**
  57407. * Compute the Color3 hexadecimal code as a string
  57408. * @returns a string containing the hexadecimal representation of the Color3 object
  57409. */
  57410. toHexString(): string;
  57411. /**
  57412. * Computes a new Color3 converted from the current one to linear space
  57413. * @returns a new Color3 object
  57414. */
  57415. toLinearSpace(): Color3;
  57416. /**
  57417. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  57418. * @param convertedColor defines the Color3 object where to store the linear space version
  57419. * @returns the unmodified Color3
  57420. */
  57421. toLinearSpaceToRef(convertedColor: Color3): Color3;
  57422. /**
  57423. * Computes a new Color3 converted from the current one to gamma space
  57424. * @returns a new Color3 object
  57425. */
  57426. toGammaSpace(): Color3;
  57427. /**
  57428. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  57429. * @param convertedColor defines the Color3 object where to store the gamma space version
  57430. * @returns the unmodified Color3
  57431. */
  57432. toGammaSpaceToRef(convertedColor: Color3): Color3;
  57433. private static _BlackReadOnly;
  57434. /**
  57435. * Creates a new Color3 from the string containing valid hexadecimal values
  57436. * @param hex defines a string containing valid hexadecimal values
  57437. * @returns a new Color3 object
  57438. */
  57439. static FromHexString(hex: string): Color3;
  57440. /**
  57441. * Creates a new Vector3 from the starting index of the given array
  57442. * @param array defines the source array
  57443. * @param offset defines an offset in the source array
  57444. * @returns a new Color3 object
  57445. */
  57446. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  57447. /**
  57448. * Creates a new Color3 from integer values (< 256)
  57449. * @param r defines the red component to read from (value between 0 and 255)
  57450. * @param g defines the green component to read from (value between 0 and 255)
  57451. * @param b defines the blue component to read from (value between 0 and 255)
  57452. * @returns a new Color3 object
  57453. */
  57454. static FromInts(r: number, g: number, b: number): Color3;
  57455. /**
  57456. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  57457. * @param start defines the start Color3 value
  57458. * @param end defines the end Color3 value
  57459. * @param amount defines the gradient value between start and end
  57460. * @returns a new Color3 object
  57461. */
  57462. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  57463. /**
  57464. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  57465. * @param left defines the start value
  57466. * @param right defines the end value
  57467. * @param amount defines the gradient factor
  57468. * @param result defines the Color3 object where to store the result
  57469. */
  57470. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  57471. /**
  57472. * Returns a Color3 value containing a red color
  57473. * @returns a new Color3 object
  57474. */
  57475. static Red(): Color3;
  57476. /**
  57477. * Returns a Color3 value containing a green color
  57478. * @returns a new Color3 object
  57479. */
  57480. static Green(): Color3;
  57481. /**
  57482. * Returns a Color3 value containing a blue color
  57483. * @returns a new Color3 object
  57484. */
  57485. static Blue(): Color3;
  57486. /**
  57487. * Returns a Color3 value containing a black color
  57488. * @returns a new Color3 object
  57489. */
  57490. static Black(): Color3;
  57491. /**
  57492. * Gets a Color3 value containing a black color that must not be updated
  57493. */
  57494. static readonly BlackReadOnly: DeepImmutable<Color3>;
  57495. /**
  57496. * Returns a Color3 value containing a white color
  57497. * @returns a new Color3 object
  57498. */
  57499. static White(): Color3;
  57500. /**
  57501. * Returns a Color3 value containing a purple color
  57502. * @returns a new Color3 object
  57503. */
  57504. static Purple(): Color3;
  57505. /**
  57506. * Returns a Color3 value containing a magenta color
  57507. * @returns a new Color3 object
  57508. */
  57509. static Magenta(): Color3;
  57510. /**
  57511. * Returns a Color3 value containing a yellow color
  57512. * @returns a new Color3 object
  57513. */
  57514. static Yellow(): Color3;
  57515. /**
  57516. * Returns a Color3 value containing a gray color
  57517. * @returns a new Color3 object
  57518. */
  57519. static Gray(): Color3;
  57520. /**
  57521. * Returns a Color3 value containing a teal color
  57522. * @returns a new Color3 object
  57523. */
  57524. static Teal(): Color3;
  57525. /**
  57526. * Returns a Color3 value containing a random color
  57527. * @returns a new Color3 object
  57528. */
  57529. static Random(): Color3;
  57530. }
  57531. /**
  57532. * Class used to hold a RBGA color
  57533. */
  57534. export class Color4 {
  57535. /**
  57536. * Defines the red component (between 0 and 1, default is 0)
  57537. */
  57538. r: number;
  57539. /**
  57540. * Defines the green component (between 0 and 1, default is 0)
  57541. */
  57542. g: number;
  57543. /**
  57544. * Defines the blue component (between 0 and 1, default is 0)
  57545. */
  57546. b: number;
  57547. /**
  57548. * Defines the alpha component (between 0 and 1, default is 1)
  57549. */
  57550. a: number;
  57551. /**
  57552. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  57553. * @param r defines the red component (between 0 and 1, default is 0)
  57554. * @param g defines the green component (between 0 and 1, default is 0)
  57555. * @param b defines the blue component (between 0 and 1, default is 0)
  57556. * @param a defines the alpha component (between 0 and 1, default is 1)
  57557. */
  57558. constructor(
  57559. /**
  57560. * Defines the red component (between 0 and 1, default is 0)
  57561. */
  57562. r?: number,
  57563. /**
  57564. * Defines the green component (between 0 and 1, default is 0)
  57565. */
  57566. g?: number,
  57567. /**
  57568. * Defines the blue component (between 0 and 1, default is 0)
  57569. */
  57570. b?: number,
  57571. /**
  57572. * Defines the alpha component (between 0 and 1, default is 1)
  57573. */
  57574. a?: number);
  57575. /**
  57576. * Adds in place the given Color4 values to the current Color4 object
  57577. * @param right defines the second operand
  57578. * @returns the current updated Color4 object
  57579. */
  57580. addInPlace(right: DeepImmutable<Color4>): Color4;
  57581. /**
  57582. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  57583. * @returns the new array
  57584. */
  57585. asArray(): number[];
  57586. /**
  57587. * Stores from the starting index in the given array the Color4 successive values
  57588. * @param array defines the array where to store the r,g,b components
  57589. * @param index defines an optional index in the target array to define where to start storing values
  57590. * @returns the current Color4 object
  57591. */
  57592. toArray(array: number[], index?: number): Color4;
  57593. /**
  57594. * Determines equality between Color4 objects
  57595. * @param otherColor defines the second operand
  57596. * @returns true if the rgba values are equal to the given ones
  57597. */
  57598. equals(otherColor: DeepImmutable<Color4>): boolean;
  57599. /**
  57600. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  57601. * @param right defines the second operand
  57602. * @returns a new Color4 object
  57603. */
  57604. add(right: DeepImmutable<Color4>): Color4;
  57605. /**
  57606. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  57607. * @param right defines the second operand
  57608. * @returns a new Color4 object
  57609. */
  57610. subtract(right: DeepImmutable<Color4>): Color4;
  57611. /**
  57612. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  57613. * @param right defines the second operand
  57614. * @param result defines the Color4 object where to store the result
  57615. * @returns the current Color4 object
  57616. */
  57617. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  57618. /**
  57619. * Creates a new Color4 with the current Color4 values multiplied by scale
  57620. * @param scale defines the scaling factor to apply
  57621. * @returns a new Color4 object
  57622. */
  57623. scale(scale: number): Color4;
  57624. /**
  57625. * Multiplies the current Color4 values by scale and stores the result in "result"
  57626. * @param scale defines the scaling factor to apply
  57627. * @param result defines the Color4 object where to store the result
  57628. * @returns the current unmodified Color4
  57629. */
  57630. scaleToRef(scale: number, result: Color4): Color4;
  57631. /**
  57632. * Scale the current Color4 values by a factor and add the result to a given Color4
  57633. * @param scale defines the scale factor
  57634. * @param result defines the Color4 object where to store the result
  57635. * @returns the unmodified current Color4
  57636. */
  57637. scaleAndAddToRef(scale: number, result: Color4): Color4;
  57638. /**
  57639. * Clamps the rgb values by the min and max values and stores the result into "result"
  57640. * @param min defines minimum clamping value (default is 0)
  57641. * @param max defines maximum clamping value (default is 1)
  57642. * @param result defines color to store the result into.
  57643. * @returns the cuurent Color4
  57644. */
  57645. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  57646. /**
  57647. * Multipy an Color4 value by another and return a new Color4 object
  57648. * @param color defines the Color4 value to multiply by
  57649. * @returns a new Color4 object
  57650. */
  57651. multiply(color: Color4): Color4;
  57652. /**
  57653. * Multipy a Color4 value by another and push the result in a reference value
  57654. * @param color defines the Color4 value to multiply by
  57655. * @param result defines the Color4 to fill the result in
  57656. * @returns the result Color4
  57657. */
  57658. multiplyToRef(color: Color4, result: Color4): Color4;
  57659. /**
  57660. * Creates a string with the Color4 current values
  57661. * @returns the string representation of the Color4 object
  57662. */
  57663. toString(): string;
  57664. /**
  57665. * Returns the string "Color4"
  57666. * @returns "Color4"
  57667. */
  57668. getClassName(): string;
  57669. /**
  57670. * Compute the Color4 hash code
  57671. * @returns an unique number that can be used to hash Color4 objects
  57672. */
  57673. getHashCode(): number;
  57674. /**
  57675. * Creates a new Color4 copied from the current one
  57676. * @returns a new Color4 object
  57677. */
  57678. clone(): Color4;
  57679. /**
  57680. * Copies the given Color4 values into the current one
  57681. * @param source defines the source Color4 object
  57682. * @returns the current updated Color4 object
  57683. */
  57684. copyFrom(source: Color4): Color4;
  57685. /**
  57686. * Copies the given float values into the current one
  57687. * @param r defines the red component to read from
  57688. * @param g defines the green component to read from
  57689. * @param b defines the blue component to read from
  57690. * @param a defines the alpha component to read from
  57691. * @returns the current updated Color4 object
  57692. */
  57693. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  57694. /**
  57695. * Copies the given float values into the current one
  57696. * @param r defines the red component to read from
  57697. * @param g defines the green component to read from
  57698. * @param b defines the blue component to read from
  57699. * @param a defines the alpha component to read from
  57700. * @returns the current updated Color4 object
  57701. */
  57702. set(r: number, g: number, b: number, a: number): Color4;
  57703. /**
  57704. * Compute the Color4 hexadecimal code as a string
  57705. * @returns a string containing the hexadecimal representation of the Color4 object
  57706. */
  57707. toHexString(): string;
  57708. /**
  57709. * Computes a new Color4 converted from the current one to linear space
  57710. * @returns a new Color4 object
  57711. */
  57712. toLinearSpace(): Color4;
  57713. /**
  57714. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  57715. * @param convertedColor defines the Color4 object where to store the linear space version
  57716. * @returns the unmodified Color4
  57717. */
  57718. toLinearSpaceToRef(convertedColor: Color4): Color4;
  57719. /**
  57720. * Computes a new Color4 converted from the current one to gamma space
  57721. * @returns a new Color4 object
  57722. */
  57723. toGammaSpace(): Color4;
  57724. /**
  57725. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  57726. * @param convertedColor defines the Color4 object where to store the gamma space version
  57727. * @returns the unmodified Color4
  57728. */
  57729. toGammaSpaceToRef(convertedColor: Color4): Color4;
  57730. /**
  57731. * Creates a new Color4 from the string containing valid hexadecimal values
  57732. * @param hex defines a string containing valid hexadecimal values
  57733. * @returns a new Color4 object
  57734. */
  57735. static FromHexString(hex: string): Color4;
  57736. /**
  57737. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  57738. * @param left defines the start value
  57739. * @param right defines the end value
  57740. * @param amount defines the gradient factor
  57741. * @returns a new Color4 object
  57742. */
  57743. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  57744. /**
  57745. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  57746. * @param left defines the start value
  57747. * @param right defines the end value
  57748. * @param amount defines the gradient factor
  57749. * @param result defines the Color4 object where to store data
  57750. */
  57751. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  57752. /**
  57753. * Creates a new Color4 from a Color3 and an alpha value
  57754. * @param color3 defines the source Color3 to read from
  57755. * @param alpha defines the alpha component (1.0 by default)
  57756. * @returns a new Color4 object
  57757. */
  57758. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  57759. /**
  57760. * Creates a new Color4 from the starting index element of the given array
  57761. * @param array defines the source array to read from
  57762. * @param offset defines the offset in the source array
  57763. * @returns a new Color4 object
  57764. */
  57765. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  57766. /**
  57767. * Creates a new Color3 from integer values (< 256)
  57768. * @param r defines the red component to read from (value between 0 and 255)
  57769. * @param g defines the green component to read from (value between 0 and 255)
  57770. * @param b defines the blue component to read from (value between 0 and 255)
  57771. * @param a defines the alpha component to read from (value between 0 and 255)
  57772. * @returns a new Color3 object
  57773. */
  57774. static FromInts(r: number, g: number, b: number, a: number): Color4;
  57775. /**
  57776. * Check the content of a given array and convert it to an array containing RGBA data
  57777. * If the original array was already containing count * 4 values then it is returned directly
  57778. * @param colors defines the array to check
  57779. * @param count defines the number of RGBA data to expect
  57780. * @returns an array containing count * 4 values (RGBA)
  57781. */
  57782. static CheckColors4(colors: number[], count: number): number[];
  57783. }
  57784. /**
  57785. * Class representing a vector containing 2 coordinates
  57786. */
  57787. export class Vector2 {
  57788. /** defines the first coordinate */
  57789. x: number;
  57790. /** defines the second coordinate */
  57791. y: number;
  57792. /**
  57793. * Creates a new Vector2 from the given x and y coordinates
  57794. * @param x defines the first coordinate
  57795. * @param y defines the second coordinate
  57796. */
  57797. constructor(
  57798. /** defines the first coordinate */
  57799. x?: number,
  57800. /** defines the second coordinate */
  57801. y?: number);
  57802. /**
  57803. * Gets a string with the Vector2 coordinates
  57804. * @returns a string with the Vector2 coordinates
  57805. */
  57806. toString(): string;
  57807. /**
  57808. * Gets class name
  57809. * @returns the string "Vector2"
  57810. */
  57811. getClassName(): string;
  57812. /**
  57813. * Gets current vector hash code
  57814. * @returns the Vector2 hash code as a number
  57815. */
  57816. getHashCode(): number;
  57817. /**
  57818. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  57819. * @param array defines the source array
  57820. * @param index defines the offset in source array
  57821. * @returns the current Vector2
  57822. */
  57823. toArray(array: FloatArray, index?: number): Vector2;
  57824. /**
  57825. * Copy the current vector to an array
  57826. * @returns a new array with 2 elements: the Vector2 coordinates.
  57827. */
  57828. asArray(): number[];
  57829. /**
  57830. * Sets the Vector2 coordinates with the given Vector2 coordinates
  57831. * @param source defines the source Vector2
  57832. * @returns the current updated Vector2
  57833. */
  57834. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  57835. /**
  57836. * Sets the Vector2 coordinates with the given floats
  57837. * @param x defines the first coordinate
  57838. * @param y defines the second coordinate
  57839. * @returns the current updated Vector2
  57840. */
  57841. copyFromFloats(x: number, y: number): Vector2;
  57842. /**
  57843. * Sets the Vector2 coordinates with the given floats
  57844. * @param x defines the first coordinate
  57845. * @param y defines the second coordinate
  57846. * @returns the current updated Vector2
  57847. */
  57848. set(x: number, y: number): Vector2;
  57849. /**
  57850. * Add another vector with the current one
  57851. * @param otherVector defines the other vector
  57852. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  57853. */
  57854. add(otherVector: DeepImmutable<Vector2>): Vector2;
  57855. /**
  57856. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  57857. * @param otherVector defines the other vector
  57858. * @param result defines the target vector
  57859. * @returns the unmodified current Vector2
  57860. */
  57861. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  57862. /**
  57863. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  57864. * @param otherVector defines the other vector
  57865. * @returns the current updated Vector2
  57866. */
  57867. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  57868. /**
  57869. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  57870. * @param otherVector defines the other vector
  57871. * @returns a new Vector2
  57872. */
  57873. addVector3(otherVector: Vector3): Vector2;
  57874. /**
  57875. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  57876. * @param otherVector defines the other vector
  57877. * @returns a new Vector2
  57878. */
  57879. subtract(otherVector: Vector2): Vector2;
  57880. /**
  57881. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  57882. * @param otherVector defines the other vector
  57883. * @param result defines the target vector
  57884. * @returns the unmodified current Vector2
  57885. */
  57886. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  57887. /**
  57888. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  57889. * @param otherVector defines the other vector
  57890. * @returns the current updated Vector2
  57891. */
  57892. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  57893. /**
  57894. * Multiplies in place the current Vector2 coordinates by the given ones
  57895. * @param otherVector defines the other vector
  57896. * @returns the current updated Vector2
  57897. */
  57898. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  57899. /**
  57900. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  57901. * @param otherVector defines the other vector
  57902. * @returns a new Vector2
  57903. */
  57904. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  57905. /**
  57906. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  57907. * @param otherVector defines the other vector
  57908. * @param result defines the target vector
  57909. * @returns the unmodified current Vector2
  57910. */
  57911. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  57912. /**
  57913. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  57914. * @param x defines the first coordinate
  57915. * @param y defines the second coordinate
  57916. * @returns a new Vector2
  57917. */
  57918. multiplyByFloats(x: number, y: number): Vector2;
  57919. /**
  57920. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  57921. * @param otherVector defines the other vector
  57922. * @returns a new Vector2
  57923. */
  57924. divide(otherVector: Vector2): Vector2;
  57925. /**
  57926. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  57927. * @param otherVector defines the other vector
  57928. * @param result defines the target vector
  57929. * @returns the unmodified current Vector2
  57930. */
  57931. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  57932. /**
  57933. * Divides the current Vector2 coordinates by the given ones
  57934. * @param otherVector defines the other vector
  57935. * @returns the current updated Vector2
  57936. */
  57937. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  57938. /**
  57939. * Gets a new Vector2 with current Vector2 negated coordinates
  57940. * @returns a new Vector2
  57941. */
  57942. negate(): Vector2;
  57943. /**
  57944. * Multiply the Vector2 coordinates by scale
  57945. * @param scale defines the scaling factor
  57946. * @returns the current updated Vector2
  57947. */
  57948. scaleInPlace(scale: number): Vector2;
  57949. /**
  57950. * Returns a new Vector2 scaled by "scale" from the current Vector2
  57951. * @param scale defines the scaling factor
  57952. * @returns a new Vector2
  57953. */
  57954. scale(scale: number): Vector2;
  57955. /**
  57956. * Scale the current Vector2 values by a factor to a given Vector2
  57957. * @param scale defines the scale factor
  57958. * @param result defines the Vector2 object where to store the result
  57959. * @returns the unmodified current Vector2
  57960. */
  57961. scaleToRef(scale: number, result: Vector2): Vector2;
  57962. /**
  57963. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  57964. * @param scale defines the scale factor
  57965. * @param result defines the Vector2 object where to store the result
  57966. * @returns the unmodified current Vector2
  57967. */
  57968. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  57969. /**
  57970. * Gets a boolean if two vectors are equals
  57971. * @param otherVector defines the other vector
  57972. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  57973. */
  57974. equals(otherVector: DeepImmutable<Vector2>): boolean;
  57975. /**
  57976. * Gets a boolean if two vectors are equals (using an epsilon value)
  57977. * @param otherVector defines the other vector
  57978. * @param epsilon defines the minimal distance to consider equality
  57979. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  57980. */
  57981. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  57982. /**
  57983. * Gets a new Vector2 from current Vector2 floored values
  57984. * @returns a new Vector2
  57985. */
  57986. floor(): Vector2;
  57987. /**
  57988. * Gets a new Vector2 from current Vector2 floored values
  57989. * @returns a new Vector2
  57990. */
  57991. fract(): Vector2;
  57992. /**
  57993. * Gets the length of the vector
  57994. * @returns the vector length (float)
  57995. */
  57996. length(): number;
  57997. /**
  57998. * Gets the vector squared length
  57999. * @returns the vector squared length (float)
  58000. */
  58001. lengthSquared(): number;
  58002. /**
  58003. * Normalize the vector
  58004. * @returns the current updated Vector2
  58005. */
  58006. normalize(): Vector2;
  58007. /**
  58008. * Gets a new Vector2 copied from the Vector2
  58009. * @returns a new Vector2
  58010. */
  58011. clone(): Vector2;
  58012. /**
  58013. * Gets a new Vector2(0, 0)
  58014. * @returns a new Vector2
  58015. */
  58016. static Zero(): Vector2;
  58017. /**
  58018. * Gets a new Vector2(1, 1)
  58019. * @returns a new Vector2
  58020. */
  58021. static One(): Vector2;
  58022. /**
  58023. * Gets a new Vector2 set from the given index element of the given array
  58024. * @param array defines the data source
  58025. * @param offset defines the offset in the data source
  58026. * @returns a new Vector2
  58027. */
  58028. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  58029. /**
  58030. * Sets "result" from the given index element of the given array
  58031. * @param array defines the data source
  58032. * @param offset defines the offset in the data source
  58033. * @param result defines the target vector
  58034. */
  58035. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  58036. /**
  58037. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  58038. * @param value1 defines 1st point of control
  58039. * @param value2 defines 2nd point of control
  58040. * @param value3 defines 3rd point of control
  58041. * @param value4 defines 4th point of control
  58042. * @param amount defines the interpolation factor
  58043. * @returns a new Vector2
  58044. */
  58045. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  58046. /**
  58047. * 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".
  58048. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  58049. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  58050. * @param value defines the value to clamp
  58051. * @param min defines the lower limit
  58052. * @param max defines the upper limit
  58053. * @returns a new Vector2
  58054. */
  58055. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  58056. /**
  58057. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  58058. * @param value1 defines the 1st control point
  58059. * @param tangent1 defines the outgoing tangent
  58060. * @param value2 defines the 2nd control point
  58061. * @param tangent2 defines the incoming tangent
  58062. * @param amount defines the interpolation factor
  58063. * @returns a new Vector2
  58064. */
  58065. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  58066. /**
  58067. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  58068. * @param start defines the start vector
  58069. * @param end defines the end vector
  58070. * @param amount defines the interpolation factor
  58071. * @returns a new Vector2
  58072. */
  58073. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  58074. /**
  58075. * Gets the dot product of the vector "left" and the vector "right"
  58076. * @param left defines first vector
  58077. * @param right defines second vector
  58078. * @returns the dot product (float)
  58079. */
  58080. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  58081. /**
  58082. * Returns a new Vector2 equal to the normalized given vector
  58083. * @param vector defines the vector to normalize
  58084. * @returns a new Vector2
  58085. */
  58086. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  58087. /**
  58088. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  58089. * @param left defines 1st vector
  58090. * @param right defines 2nd vector
  58091. * @returns a new Vector2
  58092. */
  58093. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  58094. /**
  58095. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  58096. * @param left defines 1st vector
  58097. * @param right defines 2nd vector
  58098. * @returns a new Vector2
  58099. */
  58100. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  58101. /**
  58102. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  58103. * @param vector defines the vector to transform
  58104. * @param transformation defines the matrix to apply
  58105. * @returns a new Vector2
  58106. */
  58107. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  58108. /**
  58109. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  58110. * @param vector defines the vector to transform
  58111. * @param transformation defines the matrix to apply
  58112. * @param result defines the target vector
  58113. */
  58114. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  58115. /**
  58116. * Determines if a given vector is included in a triangle
  58117. * @param p defines the vector to test
  58118. * @param p0 defines 1st triangle point
  58119. * @param p1 defines 2nd triangle point
  58120. * @param p2 defines 3rd triangle point
  58121. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  58122. */
  58123. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  58124. /**
  58125. * Gets the distance between the vectors "value1" and "value2"
  58126. * @param value1 defines first vector
  58127. * @param value2 defines second vector
  58128. * @returns the distance between vectors
  58129. */
  58130. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  58131. /**
  58132. * Returns the squared distance between the vectors "value1" and "value2"
  58133. * @param value1 defines first vector
  58134. * @param value2 defines second vector
  58135. * @returns the squared distance between vectors
  58136. */
  58137. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  58138. /**
  58139. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  58140. * @param value1 defines first vector
  58141. * @param value2 defines second vector
  58142. * @returns a new Vector2
  58143. */
  58144. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  58145. /**
  58146. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  58147. * @param p defines the middle point
  58148. * @param segA defines one point of the segment
  58149. * @param segB defines the other point of the segment
  58150. * @returns the shortest distance
  58151. */
  58152. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  58153. }
  58154. /**
  58155. * Classed used to store (x,y,z) vector representation
  58156. * A Vector3 is the main object used in 3D geometry
  58157. * It can represent etiher the coordinates of a point the space, either a direction
  58158. * Reminder: js uses a left handed forward facing system
  58159. */
  58160. export class Vector3 {
  58161. /**
  58162. * Defines the first coordinates (on X axis)
  58163. */
  58164. x: number;
  58165. /**
  58166. * Defines the second coordinates (on Y axis)
  58167. */
  58168. y: number;
  58169. /**
  58170. * Defines the third coordinates (on Z axis)
  58171. */
  58172. z: number;
  58173. private static _UpReadOnly;
  58174. /**
  58175. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  58176. * @param x defines the first coordinates (on X axis)
  58177. * @param y defines the second coordinates (on Y axis)
  58178. * @param z defines the third coordinates (on Z axis)
  58179. */
  58180. constructor(
  58181. /**
  58182. * Defines the first coordinates (on X axis)
  58183. */
  58184. x?: number,
  58185. /**
  58186. * Defines the second coordinates (on Y axis)
  58187. */
  58188. y?: number,
  58189. /**
  58190. * Defines the third coordinates (on Z axis)
  58191. */
  58192. z?: number);
  58193. /**
  58194. * Creates a string representation of the Vector3
  58195. * @returns a string with the Vector3 coordinates.
  58196. */
  58197. toString(): string;
  58198. /**
  58199. * Gets the class name
  58200. * @returns the string "Vector3"
  58201. */
  58202. getClassName(): string;
  58203. /**
  58204. * Creates the Vector3 hash code
  58205. * @returns a number which tends to be unique between Vector3 instances
  58206. */
  58207. getHashCode(): number;
  58208. /**
  58209. * Creates an array containing three elements : the coordinates of the Vector3
  58210. * @returns a new array of numbers
  58211. */
  58212. asArray(): number[];
  58213. /**
  58214. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  58215. * @param array defines the destination array
  58216. * @param index defines the offset in the destination array
  58217. * @returns the current Vector3
  58218. */
  58219. toArray(array: FloatArray, index?: number): Vector3;
  58220. /**
  58221. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  58222. * @returns a new Quaternion object, computed from the Vector3 coordinates
  58223. */
  58224. toQuaternion(): Quaternion;
  58225. /**
  58226. * Adds the given vector to the current Vector3
  58227. * @param otherVector defines the second operand
  58228. * @returns the current updated Vector3
  58229. */
  58230. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  58231. /**
  58232. * Adds the given coordinates to the current Vector3
  58233. * @param x defines the x coordinate of the operand
  58234. * @param y defines the y coordinate of the operand
  58235. * @param z defines the z coordinate of the operand
  58236. * @returns the current updated Vector3
  58237. */
  58238. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  58239. /**
  58240. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  58241. * @param otherVector defines the second operand
  58242. * @returns the resulting Vector3
  58243. */
  58244. add(otherVector: DeepImmutable<Vector3>): Vector3;
  58245. /**
  58246. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  58247. * @param otherVector defines the second operand
  58248. * @param result defines the Vector3 object where to store the result
  58249. * @returns the current Vector3
  58250. */
  58251. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  58252. /**
  58253. * Subtract the given vector from the current Vector3
  58254. * @param otherVector defines the second operand
  58255. * @returns the current updated Vector3
  58256. */
  58257. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  58258. /**
  58259. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  58260. * @param otherVector defines the second operand
  58261. * @returns the resulting Vector3
  58262. */
  58263. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  58264. /**
  58265. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  58266. * @param otherVector defines the second operand
  58267. * @param result defines the Vector3 object where to store the result
  58268. * @returns the current Vector3
  58269. */
  58270. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  58271. /**
  58272. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  58273. * @param x defines the x coordinate of the operand
  58274. * @param y defines the y coordinate of the operand
  58275. * @param z defines the z coordinate of the operand
  58276. * @returns the resulting Vector3
  58277. */
  58278. subtractFromFloats(x: number, y: number, z: number): Vector3;
  58279. /**
  58280. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  58281. * @param x defines the x coordinate of the operand
  58282. * @param y defines the y coordinate of the operand
  58283. * @param z defines the z coordinate of the operand
  58284. * @param result defines the Vector3 object where to store the result
  58285. * @returns the current Vector3
  58286. */
  58287. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  58288. /**
  58289. * Gets a new Vector3 set with the current Vector3 negated coordinates
  58290. * @returns a new Vector3
  58291. */
  58292. negate(): Vector3;
  58293. /**
  58294. * Multiplies the Vector3 coordinates by the float "scale"
  58295. * @param scale defines the multiplier factor
  58296. * @returns the current updated Vector3
  58297. */
  58298. scaleInPlace(scale: number): Vector3;
  58299. /**
  58300. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  58301. * @param scale defines the multiplier factor
  58302. * @returns a new Vector3
  58303. */
  58304. scale(scale: number): Vector3;
  58305. /**
  58306. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  58307. * @param scale defines the multiplier factor
  58308. * @param result defines the Vector3 object where to store the result
  58309. * @returns the current Vector3
  58310. */
  58311. scaleToRef(scale: number, result: Vector3): Vector3;
  58312. /**
  58313. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  58314. * @param scale defines the scale factor
  58315. * @param result defines the Vector3 object where to store the result
  58316. * @returns the unmodified current Vector3
  58317. */
  58318. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  58319. /**
  58320. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  58321. * @param otherVector defines the second operand
  58322. * @returns true if both vectors are equals
  58323. */
  58324. equals(otherVector: DeepImmutable<Vector3>): boolean;
  58325. /**
  58326. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  58327. * @param otherVector defines the second operand
  58328. * @param epsilon defines the minimal distance to define values as equals
  58329. * @returns true if both vectors are distant less than epsilon
  58330. */
  58331. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  58332. /**
  58333. * Returns true if the current Vector3 coordinates equals the given floats
  58334. * @param x defines the x coordinate of the operand
  58335. * @param y defines the y coordinate of the operand
  58336. * @param z defines the z coordinate of the operand
  58337. * @returns true if both vectors are equals
  58338. */
  58339. equalsToFloats(x: number, y: number, z: number): boolean;
  58340. /**
  58341. * Multiplies the current Vector3 coordinates by the given ones
  58342. * @param otherVector defines the second operand
  58343. * @returns the current updated Vector3
  58344. */
  58345. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  58346. /**
  58347. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  58348. * @param otherVector defines the second operand
  58349. * @returns the new Vector3
  58350. */
  58351. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  58352. /**
  58353. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  58354. * @param otherVector defines the second operand
  58355. * @param result defines the Vector3 object where to store the result
  58356. * @returns the current Vector3
  58357. */
  58358. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  58359. /**
  58360. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  58361. * @param x defines the x coordinate of the operand
  58362. * @param y defines the y coordinate of the operand
  58363. * @param z defines the z coordinate of the operand
  58364. * @returns the new Vector3
  58365. */
  58366. multiplyByFloats(x: number, y: number, z: number): Vector3;
  58367. /**
  58368. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  58369. * @param otherVector defines the second operand
  58370. * @returns the new Vector3
  58371. */
  58372. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  58373. /**
  58374. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  58375. * @param otherVector defines the second operand
  58376. * @param result defines the Vector3 object where to store the result
  58377. * @returns the current Vector3
  58378. */
  58379. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  58380. /**
  58381. * Divides the current Vector3 coordinates by the given ones.
  58382. * @param otherVector defines the second operand
  58383. * @returns the current updated Vector3
  58384. */
  58385. divideInPlace(otherVector: Vector3): Vector3;
  58386. /**
  58387. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  58388. * @param other defines the second operand
  58389. * @returns the current updated Vector3
  58390. */
  58391. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  58392. /**
  58393. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  58394. * @param other defines the second operand
  58395. * @returns the current updated Vector3
  58396. */
  58397. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  58398. /**
  58399. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  58400. * @param x defines the x coordinate of the operand
  58401. * @param y defines the y coordinate of the operand
  58402. * @param z defines the z coordinate of the operand
  58403. * @returns the current updated Vector3
  58404. */
  58405. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  58406. /**
  58407. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  58408. * @param x defines the x coordinate of the operand
  58409. * @param y defines the y coordinate of the operand
  58410. * @param z defines the z coordinate of the operand
  58411. * @returns the current updated Vector3
  58412. */
  58413. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  58414. /**
  58415. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  58416. * Check if is non uniform within a certain amount of decimal places to account for this
  58417. * @param epsilon the amount the values can differ
  58418. * @returns if the the vector is non uniform to a certain number of decimal places
  58419. */
  58420. isNonUniformWithinEpsilon(epsilon: number): boolean;
  58421. /**
  58422. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  58423. */
  58424. readonly isNonUniform: boolean;
  58425. /**
  58426. * Gets a new Vector3 from current Vector3 floored values
  58427. * @returns a new Vector3
  58428. */
  58429. floor(): Vector3;
  58430. /**
  58431. * Gets a new Vector3 from current Vector3 floored values
  58432. * @returns a new Vector3
  58433. */
  58434. fract(): Vector3;
  58435. /**
  58436. * Gets the length of the Vector3
  58437. * @returns the length of the Vecto3
  58438. */
  58439. length(): number;
  58440. /**
  58441. * Gets the squared length of the Vector3
  58442. * @returns squared length of the Vector3
  58443. */
  58444. lengthSquared(): number;
  58445. /**
  58446. * Normalize the current Vector3.
  58447. * Please note that this is an in place operation.
  58448. * @returns the current updated Vector3
  58449. */
  58450. normalize(): Vector3;
  58451. /**
  58452. * Reorders the x y z properties of the vector in place
  58453. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  58454. * @returns the current updated vector
  58455. */
  58456. reorderInPlace(order: string): this;
  58457. /**
  58458. * Rotates the vector around 0,0,0 by a quaternion
  58459. * @param quaternion the rotation quaternion
  58460. * @param result vector to store the result
  58461. * @returns the resulting vector
  58462. */
  58463. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  58464. /**
  58465. * Rotates a vector around a given point
  58466. * @param quaternion the rotation quaternion
  58467. * @param point the point to rotate around
  58468. * @param result vector to store the result
  58469. * @returns the resulting vector
  58470. */
  58471. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  58472. /**
  58473. * Normalize the current Vector3 with the given input length.
  58474. * Please note that this is an in place operation.
  58475. * @param len the length of the vector
  58476. * @returns the current updated Vector3
  58477. */
  58478. normalizeFromLength(len: number): Vector3;
  58479. /**
  58480. * Normalize the current Vector3 to a new vector
  58481. * @returns the new Vector3
  58482. */
  58483. normalizeToNew(): Vector3;
  58484. /**
  58485. * Normalize the current Vector3 to the reference
  58486. * @param reference define the Vector3 to update
  58487. * @returns the updated Vector3
  58488. */
  58489. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  58490. /**
  58491. * Creates a new Vector3 copied from the current Vector3
  58492. * @returns the new Vector3
  58493. */
  58494. clone(): Vector3;
  58495. /**
  58496. * Copies the given vector coordinates to the current Vector3 ones
  58497. * @param source defines the source Vector3
  58498. * @returns the current updated Vector3
  58499. */
  58500. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  58501. /**
  58502. * Copies the given floats to the current Vector3 coordinates
  58503. * @param x defines the x coordinate of the operand
  58504. * @param y defines the y coordinate of the operand
  58505. * @param z defines the z coordinate of the operand
  58506. * @returns the current updated Vector3
  58507. */
  58508. copyFromFloats(x: number, y: number, z: number): Vector3;
  58509. /**
  58510. * Copies the given floats to the current Vector3 coordinates
  58511. * @param x defines the x coordinate of the operand
  58512. * @param y defines the y coordinate of the operand
  58513. * @param z defines the z coordinate of the operand
  58514. * @returns the current updated Vector3
  58515. */
  58516. set(x: number, y: number, z: number): Vector3;
  58517. /**
  58518. * Copies the given float to the current Vector3 coordinates
  58519. * @param v defines the x, y and z coordinates of the operand
  58520. * @returns the current updated Vector3
  58521. */
  58522. setAll(v: number): Vector3;
  58523. /**
  58524. * Get the clip factor between two vectors
  58525. * @param vector0 defines the first operand
  58526. * @param vector1 defines the second operand
  58527. * @param axis defines the axis to use
  58528. * @param size defines the size along the axis
  58529. * @returns the clip factor
  58530. */
  58531. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  58532. /**
  58533. * Get angle between two vectors
  58534. * @param vector0 angle between vector0 and vector1
  58535. * @param vector1 angle between vector0 and vector1
  58536. * @param normal direction of the normal
  58537. * @return the angle between vector0 and vector1
  58538. */
  58539. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  58540. /**
  58541. * Returns a new Vector3 set from the index "offset" of the given array
  58542. * @param array defines the source array
  58543. * @param offset defines the offset in the source array
  58544. * @returns the new Vector3
  58545. */
  58546. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  58547. /**
  58548. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  58549. * This function is deprecated. Use FromArray instead
  58550. * @param array defines the source array
  58551. * @param offset defines the offset in the source array
  58552. * @returns the new Vector3
  58553. */
  58554. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  58555. /**
  58556. * Sets the given vector "result" with the element values from the index "offset" of the given array
  58557. * @param array defines the source array
  58558. * @param offset defines the offset in the source array
  58559. * @param result defines the Vector3 where to store the result
  58560. */
  58561. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  58562. /**
  58563. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  58564. * This function is deprecated. Use FromArrayToRef instead.
  58565. * @param array defines the source array
  58566. * @param offset defines the offset in the source array
  58567. * @param result defines the Vector3 where to store the result
  58568. */
  58569. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  58570. /**
  58571. * Sets the given vector "result" with the given floats.
  58572. * @param x defines the x coordinate of the source
  58573. * @param y defines the y coordinate of the source
  58574. * @param z defines the z coordinate of the source
  58575. * @param result defines the Vector3 where to store the result
  58576. */
  58577. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  58578. /**
  58579. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  58580. * @returns a new empty Vector3
  58581. */
  58582. static Zero(): Vector3;
  58583. /**
  58584. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  58585. * @returns a new unit Vector3
  58586. */
  58587. static One(): Vector3;
  58588. /**
  58589. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  58590. * @returns a new up Vector3
  58591. */
  58592. static Up(): Vector3;
  58593. /**
  58594. * Gets a up Vector3 that must not be updated
  58595. */
  58596. static readonly UpReadOnly: DeepImmutable<Vector3>;
  58597. /**
  58598. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  58599. * @returns a new down Vector3
  58600. */
  58601. static Down(): Vector3;
  58602. /**
  58603. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  58604. * @returns a new forward Vector3
  58605. */
  58606. static Forward(): Vector3;
  58607. /**
  58608. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  58609. * @returns a new forward Vector3
  58610. */
  58611. static Backward(): Vector3;
  58612. /**
  58613. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  58614. * @returns a new right Vector3
  58615. */
  58616. static Right(): Vector3;
  58617. /**
  58618. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  58619. * @returns a new left Vector3
  58620. */
  58621. static Left(): Vector3;
  58622. /**
  58623. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  58624. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  58625. * @param vector defines the Vector3 to transform
  58626. * @param transformation defines the transformation matrix
  58627. * @returns the transformed Vector3
  58628. */
  58629. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  58630. /**
  58631. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  58632. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  58633. * @param vector defines the Vector3 to transform
  58634. * @param transformation defines the transformation matrix
  58635. * @param result defines the Vector3 where to store the result
  58636. */
  58637. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  58638. /**
  58639. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  58640. * This method computes tranformed coordinates only, not transformed direction vectors
  58641. * @param x define the x coordinate of the source vector
  58642. * @param y define the y coordinate of the source vector
  58643. * @param z define the z coordinate of the source vector
  58644. * @param transformation defines the transformation matrix
  58645. * @param result defines the Vector3 where to store the result
  58646. */
  58647. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  58648. /**
  58649. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  58650. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  58651. * @param vector defines the Vector3 to transform
  58652. * @param transformation defines the transformation matrix
  58653. * @returns the new Vector3
  58654. */
  58655. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  58656. /**
  58657. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  58658. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  58659. * @param vector defines the Vector3 to transform
  58660. * @param transformation defines the transformation matrix
  58661. * @param result defines the Vector3 where to store the result
  58662. */
  58663. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  58664. /**
  58665. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  58666. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  58667. * @param x define the x coordinate of the source vector
  58668. * @param y define the y coordinate of the source vector
  58669. * @param z define the z coordinate of the source vector
  58670. * @param transformation defines the transformation matrix
  58671. * @param result defines the Vector3 where to store the result
  58672. */
  58673. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  58674. /**
  58675. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  58676. * @param value1 defines the first control point
  58677. * @param value2 defines the second control point
  58678. * @param value3 defines the third control point
  58679. * @param value4 defines the fourth control point
  58680. * @param amount defines the amount on the spline to use
  58681. * @returns the new Vector3
  58682. */
  58683. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  58684. /**
  58685. * 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"
  58686. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  58687. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  58688. * @param value defines the current value
  58689. * @param min defines the lower range value
  58690. * @param max defines the upper range value
  58691. * @returns the new Vector3
  58692. */
  58693. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  58694. /**
  58695. * 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"
  58696. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  58697. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  58698. * @param value defines the current value
  58699. * @param min defines the lower range value
  58700. * @param max defines the upper range value
  58701. * @param result defines the Vector3 where to store the result
  58702. */
  58703. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  58704. /**
  58705. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  58706. * @param value1 defines the first control point
  58707. * @param tangent1 defines the first tangent vector
  58708. * @param value2 defines the second control point
  58709. * @param tangent2 defines the second tangent vector
  58710. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  58711. * @returns the new Vector3
  58712. */
  58713. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  58714. /**
  58715. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  58716. * @param start defines the start value
  58717. * @param end defines the end value
  58718. * @param amount max defines amount between both (between 0 and 1)
  58719. * @returns the new Vector3
  58720. */
  58721. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  58722. /**
  58723. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  58724. * @param start defines the start value
  58725. * @param end defines the end value
  58726. * @param amount max defines amount between both (between 0 and 1)
  58727. * @param result defines the Vector3 where to store the result
  58728. */
  58729. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  58730. /**
  58731. * Returns the dot product (float) between the vectors "left" and "right"
  58732. * @param left defines the left operand
  58733. * @param right defines the right operand
  58734. * @returns the dot product
  58735. */
  58736. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  58737. /**
  58738. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  58739. * The cross product is then orthogonal to both "left" and "right"
  58740. * @param left defines the left operand
  58741. * @param right defines the right operand
  58742. * @returns the cross product
  58743. */
  58744. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  58745. /**
  58746. * Sets the given vector "result" with the cross product of "left" and "right"
  58747. * The cross product is then orthogonal to both "left" and "right"
  58748. * @param left defines the left operand
  58749. * @param right defines the right operand
  58750. * @param result defines the Vector3 where to store the result
  58751. */
  58752. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  58753. /**
  58754. * Returns a new Vector3 as the normalization of the given vector
  58755. * @param vector defines the Vector3 to normalize
  58756. * @returns the new Vector3
  58757. */
  58758. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  58759. /**
  58760. * Sets the given vector "result" with the normalization of the given first vector
  58761. * @param vector defines the Vector3 to normalize
  58762. * @param result defines the Vector3 where to store the result
  58763. */
  58764. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  58765. /**
  58766. * Project a Vector3 onto screen space
  58767. * @param vector defines the Vector3 to project
  58768. * @param world defines the world matrix to use
  58769. * @param transform defines the transform (view x projection) matrix to use
  58770. * @param viewport defines the screen viewport to use
  58771. * @returns the new Vector3
  58772. */
  58773. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  58774. /** @hidden */
  58775. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  58776. /**
  58777. * Unproject from screen space to object space
  58778. * @param source defines the screen space Vector3 to use
  58779. * @param viewportWidth defines the current width of the viewport
  58780. * @param viewportHeight defines the current height of the viewport
  58781. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  58782. * @param transform defines the transform (view x projection) matrix to use
  58783. * @returns the new Vector3
  58784. */
  58785. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  58786. /**
  58787. * Unproject from screen space to object space
  58788. * @param source defines the screen space Vector3 to use
  58789. * @param viewportWidth defines the current width of the viewport
  58790. * @param viewportHeight defines the current height of the viewport
  58791. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  58792. * @param view defines the view matrix to use
  58793. * @param projection defines the projection matrix to use
  58794. * @returns the new Vector3
  58795. */
  58796. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  58797. /**
  58798. * Unproject from screen space to object space
  58799. * @param source defines the screen space Vector3 to use
  58800. * @param viewportWidth defines the current width of the viewport
  58801. * @param viewportHeight defines the current height of the viewport
  58802. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  58803. * @param view defines the view matrix to use
  58804. * @param projection defines the projection matrix to use
  58805. * @param result defines the Vector3 where to store the result
  58806. */
  58807. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  58808. /**
  58809. * Unproject from screen space to object space
  58810. * @param sourceX defines the screen space x coordinate to use
  58811. * @param sourceY defines the screen space y coordinate to use
  58812. * @param sourceZ defines the screen space z coordinate to use
  58813. * @param viewportWidth defines the current width of the viewport
  58814. * @param viewportHeight defines the current height of the viewport
  58815. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  58816. * @param view defines the view matrix to use
  58817. * @param projection defines the projection matrix to use
  58818. * @param result defines the Vector3 where to store the result
  58819. */
  58820. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  58821. /**
  58822. * Gets the minimal coordinate values between two Vector3
  58823. * @param left defines the first operand
  58824. * @param right defines the second operand
  58825. * @returns the new Vector3
  58826. */
  58827. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  58828. /**
  58829. * Gets the maximal coordinate values between two Vector3
  58830. * @param left defines the first operand
  58831. * @param right defines the second operand
  58832. * @returns the new Vector3
  58833. */
  58834. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  58835. /**
  58836. * Returns the distance between the vectors "value1" and "value2"
  58837. * @param value1 defines the first operand
  58838. * @param value2 defines the second operand
  58839. * @returns the distance
  58840. */
  58841. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  58842. /**
  58843. * Returns the squared distance between the vectors "value1" and "value2"
  58844. * @param value1 defines the first operand
  58845. * @param value2 defines the second operand
  58846. * @returns the squared distance
  58847. */
  58848. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  58849. /**
  58850. * Returns a new Vector3 located at the center between "value1" and "value2"
  58851. * @param value1 defines the first operand
  58852. * @param value2 defines the second operand
  58853. * @returns the new Vector3
  58854. */
  58855. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  58856. /**
  58857. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  58858. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  58859. * to something in order to rotate it from its local system to the given target system
  58860. * Note: axis1, axis2 and axis3 are normalized during this operation
  58861. * @param axis1 defines the first axis
  58862. * @param axis2 defines the second axis
  58863. * @param axis3 defines the third axis
  58864. * @returns a new Vector3
  58865. */
  58866. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  58867. /**
  58868. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  58869. * @param axis1 defines the first axis
  58870. * @param axis2 defines the second axis
  58871. * @param axis3 defines the third axis
  58872. * @param ref defines the Vector3 where to store the result
  58873. */
  58874. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  58875. }
  58876. /**
  58877. * Vector4 class created for EulerAngle class conversion to Quaternion
  58878. */
  58879. export class Vector4 {
  58880. /** x value of the vector */
  58881. x: number;
  58882. /** y value of the vector */
  58883. y: number;
  58884. /** z value of the vector */
  58885. z: number;
  58886. /** w value of the vector */
  58887. w: number;
  58888. /**
  58889. * Creates a Vector4 object from the given floats.
  58890. * @param x x value of the vector
  58891. * @param y y value of the vector
  58892. * @param z z value of the vector
  58893. * @param w w value of the vector
  58894. */
  58895. constructor(
  58896. /** x value of the vector */
  58897. x: number,
  58898. /** y value of the vector */
  58899. y: number,
  58900. /** z value of the vector */
  58901. z: number,
  58902. /** w value of the vector */
  58903. w: number);
  58904. /**
  58905. * Returns the string with the Vector4 coordinates.
  58906. * @returns a string containing all the vector values
  58907. */
  58908. toString(): string;
  58909. /**
  58910. * Returns the string "Vector4".
  58911. * @returns "Vector4"
  58912. */
  58913. getClassName(): string;
  58914. /**
  58915. * Returns the Vector4 hash code.
  58916. * @returns a unique hash code
  58917. */
  58918. getHashCode(): number;
  58919. /**
  58920. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  58921. * @returns the resulting array
  58922. */
  58923. asArray(): number[];
  58924. /**
  58925. * Populates the given array from the given index with the Vector4 coordinates.
  58926. * @param array array to populate
  58927. * @param index index of the array to start at (default: 0)
  58928. * @returns the Vector4.
  58929. */
  58930. toArray(array: FloatArray, index?: number): Vector4;
  58931. /**
  58932. * Adds the given vector to the current Vector4.
  58933. * @param otherVector the vector to add
  58934. * @returns the updated Vector4.
  58935. */
  58936. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  58937. /**
  58938. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  58939. * @param otherVector the vector to add
  58940. * @returns the resulting vector
  58941. */
  58942. add(otherVector: DeepImmutable<Vector4>): Vector4;
  58943. /**
  58944. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  58945. * @param otherVector the vector to add
  58946. * @param result the vector to store the result
  58947. * @returns the current Vector4.
  58948. */
  58949. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  58950. /**
  58951. * Subtract in place the given vector from the current Vector4.
  58952. * @param otherVector the vector to subtract
  58953. * @returns the updated Vector4.
  58954. */
  58955. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  58956. /**
  58957. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  58958. * @param otherVector the vector to add
  58959. * @returns the new vector with the result
  58960. */
  58961. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  58962. /**
  58963. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  58964. * @param otherVector the vector to subtract
  58965. * @param result the vector to store the result
  58966. * @returns the current Vector4.
  58967. */
  58968. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  58969. /**
  58970. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  58971. */
  58972. /**
  58973. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  58974. * @param x value to subtract
  58975. * @param y value to subtract
  58976. * @param z value to subtract
  58977. * @param w value to subtract
  58978. * @returns new vector containing the result
  58979. */
  58980. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  58981. /**
  58982. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  58983. * @param x value to subtract
  58984. * @param y value to subtract
  58985. * @param z value to subtract
  58986. * @param w value to subtract
  58987. * @param result the vector to store the result in
  58988. * @returns the current Vector4.
  58989. */
  58990. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  58991. /**
  58992. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  58993. * @returns a new vector with the negated values
  58994. */
  58995. negate(): Vector4;
  58996. /**
  58997. * Multiplies the current Vector4 coordinates by scale (float).
  58998. * @param scale the number to scale with
  58999. * @returns the updated Vector4.
  59000. */
  59001. scaleInPlace(scale: number): Vector4;
  59002. /**
  59003. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  59004. * @param scale the number to scale with
  59005. * @returns a new vector with the result
  59006. */
  59007. scale(scale: number): Vector4;
  59008. /**
  59009. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  59010. * @param scale the number to scale with
  59011. * @param result a vector to store the result in
  59012. * @returns the current Vector4.
  59013. */
  59014. scaleToRef(scale: number, result: Vector4): Vector4;
  59015. /**
  59016. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  59017. * @param scale defines the scale factor
  59018. * @param result defines the Vector4 object where to store the result
  59019. * @returns the unmodified current Vector4
  59020. */
  59021. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  59022. /**
  59023. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  59024. * @param otherVector the vector to compare against
  59025. * @returns true if they are equal
  59026. */
  59027. equals(otherVector: DeepImmutable<Vector4>): boolean;
  59028. /**
  59029. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  59030. * @param otherVector vector to compare against
  59031. * @param epsilon (Default: very small number)
  59032. * @returns true if they are equal
  59033. */
  59034. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  59035. /**
  59036. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  59037. * @param x x value to compare against
  59038. * @param y y value to compare against
  59039. * @param z z value to compare against
  59040. * @param w w value to compare against
  59041. * @returns true if equal
  59042. */
  59043. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  59044. /**
  59045. * Multiplies in place the current Vector4 by the given one.
  59046. * @param otherVector vector to multiple with
  59047. * @returns the updated Vector4.
  59048. */
  59049. multiplyInPlace(otherVector: Vector4): Vector4;
  59050. /**
  59051. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  59052. * @param otherVector vector to multiple with
  59053. * @returns resulting new vector
  59054. */
  59055. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  59056. /**
  59057. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  59058. * @param otherVector vector to multiple with
  59059. * @param result vector to store the result
  59060. * @returns the current Vector4.
  59061. */
  59062. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59063. /**
  59064. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  59065. * @param x x value multiply with
  59066. * @param y y value multiply with
  59067. * @param z z value multiply with
  59068. * @param w w value multiply with
  59069. * @returns resulting new vector
  59070. */
  59071. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  59072. /**
  59073. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  59074. * @param otherVector vector to devide with
  59075. * @returns resulting new vector
  59076. */
  59077. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  59078. /**
  59079. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  59080. * @param otherVector vector to devide with
  59081. * @param result vector to store the result
  59082. * @returns the current Vector4.
  59083. */
  59084. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59085. /**
  59086. * Divides the current Vector3 coordinates by the given ones.
  59087. * @param otherVector vector to devide with
  59088. * @returns the updated Vector3.
  59089. */
  59090. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  59091. /**
  59092. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  59093. * @param other defines the second operand
  59094. * @returns the current updated Vector4
  59095. */
  59096. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  59097. /**
  59098. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  59099. * @param other defines the second operand
  59100. * @returns the current updated Vector4
  59101. */
  59102. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  59103. /**
  59104. * Gets a new Vector4 from current Vector4 floored values
  59105. * @returns a new Vector4
  59106. */
  59107. floor(): Vector4;
  59108. /**
  59109. * Gets a new Vector4 from current Vector3 floored values
  59110. * @returns a new Vector4
  59111. */
  59112. fract(): Vector4;
  59113. /**
  59114. * Returns the Vector4 length (float).
  59115. * @returns the length
  59116. */
  59117. length(): number;
  59118. /**
  59119. * Returns the Vector4 squared length (float).
  59120. * @returns the length squared
  59121. */
  59122. lengthSquared(): number;
  59123. /**
  59124. * Normalizes in place the Vector4.
  59125. * @returns the updated Vector4.
  59126. */
  59127. normalize(): Vector4;
  59128. /**
  59129. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  59130. * @returns this converted to a new vector3
  59131. */
  59132. toVector3(): Vector3;
  59133. /**
  59134. * Returns a new Vector4 copied from the current one.
  59135. * @returns the new cloned vector
  59136. */
  59137. clone(): Vector4;
  59138. /**
  59139. * Updates the current Vector4 with the given one coordinates.
  59140. * @param source the source vector to copy from
  59141. * @returns the updated Vector4.
  59142. */
  59143. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  59144. /**
  59145. * Updates the current Vector4 coordinates with the given floats.
  59146. * @param x float to copy from
  59147. * @param y float to copy from
  59148. * @param z float to copy from
  59149. * @param w float to copy from
  59150. * @returns the updated Vector4.
  59151. */
  59152. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  59153. /**
  59154. * Updates the current Vector4 coordinates with the given floats.
  59155. * @param x float to set from
  59156. * @param y float to set from
  59157. * @param z float to set from
  59158. * @param w float to set from
  59159. * @returns the updated Vector4.
  59160. */
  59161. set(x: number, y: number, z: number, w: number): Vector4;
  59162. /**
  59163. * Copies the given float to the current Vector3 coordinates
  59164. * @param v defines the x, y, z and w coordinates of the operand
  59165. * @returns the current updated Vector3
  59166. */
  59167. setAll(v: number): Vector4;
  59168. /**
  59169. * Returns a new Vector4 set from the starting index of the given array.
  59170. * @param array the array to pull values from
  59171. * @param offset the offset into the array to start at
  59172. * @returns the new vector
  59173. */
  59174. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  59175. /**
  59176. * Updates the given vector "result" from the starting index of the given array.
  59177. * @param array the array to pull values from
  59178. * @param offset the offset into the array to start at
  59179. * @param result the vector to store the result in
  59180. */
  59181. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  59182. /**
  59183. * Updates the given vector "result" from the starting index of the given Float32Array.
  59184. * @param array the array to pull values from
  59185. * @param offset the offset into the array to start at
  59186. * @param result the vector to store the result in
  59187. */
  59188. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  59189. /**
  59190. * Updates the given vector "result" coordinates from the given floats.
  59191. * @param x float to set from
  59192. * @param y float to set from
  59193. * @param z float to set from
  59194. * @param w float to set from
  59195. * @param result the vector to the floats in
  59196. */
  59197. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  59198. /**
  59199. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  59200. * @returns the new vector
  59201. */
  59202. static Zero(): Vector4;
  59203. /**
  59204. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  59205. * @returns the new vector
  59206. */
  59207. static One(): Vector4;
  59208. /**
  59209. * Returns a new normalized Vector4 from the given one.
  59210. * @param vector the vector to normalize
  59211. * @returns the vector
  59212. */
  59213. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  59214. /**
  59215. * Updates the given vector "result" from the normalization of the given one.
  59216. * @param vector the vector to normalize
  59217. * @param result the vector to store the result in
  59218. */
  59219. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  59220. /**
  59221. * Returns a vector with the minimum values from the left and right vectors
  59222. * @param left left vector to minimize
  59223. * @param right right vector to minimize
  59224. * @returns a new vector with the minimum of the left and right vector values
  59225. */
  59226. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  59227. /**
  59228. * Returns a vector with the maximum values from the left and right vectors
  59229. * @param left left vector to maximize
  59230. * @param right right vector to maximize
  59231. * @returns a new vector with the maximum of the left and right vector values
  59232. */
  59233. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  59234. /**
  59235. * Returns the distance (float) between the vectors "value1" and "value2".
  59236. * @param value1 value to calulate the distance between
  59237. * @param value2 value to calulate the distance between
  59238. * @return the distance between the two vectors
  59239. */
  59240. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  59241. /**
  59242. * Returns the squared distance (float) between the vectors "value1" and "value2".
  59243. * @param value1 value to calulate the distance between
  59244. * @param value2 value to calulate the distance between
  59245. * @return the distance between the two vectors squared
  59246. */
  59247. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  59248. /**
  59249. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  59250. * @param value1 value to calulate the center between
  59251. * @param value2 value to calulate the center between
  59252. * @return the center between the two vectors
  59253. */
  59254. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  59255. /**
  59256. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  59257. * This methods computes transformed normalized direction vectors only.
  59258. * @param vector the vector to transform
  59259. * @param transformation the transformation matrix to apply
  59260. * @returns the new vector
  59261. */
  59262. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  59263. /**
  59264. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  59265. * This methods computes transformed normalized direction vectors only.
  59266. * @param vector the vector to transform
  59267. * @param transformation the transformation matrix to apply
  59268. * @param result the vector to store the result in
  59269. */
  59270. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  59271. /**
  59272. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  59273. * This methods computes transformed normalized direction vectors only.
  59274. * @param x value to transform
  59275. * @param y value to transform
  59276. * @param z value to transform
  59277. * @param w value to transform
  59278. * @param transformation the transformation matrix to apply
  59279. * @param result the vector to store the results in
  59280. */
  59281. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  59282. /**
  59283. * Creates a new Vector4 from a Vector3
  59284. * @param source defines the source data
  59285. * @param w defines the 4th component (default is 0)
  59286. * @returns a new Vector4
  59287. */
  59288. static FromVector3(source: Vector3, w?: number): Vector4;
  59289. }
  59290. /**
  59291. * Interface for the size containing width and height
  59292. */
  59293. export interface ISize {
  59294. /**
  59295. * Width
  59296. */
  59297. width: number;
  59298. /**
  59299. * Heighht
  59300. */
  59301. height: number;
  59302. }
  59303. /**
  59304. * Size containing widht and height
  59305. */
  59306. export class Size implements ISize {
  59307. /**
  59308. * Width
  59309. */
  59310. width: number;
  59311. /**
  59312. * Height
  59313. */
  59314. height: number;
  59315. /**
  59316. * Creates a Size object from the given width and height (floats).
  59317. * @param width width of the new size
  59318. * @param height height of the new size
  59319. */
  59320. constructor(width: number, height: number);
  59321. /**
  59322. * Returns a string with the Size width and height
  59323. * @returns a string with the Size width and height
  59324. */
  59325. toString(): string;
  59326. /**
  59327. * "Size"
  59328. * @returns the string "Size"
  59329. */
  59330. getClassName(): string;
  59331. /**
  59332. * Returns the Size hash code.
  59333. * @returns a hash code for a unique width and height
  59334. */
  59335. getHashCode(): number;
  59336. /**
  59337. * Updates the current size from the given one.
  59338. * @param src the given size
  59339. */
  59340. copyFrom(src: Size): void;
  59341. /**
  59342. * Updates in place the current Size from the given floats.
  59343. * @param width width of the new size
  59344. * @param height height of the new size
  59345. * @returns the updated Size.
  59346. */
  59347. copyFromFloats(width: number, height: number): Size;
  59348. /**
  59349. * Updates in place the current Size from the given floats.
  59350. * @param width width to set
  59351. * @param height height to set
  59352. * @returns the updated Size.
  59353. */
  59354. set(width: number, height: number): Size;
  59355. /**
  59356. * Multiplies the width and height by numbers
  59357. * @param w factor to multiple the width by
  59358. * @param h factor to multiple the height by
  59359. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  59360. */
  59361. multiplyByFloats(w: number, h: number): Size;
  59362. /**
  59363. * Clones the size
  59364. * @returns a new Size copied from the given one.
  59365. */
  59366. clone(): Size;
  59367. /**
  59368. * True if the current Size and the given one width and height are strictly equal.
  59369. * @param other the other size to compare against
  59370. * @returns True if the current Size and the given one width and height are strictly equal.
  59371. */
  59372. equals(other: Size): boolean;
  59373. /**
  59374. * The surface of the Size : width * height (float).
  59375. */
  59376. readonly surface: number;
  59377. /**
  59378. * Create a new size of zero
  59379. * @returns a new Size set to (0.0, 0.0)
  59380. */
  59381. static Zero(): Size;
  59382. /**
  59383. * Sums the width and height of two sizes
  59384. * @param otherSize size to add to this size
  59385. * @returns a new Size set as the addition result of the current Size and the given one.
  59386. */
  59387. add(otherSize: Size): Size;
  59388. /**
  59389. * Subtracts the width and height of two
  59390. * @param otherSize size to subtract to this size
  59391. * @returns a new Size set as the subtraction result of the given one from the current Size.
  59392. */
  59393. subtract(otherSize: Size): Size;
  59394. /**
  59395. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  59396. * @param start starting size to lerp between
  59397. * @param end end size to lerp between
  59398. * @param amount amount to lerp between the start and end values
  59399. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  59400. */
  59401. static Lerp(start: Size, end: Size, amount: number): Size;
  59402. }
  59403. /**
  59404. * Class used to store quaternion data
  59405. * @see https://en.wikipedia.org/wiki/Quaternion
  59406. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  59407. */
  59408. export class Quaternion {
  59409. /** defines the first component (0 by default) */
  59410. x: number;
  59411. /** defines the second component (0 by default) */
  59412. y: number;
  59413. /** defines the third component (0 by default) */
  59414. z: number;
  59415. /** defines the fourth component (1.0 by default) */
  59416. w: number;
  59417. /**
  59418. * Creates a new Quaternion from the given floats
  59419. * @param x defines the first component (0 by default)
  59420. * @param y defines the second component (0 by default)
  59421. * @param z defines the third component (0 by default)
  59422. * @param w defines the fourth component (1.0 by default)
  59423. */
  59424. constructor(
  59425. /** defines the first component (0 by default) */
  59426. x?: number,
  59427. /** defines the second component (0 by default) */
  59428. y?: number,
  59429. /** defines the third component (0 by default) */
  59430. z?: number,
  59431. /** defines the fourth component (1.0 by default) */
  59432. w?: number);
  59433. /**
  59434. * Gets a string representation for the current quaternion
  59435. * @returns a string with the Quaternion coordinates
  59436. */
  59437. toString(): string;
  59438. /**
  59439. * Gets the class name of the quaternion
  59440. * @returns the string "Quaternion"
  59441. */
  59442. getClassName(): string;
  59443. /**
  59444. * Gets a hash code for this quaternion
  59445. * @returns the quaternion hash code
  59446. */
  59447. getHashCode(): number;
  59448. /**
  59449. * Copy the quaternion to an array
  59450. * @returns a new array populated with 4 elements from the quaternion coordinates
  59451. */
  59452. asArray(): number[];
  59453. /**
  59454. * Check if two quaternions are equals
  59455. * @param otherQuaternion defines the second operand
  59456. * @return true if the current quaternion and the given one coordinates are strictly equals
  59457. */
  59458. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  59459. /**
  59460. * Clone the current quaternion
  59461. * @returns a new quaternion copied from the current one
  59462. */
  59463. clone(): Quaternion;
  59464. /**
  59465. * Copy a quaternion to the current one
  59466. * @param other defines the other quaternion
  59467. * @returns the updated current quaternion
  59468. */
  59469. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  59470. /**
  59471. * Updates the current quaternion with the given float coordinates
  59472. * @param x defines the x coordinate
  59473. * @param y defines the y coordinate
  59474. * @param z defines the z coordinate
  59475. * @param w defines the w coordinate
  59476. * @returns the updated current quaternion
  59477. */
  59478. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  59479. /**
  59480. * Updates the current quaternion from the given float coordinates
  59481. * @param x defines the x coordinate
  59482. * @param y defines the y coordinate
  59483. * @param z defines the z coordinate
  59484. * @param w defines the w coordinate
  59485. * @returns the updated current quaternion
  59486. */
  59487. set(x: number, y: number, z: number, w: number): Quaternion;
  59488. /**
  59489. * Adds two quaternions
  59490. * @param other defines the second operand
  59491. * @returns a new quaternion as the addition result of the given one and the current quaternion
  59492. */
  59493. add(other: DeepImmutable<Quaternion>): Quaternion;
  59494. /**
  59495. * Add a quaternion to the current one
  59496. * @param other defines the quaternion to add
  59497. * @returns the current quaternion
  59498. */
  59499. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  59500. /**
  59501. * Subtract two quaternions
  59502. * @param other defines the second operand
  59503. * @returns a new quaternion as the subtraction result of the given one from the current one
  59504. */
  59505. subtract(other: Quaternion): Quaternion;
  59506. /**
  59507. * Multiplies the current quaternion by a scale factor
  59508. * @param value defines the scale factor
  59509. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  59510. */
  59511. scale(value: number): Quaternion;
  59512. /**
  59513. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  59514. * @param scale defines the scale factor
  59515. * @param result defines the Quaternion object where to store the result
  59516. * @returns the unmodified current quaternion
  59517. */
  59518. scaleToRef(scale: number, result: Quaternion): Quaternion;
  59519. /**
  59520. * Multiplies in place the current quaternion by a scale factor
  59521. * @param value defines the scale factor
  59522. * @returns the current modified quaternion
  59523. */
  59524. scaleInPlace(value: number): Quaternion;
  59525. /**
  59526. * Scale the current quaternion values by a factor and add the result to a given quaternion
  59527. * @param scale defines the scale factor
  59528. * @param result defines the Quaternion object where to store the result
  59529. * @returns the unmodified current quaternion
  59530. */
  59531. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  59532. /**
  59533. * Multiplies two quaternions
  59534. * @param q1 defines the second operand
  59535. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  59536. */
  59537. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  59538. /**
  59539. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  59540. * @param q1 defines the second operand
  59541. * @param result defines the target quaternion
  59542. * @returns the current quaternion
  59543. */
  59544. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  59545. /**
  59546. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  59547. * @param q1 defines the second operand
  59548. * @returns the currentupdated quaternion
  59549. */
  59550. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  59551. /**
  59552. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  59553. * @param ref defines the target quaternion
  59554. * @returns the current quaternion
  59555. */
  59556. conjugateToRef(ref: Quaternion): Quaternion;
  59557. /**
  59558. * Conjugates in place (1-q) the current quaternion
  59559. * @returns the current updated quaternion
  59560. */
  59561. conjugateInPlace(): Quaternion;
  59562. /**
  59563. * Conjugates in place (1-q) the current quaternion
  59564. * @returns a new quaternion
  59565. */
  59566. conjugate(): Quaternion;
  59567. /**
  59568. * Gets length of current quaternion
  59569. * @returns the quaternion length (float)
  59570. */
  59571. length(): number;
  59572. /**
  59573. * Normalize in place the current quaternion
  59574. * @returns the current updated quaternion
  59575. */
  59576. normalize(): Quaternion;
  59577. /**
  59578. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  59579. * @param order is a reserved parameter and is ignore for now
  59580. * @returns a new Vector3 containing the Euler angles
  59581. */
  59582. toEulerAngles(order?: string): Vector3;
  59583. /**
  59584. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  59585. * @param result defines the vector which will be filled with the Euler angles
  59586. * @param order is a reserved parameter and is ignore for now
  59587. * @returns the current unchanged quaternion
  59588. */
  59589. toEulerAnglesToRef(result: Vector3): Quaternion;
  59590. /**
  59591. * Updates the given rotation matrix with the current quaternion values
  59592. * @param result defines the target matrix
  59593. * @returns the current unchanged quaternion
  59594. */
  59595. toRotationMatrix(result: Matrix): Quaternion;
  59596. /**
  59597. * Updates the current quaternion from the given rotation matrix values
  59598. * @param matrix defines the source matrix
  59599. * @returns the current updated quaternion
  59600. */
  59601. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  59602. /**
  59603. * Creates a new quaternion from a rotation matrix
  59604. * @param matrix defines the source matrix
  59605. * @returns a new quaternion created from the given rotation matrix values
  59606. */
  59607. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  59608. /**
  59609. * Updates the given quaternion with the given rotation matrix values
  59610. * @param matrix defines the source matrix
  59611. * @param result defines the target quaternion
  59612. */
  59613. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  59614. /**
  59615. * Returns the dot product (float) between the quaternions "left" and "right"
  59616. * @param left defines the left operand
  59617. * @param right defines the right operand
  59618. * @returns the dot product
  59619. */
  59620. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  59621. /**
  59622. * Checks if the two quaternions are close to each other
  59623. * @param quat0 defines the first quaternion to check
  59624. * @param quat1 defines the second quaternion to check
  59625. * @returns true if the two quaternions are close to each other
  59626. */
  59627. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  59628. /**
  59629. * Creates an empty quaternion
  59630. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  59631. */
  59632. static Zero(): Quaternion;
  59633. /**
  59634. * Inverse a given quaternion
  59635. * @param q defines the source quaternion
  59636. * @returns a new quaternion as the inverted current quaternion
  59637. */
  59638. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  59639. /**
  59640. * Inverse a given quaternion
  59641. * @param q defines the source quaternion
  59642. * @param result the quaternion the result will be stored in
  59643. * @returns the result quaternion
  59644. */
  59645. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  59646. /**
  59647. * Creates an identity quaternion
  59648. * @returns the identity quaternion
  59649. */
  59650. static Identity(): Quaternion;
  59651. /**
  59652. * Gets a boolean indicating if the given quaternion is identity
  59653. * @param quaternion defines the quaternion to check
  59654. * @returns true if the quaternion is identity
  59655. */
  59656. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  59657. /**
  59658. * Creates a quaternion from a rotation around an axis
  59659. * @param axis defines the axis to use
  59660. * @param angle defines the angle to use
  59661. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  59662. */
  59663. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  59664. /**
  59665. * Creates a rotation around an axis and stores it into the given quaternion
  59666. * @param axis defines the axis to use
  59667. * @param angle defines the angle to use
  59668. * @param result defines the target quaternion
  59669. * @returns the target quaternion
  59670. */
  59671. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  59672. /**
  59673. * Creates a new quaternion from data stored into an array
  59674. * @param array defines the data source
  59675. * @param offset defines the offset in the source array where the data starts
  59676. * @returns a new quaternion
  59677. */
  59678. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  59679. /**
  59680. * Create a quaternion from Euler rotation angles
  59681. * @param x Pitch
  59682. * @param y Yaw
  59683. * @param z Roll
  59684. * @returns the new Quaternion
  59685. */
  59686. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  59687. /**
  59688. * Updates a quaternion from Euler rotation angles
  59689. * @param x Pitch
  59690. * @param y Yaw
  59691. * @param z Roll
  59692. * @param result the quaternion to store the result
  59693. * @returns the updated quaternion
  59694. */
  59695. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  59696. /**
  59697. * Create a quaternion from Euler rotation vector
  59698. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  59699. * @returns the new Quaternion
  59700. */
  59701. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  59702. /**
  59703. * Updates a quaternion from Euler rotation vector
  59704. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  59705. * @param result the quaternion to store the result
  59706. * @returns the updated quaternion
  59707. */
  59708. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  59709. /**
  59710. * Creates a new quaternion from the given Euler float angles (y, x, z)
  59711. * @param yaw defines the rotation around Y axis
  59712. * @param pitch defines the rotation around X axis
  59713. * @param roll defines the rotation around Z axis
  59714. * @returns the new quaternion
  59715. */
  59716. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  59717. /**
  59718. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  59719. * @param yaw defines the rotation around Y axis
  59720. * @param pitch defines the rotation around X axis
  59721. * @param roll defines the rotation around Z axis
  59722. * @param result defines the target quaternion
  59723. */
  59724. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  59725. /**
  59726. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  59727. * @param alpha defines the rotation around first axis
  59728. * @param beta defines the rotation around second axis
  59729. * @param gamma defines the rotation around third axis
  59730. * @returns the new quaternion
  59731. */
  59732. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  59733. /**
  59734. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  59735. * @param alpha defines the rotation around first axis
  59736. * @param beta defines the rotation around second axis
  59737. * @param gamma defines the rotation around third axis
  59738. * @param result defines the target quaternion
  59739. */
  59740. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  59741. /**
  59742. * 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)
  59743. * @param axis1 defines the first axis
  59744. * @param axis2 defines the second axis
  59745. * @param axis3 defines the third axis
  59746. * @returns the new quaternion
  59747. */
  59748. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  59749. /**
  59750. * 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
  59751. * @param axis1 defines the first axis
  59752. * @param axis2 defines the second axis
  59753. * @param axis3 defines the third axis
  59754. * @param ref defines the target quaternion
  59755. */
  59756. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  59757. /**
  59758. * Interpolates between two quaternions
  59759. * @param left defines first quaternion
  59760. * @param right defines second quaternion
  59761. * @param amount defines the gradient to use
  59762. * @returns the new interpolated quaternion
  59763. */
  59764. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  59765. /**
  59766. * Interpolates between two quaternions and stores it into a target quaternion
  59767. * @param left defines first quaternion
  59768. * @param right defines second quaternion
  59769. * @param amount defines the gradient to use
  59770. * @param result defines the target quaternion
  59771. */
  59772. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  59773. /**
  59774. * Interpolate between two quaternions using Hermite interpolation
  59775. * @param value1 defines first quaternion
  59776. * @param tangent1 defines the incoming tangent
  59777. * @param value2 defines second quaternion
  59778. * @param tangent2 defines the outgoing tangent
  59779. * @param amount defines the target quaternion
  59780. * @returns the new interpolated quaternion
  59781. */
  59782. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  59783. }
  59784. /**
  59785. * Class used to store matrix data (4x4)
  59786. */
  59787. export class Matrix {
  59788. private static _updateFlagSeed;
  59789. private static _identityReadOnly;
  59790. private _isIdentity;
  59791. private _isIdentityDirty;
  59792. private _isIdentity3x2;
  59793. private _isIdentity3x2Dirty;
  59794. /**
  59795. * Gets the update flag of the matrix which is an unique number for the matrix.
  59796. * It will be incremented every time the matrix data change.
  59797. * You can use it to speed the comparison between two versions of the same matrix.
  59798. */
  59799. updateFlag: number;
  59800. private readonly _m;
  59801. /**
  59802. * Gets the internal data of the matrix
  59803. */
  59804. readonly m: DeepImmutable<Float32Array>;
  59805. /** @hidden */
  59806. _markAsUpdated(): void;
  59807. /** @hidden */
  59808. private _updateIdentityStatus;
  59809. /**
  59810. * Creates an empty matrix (filled with zeros)
  59811. */
  59812. constructor();
  59813. /**
  59814. * Check if the current matrix is identity
  59815. * @returns true is the matrix is the identity matrix
  59816. */
  59817. isIdentity(): boolean;
  59818. /**
  59819. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  59820. * @returns true is the matrix is the identity matrix
  59821. */
  59822. isIdentityAs3x2(): boolean;
  59823. /**
  59824. * Gets the determinant of the matrix
  59825. * @returns the matrix determinant
  59826. */
  59827. determinant(): number;
  59828. /**
  59829. * Returns the matrix as a Float32Array
  59830. * @returns the matrix underlying array
  59831. */
  59832. toArray(): DeepImmutable<Float32Array>;
  59833. /**
  59834. * Returns the matrix as a Float32Array
  59835. * @returns the matrix underlying array.
  59836. */
  59837. asArray(): DeepImmutable<Float32Array>;
  59838. /**
  59839. * Inverts the current matrix in place
  59840. * @returns the current inverted matrix
  59841. */
  59842. invert(): Matrix;
  59843. /**
  59844. * Sets all the matrix elements to zero
  59845. * @returns the current matrix
  59846. */
  59847. reset(): Matrix;
  59848. /**
  59849. * Adds the current matrix with a second one
  59850. * @param other defines the matrix to add
  59851. * @returns a new matrix as the addition of the current matrix and the given one
  59852. */
  59853. add(other: DeepImmutable<Matrix>): Matrix;
  59854. /**
  59855. * Sets the given matrix "result" to the addition of the current matrix and the given one
  59856. * @param other defines the matrix to add
  59857. * @param result defines the target matrix
  59858. * @returns the current matrix
  59859. */
  59860. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  59861. /**
  59862. * Adds in place the given matrix to the current matrix
  59863. * @param other defines the second operand
  59864. * @returns the current updated matrix
  59865. */
  59866. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  59867. /**
  59868. * Sets the given matrix to the current inverted Matrix
  59869. * @param other defines the target matrix
  59870. * @returns the unmodified current matrix
  59871. */
  59872. invertToRef(other: Matrix): Matrix;
  59873. /**
  59874. * add a value at the specified position in the current Matrix
  59875. * @param index the index of the value within the matrix. between 0 and 15.
  59876. * @param value the value to be added
  59877. * @returns the current updated matrix
  59878. */
  59879. addAtIndex(index: number, value: number): Matrix;
  59880. /**
  59881. * mutiply the specified position in the current Matrix by a value
  59882. * @param index the index of the value within the matrix. between 0 and 15.
  59883. * @param value the value to be added
  59884. * @returns the current updated matrix
  59885. */
  59886. multiplyAtIndex(index: number, value: number): Matrix;
  59887. /**
  59888. * Inserts the translation vector (using 3 floats) in the current matrix
  59889. * @param x defines the 1st component of the translation
  59890. * @param y defines the 2nd component of the translation
  59891. * @param z defines the 3rd component of the translation
  59892. * @returns the current updated matrix
  59893. */
  59894. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  59895. /**
  59896. * Inserts the translation vector in the current matrix
  59897. * @param vector3 defines the translation to insert
  59898. * @returns the current updated matrix
  59899. */
  59900. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  59901. /**
  59902. * Gets the translation value of the current matrix
  59903. * @returns a new Vector3 as the extracted translation from the matrix
  59904. */
  59905. getTranslation(): Vector3;
  59906. /**
  59907. * Fill a Vector3 with the extracted translation from the matrix
  59908. * @param result defines the Vector3 where to store the translation
  59909. * @returns the current matrix
  59910. */
  59911. getTranslationToRef(result: Vector3): Matrix;
  59912. /**
  59913. * Remove rotation and scaling part from the matrix
  59914. * @returns the updated matrix
  59915. */
  59916. removeRotationAndScaling(): Matrix;
  59917. /**
  59918. * Multiply two matrices
  59919. * @param other defines the second operand
  59920. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  59921. */
  59922. multiply(other: DeepImmutable<Matrix>): Matrix;
  59923. /**
  59924. * Copy the current matrix from the given one
  59925. * @param other defines the source matrix
  59926. * @returns the current updated matrix
  59927. */
  59928. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  59929. /**
  59930. * Populates the given array from the starting index with the current matrix values
  59931. * @param array defines the target array
  59932. * @param offset defines the offset in the target array where to start storing values
  59933. * @returns the current matrix
  59934. */
  59935. copyToArray(array: Float32Array, offset?: number): Matrix;
  59936. /**
  59937. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  59938. * @param other defines the second operand
  59939. * @param result defines the matrix where to store the multiplication
  59940. * @returns the current matrix
  59941. */
  59942. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  59943. /**
  59944. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  59945. * @param other defines the second operand
  59946. * @param result defines the array where to store the multiplication
  59947. * @param offset defines the offset in the target array where to start storing values
  59948. * @returns the current matrix
  59949. */
  59950. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  59951. /**
  59952. * Check equality between this matrix and a second one
  59953. * @param value defines the second matrix to compare
  59954. * @returns true is the current matrix and the given one values are strictly equal
  59955. */
  59956. equals(value: DeepImmutable<Matrix>): boolean;
  59957. /**
  59958. * Clone the current matrix
  59959. * @returns a new matrix from the current matrix
  59960. */
  59961. clone(): Matrix;
  59962. /**
  59963. * Returns the name of the current matrix class
  59964. * @returns the string "Matrix"
  59965. */
  59966. getClassName(): string;
  59967. /**
  59968. * Gets the hash code of the current matrix
  59969. * @returns the hash code
  59970. */
  59971. getHashCode(): number;
  59972. /**
  59973. * Decomposes the current Matrix into a translation, rotation and scaling components
  59974. * @param scale defines the scale vector3 given as a reference to update
  59975. * @param rotation defines the rotation quaternion given as a reference to update
  59976. * @param translation defines the translation vector3 given as a reference to update
  59977. * @returns true if operation was successful
  59978. */
  59979. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  59980. /**
  59981. * Gets specific row of the matrix
  59982. * @param index defines the number of the row to get
  59983. * @returns the index-th row of the current matrix as a new Vector4
  59984. */
  59985. getRow(index: number): Nullable<Vector4>;
  59986. /**
  59987. * Sets the index-th row of the current matrix to the vector4 values
  59988. * @param index defines the number of the row to set
  59989. * @param row defines the target vector4
  59990. * @returns the updated current matrix
  59991. */
  59992. setRow(index: number, row: Vector4): Matrix;
  59993. /**
  59994. * Compute the transpose of the matrix
  59995. * @returns the new transposed matrix
  59996. */
  59997. transpose(): Matrix;
  59998. /**
  59999. * Compute the transpose of the matrix and store it in a given matrix
  60000. * @param result defines the target matrix
  60001. * @returns the current matrix
  60002. */
  60003. transposeToRef(result: Matrix): Matrix;
  60004. /**
  60005. * Sets the index-th row of the current matrix with the given 4 x float values
  60006. * @param index defines the row index
  60007. * @param x defines the x component to set
  60008. * @param y defines the y component to set
  60009. * @param z defines the z component to set
  60010. * @param w defines the w component to set
  60011. * @returns the updated current matrix
  60012. */
  60013. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  60014. /**
  60015. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  60016. * @param scale defines the scale factor
  60017. * @returns a new matrix
  60018. */
  60019. scale(scale: number): Matrix;
  60020. /**
  60021. * Scale the current matrix values by a factor to a given result matrix
  60022. * @param scale defines the scale factor
  60023. * @param result defines the matrix to store the result
  60024. * @returns the current matrix
  60025. */
  60026. scaleToRef(scale: number, result: Matrix): Matrix;
  60027. /**
  60028. * Scale the current matrix values by a factor and add the result to a given matrix
  60029. * @param scale defines the scale factor
  60030. * @param result defines the Matrix to store the result
  60031. * @returns the current matrix
  60032. */
  60033. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  60034. /**
  60035. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  60036. * @param ref matrix to store the result
  60037. */
  60038. toNormalMatrix(ref: Matrix): void;
  60039. /**
  60040. * Gets only rotation part of the current matrix
  60041. * @returns a new matrix sets to the extracted rotation matrix from the current one
  60042. */
  60043. getRotationMatrix(): Matrix;
  60044. /**
  60045. * Extracts the rotation matrix from the current one and sets it as the given "result"
  60046. * @param result defines the target matrix to store data to
  60047. * @returns the current matrix
  60048. */
  60049. getRotationMatrixToRef(result: Matrix): Matrix;
  60050. /**
  60051. * Toggles model matrix from being right handed to left handed in place and vice versa
  60052. */
  60053. toggleModelMatrixHandInPlace(): void;
  60054. /**
  60055. * Toggles projection matrix from being right handed to left handed in place and vice versa
  60056. */
  60057. toggleProjectionMatrixHandInPlace(): void;
  60058. /**
  60059. * Creates a matrix from an array
  60060. * @param array defines the source array
  60061. * @param offset defines an offset in the source array
  60062. * @returns a new Matrix set from the starting index of the given array
  60063. */
  60064. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  60065. /**
  60066. * Copy the content of an array into a given matrix
  60067. * @param array defines the source array
  60068. * @param offset defines an offset in the source array
  60069. * @param result defines the target matrix
  60070. */
  60071. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  60072. /**
  60073. * Stores an array into a matrix after having multiplied each component by a given factor
  60074. * @param array defines the source array
  60075. * @param offset defines the offset in the source array
  60076. * @param scale defines the scaling factor
  60077. * @param result defines the target matrix
  60078. */
  60079. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  60080. /**
  60081. * Gets an identity matrix that must not be updated
  60082. */
  60083. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  60084. /**
  60085. * Stores a list of values (16) inside a given matrix
  60086. * @param initialM11 defines 1st value of 1st row
  60087. * @param initialM12 defines 2nd value of 1st row
  60088. * @param initialM13 defines 3rd value of 1st row
  60089. * @param initialM14 defines 4th value of 1st row
  60090. * @param initialM21 defines 1st value of 2nd row
  60091. * @param initialM22 defines 2nd value of 2nd row
  60092. * @param initialM23 defines 3rd value of 2nd row
  60093. * @param initialM24 defines 4th value of 2nd row
  60094. * @param initialM31 defines 1st value of 3rd row
  60095. * @param initialM32 defines 2nd value of 3rd row
  60096. * @param initialM33 defines 3rd value of 3rd row
  60097. * @param initialM34 defines 4th value of 3rd row
  60098. * @param initialM41 defines 1st value of 4th row
  60099. * @param initialM42 defines 2nd value of 4th row
  60100. * @param initialM43 defines 3rd value of 4th row
  60101. * @param initialM44 defines 4th value of 4th row
  60102. * @param result defines the target matrix
  60103. */
  60104. 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;
  60105. /**
  60106. * Creates new matrix from a list of values (16)
  60107. * @param initialM11 defines 1st value of 1st row
  60108. * @param initialM12 defines 2nd value of 1st row
  60109. * @param initialM13 defines 3rd value of 1st row
  60110. * @param initialM14 defines 4th value of 1st row
  60111. * @param initialM21 defines 1st value of 2nd row
  60112. * @param initialM22 defines 2nd value of 2nd row
  60113. * @param initialM23 defines 3rd value of 2nd row
  60114. * @param initialM24 defines 4th value of 2nd row
  60115. * @param initialM31 defines 1st value of 3rd row
  60116. * @param initialM32 defines 2nd value of 3rd row
  60117. * @param initialM33 defines 3rd value of 3rd row
  60118. * @param initialM34 defines 4th value of 3rd row
  60119. * @param initialM41 defines 1st value of 4th row
  60120. * @param initialM42 defines 2nd value of 4th row
  60121. * @param initialM43 defines 3rd value of 4th row
  60122. * @param initialM44 defines 4th value of 4th row
  60123. * @returns the new matrix
  60124. */
  60125. 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;
  60126. /**
  60127. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  60128. * @param scale defines the scale vector3
  60129. * @param rotation defines the rotation quaternion
  60130. * @param translation defines the translation vector3
  60131. * @returns a new matrix
  60132. */
  60133. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  60134. /**
  60135. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  60136. * @param scale defines the scale vector3
  60137. * @param rotation defines the rotation quaternion
  60138. * @param translation defines the translation vector3
  60139. * @param result defines the target matrix
  60140. */
  60141. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  60142. /**
  60143. * Creates a new identity matrix
  60144. * @returns a new identity matrix
  60145. */
  60146. static Identity(): Matrix;
  60147. /**
  60148. * Creates a new identity matrix and stores the result in a given matrix
  60149. * @param result defines the target matrix
  60150. */
  60151. static IdentityToRef(result: Matrix): void;
  60152. /**
  60153. * Creates a new zero matrix
  60154. * @returns a new zero matrix
  60155. */
  60156. static Zero(): Matrix;
  60157. /**
  60158. * Creates a new rotation matrix for "angle" radians around the X axis
  60159. * @param angle defines the angle (in radians) to use
  60160. * @return the new matrix
  60161. */
  60162. static RotationX(angle: number): Matrix;
  60163. /**
  60164. * Creates a new matrix as the invert of a given matrix
  60165. * @param source defines the source matrix
  60166. * @returns the new matrix
  60167. */
  60168. static Invert(source: DeepImmutable<Matrix>): Matrix;
  60169. /**
  60170. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  60171. * @param angle defines the angle (in radians) to use
  60172. * @param result defines the target matrix
  60173. */
  60174. static RotationXToRef(angle: number, result: Matrix): void;
  60175. /**
  60176. * Creates a new rotation matrix for "angle" radians around the Y axis
  60177. * @param angle defines the angle (in radians) to use
  60178. * @return the new matrix
  60179. */
  60180. static RotationY(angle: number): Matrix;
  60181. /**
  60182. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  60183. * @param angle defines the angle (in radians) to use
  60184. * @param result defines the target matrix
  60185. */
  60186. static RotationYToRef(angle: number, result: Matrix): void;
  60187. /**
  60188. * Creates a new rotation matrix for "angle" radians around the Z axis
  60189. * @param angle defines the angle (in radians) to use
  60190. * @return the new matrix
  60191. */
  60192. static RotationZ(angle: number): Matrix;
  60193. /**
  60194. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  60195. * @param angle defines the angle (in radians) to use
  60196. * @param result defines the target matrix
  60197. */
  60198. static RotationZToRef(angle: number, result: Matrix): void;
  60199. /**
  60200. * Creates a new rotation matrix for "angle" radians around the given axis
  60201. * @param axis defines the axis to use
  60202. * @param angle defines the angle (in radians) to use
  60203. * @return the new matrix
  60204. */
  60205. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  60206. /**
  60207. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  60208. * @param axis defines the axis to use
  60209. * @param angle defines the angle (in radians) to use
  60210. * @param result defines the target matrix
  60211. */
  60212. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  60213. /**
  60214. * Creates a rotation matrix
  60215. * @param yaw defines the yaw angle in radians (Y axis)
  60216. * @param pitch defines the pitch angle in radians (X axis)
  60217. * @param roll defines the roll angle in radians (X axis)
  60218. * @returns the new rotation matrix
  60219. */
  60220. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  60221. /**
  60222. * Creates a rotation matrix and stores it in a given matrix
  60223. * @param yaw defines the yaw angle in radians (Y axis)
  60224. * @param pitch defines the pitch angle in radians (X axis)
  60225. * @param roll defines the roll angle in radians (X axis)
  60226. * @param result defines the target matrix
  60227. */
  60228. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  60229. /**
  60230. * Creates a scaling matrix
  60231. * @param x defines the scale factor on X axis
  60232. * @param y defines the scale factor on Y axis
  60233. * @param z defines the scale factor on Z axis
  60234. * @returns the new matrix
  60235. */
  60236. static Scaling(x: number, y: number, z: number): Matrix;
  60237. /**
  60238. * Creates a scaling matrix and stores it in a given matrix
  60239. * @param x defines the scale factor on X axis
  60240. * @param y defines the scale factor on Y axis
  60241. * @param z defines the scale factor on Z axis
  60242. * @param result defines the target matrix
  60243. */
  60244. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  60245. /**
  60246. * Creates a translation matrix
  60247. * @param x defines the translation on X axis
  60248. * @param y defines the translation on Y axis
  60249. * @param z defines the translationon Z axis
  60250. * @returns the new matrix
  60251. */
  60252. static Translation(x: number, y: number, z: number): Matrix;
  60253. /**
  60254. * Creates a translation matrix and stores it in a given matrix
  60255. * @param x defines the translation on X axis
  60256. * @param y defines the translation on Y axis
  60257. * @param z defines the translationon Z axis
  60258. * @param result defines the target matrix
  60259. */
  60260. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  60261. /**
  60262. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  60263. * @param startValue defines the start value
  60264. * @param endValue defines the end value
  60265. * @param gradient defines the gradient factor
  60266. * @returns the new matrix
  60267. */
  60268. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  60269. /**
  60270. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  60271. * @param startValue defines the start value
  60272. * @param endValue defines the end value
  60273. * @param gradient defines the gradient factor
  60274. * @param result defines the Matrix object where to store data
  60275. */
  60276. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  60277. /**
  60278. * Builds a new matrix whose values are computed by:
  60279. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  60280. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  60281. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  60282. * @param startValue defines the first matrix
  60283. * @param endValue defines the second matrix
  60284. * @param gradient defines the gradient between the two matrices
  60285. * @returns the new matrix
  60286. */
  60287. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  60288. /**
  60289. * Update a matrix to values which are computed by:
  60290. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  60291. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  60292. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  60293. * @param startValue defines the first matrix
  60294. * @param endValue defines the second matrix
  60295. * @param gradient defines the gradient between the two matrices
  60296. * @param result defines the target matrix
  60297. */
  60298. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  60299. /**
  60300. * 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"
  60301. * This function works in left handed mode
  60302. * @param eye defines the final position of the entity
  60303. * @param target defines where the entity should look at
  60304. * @param up defines the up vector for the entity
  60305. * @returns the new matrix
  60306. */
  60307. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  60308. /**
  60309. * 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".
  60310. * This function works in left handed mode
  60311. * @param eye defines the final position of the entity
  60312. * @param target defines where the entity should look at
  60313. * @param up defines the up vector for the entity
  60314. * @param result defines the target matrix
  60315. */
  60316. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  60317. /**
  60318. * 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"
  60319. * This function works in right handed mode
  60320. * @param eye defines the final position of the entity
  60321. * @param target defines where the entity should look at
  60322. * @param up defines the up vector for the entity
  60323. * @returns the new matrix
  60324. */
  60325. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  60326. /**
  60327. * 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".
  60328. * This function works in right handed mode
  60329. * @param eye defines the final position of the entity
  60330. * @param target defines where the entity should look at
  60331. * @param up defines the up vector for the entity
  60332. * @param result defines the target matrix
  60333. */
  60334. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  60335. /**
  60336. * Create a left-handed orthographic projection matrix
  60337. * @param width defines the viewport width
  60338. * @param height defines the viewport height
  60339. * @param znear defines the near clip plane
  60340. * @param zfar defines the far clip plane
  60341. * @returns a new matrix as a left-handed orthographic projection matrix
  60342. */
  60343. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  60344. /**
  60345. * Store a left-handed orthographic projection to a given matrix
  60346. * @param width defines the viewport width
  60347. * @param height defines the viewport height
  60348. * @param znear defines the near clip plane
  60349. * @param zfar defines the far clip plane
  60350. * @param result defines the target matrix
  60351. */
  60352. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  60353. /**
  60354. * Create a left-handed orthographic projection matrix
  60355. * @param left defines the viewport left coordinate
  60356. * @param right defines the viewport right coordinate
  60357. * @param bottom defines the viewport bottom coordinate
  60358. * @param top defines the viewport top coordinate
  60359. * @param znear defines the near clip plane
  60360. * @param zfar defines the far clip plane
  60361. * @returns a new matrix as a left-handed orthographic projection matrix
  60362. */
  60363. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  60364. /**
  60365. * Stores a left-handed orthographic projection into a given matrix
  60366. * @param left defines the viewport left coordinate
  60367. * @param right defines the viewport right coordinate
  60368. * @param bottom defines the viewport bottom coordinate
  60369. * @param top defines the viewport top coordinate
  60370. * @param znear defines the near clip plane
  60371. * @param zfar defines the far clip plane
  60372. * @param result defines the target matrix
  60373. */
  60374. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  60375. /**
  60376. * Creates a right-handed orthographic projection matrix
  60377. * @param left defines the viewport left coordinate
  60378. * @param right defines the viewport right coordinate
  60379. * @param bottom defines the viewport bottom coordinate
  60380. * @param top defines the viewport top coordinate
  60381. * @param znear defines the near clip plane
  60382. * @param zfar defines the far clip plane
  60383. * @returns a new matrix as a right-handed orthographic projection matrix
  60384. */
  60385. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  60386. /**
  60387. * Stores a right-handed orthographic projection into a given matrix
  60388. * @param left defines the viewport left coordinate
  60389. * @param right defines the viewport right coordinate
  60390. * @param bottom defines the viewport bottom coordinate
  60391. * @param top defines the viewport top coordinate
  60392. * @param znear defines the near clip plane
  60393. * @param zfar defines the far clip plane
  60394. * @param result defines the target matrix
  60395. */
  60396. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  60397. /**
  60398. * Creates a left-handed perspective projection matrix
  60399. * @param width defines the viewport width
  60400. * @param height defines the viewport height
  60401. * @param znear defines the near clip plane
  60402. * @param zfar defines the far clip plane
  60403. * @returns a new matrix as a left-handed perspective projection matrix
  60404. */
  60405. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  60406. /**
  60407. * Creates a left-handed perspective projection matrix
  60408. * @param fov defines the horizontal field of view
  60409. * @param aspect defines the aspect ratio
  60410. * @param znear defines the near clip plane
  60411. * @param zfar defines the far clip plane
  60412. * @returns a new matrix as a left-handed perspective projection matrix
  60413. */
  60414. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  60415. /**
  60416. * Stores a left-handed perspective projection into a given matrix
  60417. * @param fov defines the horizontal field of view
  60418. * @param aspect defines the aspect ratio
  60419. * @param znear defines the near clip plane
  60420. * @param zfar defines the far clip plane
  60421. * @param result defines the target matrix
  60422. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  60423. */
  60424. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  60425. /**
  60426. * Creates a right-handed perspective projection matrix
  60427. * @param fov defines the horizontal field of view
  60428. * @param aspect defines the aspect ratio
  60429. * @param znear defines the near clip plane
  60430. * @param zfar defines the far clip plane
  60431. * @returns a new matrix as a right-handed perspective projection matrix
  60432. */
  60433. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  60434. /**
  60435. * Stores a right-handed perspective projection into a given matrix
  60436. * @param fov defines the horizontal field of view
  60437. * @param aspect defines the aspect ratio
  60438. * @param znear defines the near clip plane
  60439. * @param zfar defines the far clip plane
  60440. * @param result defines the target matrix
  60441. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  60442. */
  60443. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  60444. /**
  60445. * Stores a perspective projection for WebVR info a given matrix
  60446. * @param fov defines the field of view
  60447. * @param znear defines the near clip plane
  60448. * @param zfar defines the far clip plane
  60449. * @param result defines the target matrix
  60450. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  60451. */
  60452. static PerspectiveFovWebVRToRef(fov: {
  60453. upDegrees: number;
  60454. downDegrees: number;
  60455. leftDegrees: number;
  60456. rightDegrees: number;
  60457. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  60458. /**
  60459. * Computes a complete transformation matrix
  60460. * @param viewport defines the viewport to use
  60461. * @param world defines the world matrix
  60462. * @param view defines the view matrix
  60463. * @param projection defines the projection matrix
  60464. * @param zmin defines the near clip plane
  60465. * @param zmax defines the far clip plane
  60466. * @returns the transformation matrix
  60467. */
  60468. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  60469. /**
  60470. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  60471. * @param matrix defines the matrix to use
  60472. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  60473. */
  60474. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  60475. /**
  60476. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  60477. * @param matrix defines the matrix to use
  60478. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  60479. */
  60480. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  60481. /**
  60482. * Compute the transpose of a given matrix
  60483. * @param matrix defines the matrix to transpose
  60484. * @returns the new matrix
  60485. */
  60486. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  60487. /**
  60488. * Compute the transpose of a matrix and store it in a target matrix
  60489. * @param matrix defines the matrix to transpose
  60490. * @param result defines the target matrix
  60491. */
  60492. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  60493. /**
  60494. * Computes a reflection matrix from a plane
  60495. * @param plane defines the reflection plane
  60496. * @returns a new matrix
  60497. */
  60498. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  60499. /**
  60500. * Computes a reflection matrix from a plane
  60501. * @param plane defines the reflection plane
  60502. * @param result defines the target matrix
  60503. */
  60504. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  60505. /**
  60506. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  60507. * @param xaxis defines the value of the 1st axis
  60508. * @param yaxis defines the value of the 2nd axis
  60509. * @param zaxis defines the value of the 3rd axis
  60510. * @param result defines the target matrix
  60511. */
  60512. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  60513. /**
  60514. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  60515. * @param quat defines the quaternion to use
  60516. * @param result defines the target matrix
  60517. */
  60518. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  60519. }
  60520. /**
  60521. * Represens a plane by the equation ax + by + cz + d = 0
  60522. */
  60523. export class Plane {
  60524. /**
  60525. * Normal of the plane (a,b,c)
  60526. */
  60527. normal: Vector3;
  60528. /**
  60529. * d component of the plane
  60530. */
  60531. d: number;
  60532. /**
  60533. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  60534. * @param a a component of the plane
  60535. * @param b b component of the plane
  60536. * @param c c component of the plane
  60537. * @param d d component of the plane
  60538. */
  60539. constructor(a: number, b: number, c: number, d: number);
  60540. /**
  60541. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  60542. */
  60543. asArray(): number[];
  60544. /**
  60545. * @returns a new plane copied from the current Plane.
  60546. */
  60547. clone(): Plane;
  60548. /**
  60549. * @returns the string "Plane".
  60550. */
  60551. getClassName(): string;
  60552. /**
  60553. * @returns the Plane hash code.
  60554. */
  60555. getHashCode(): number;
  60556. /**
  60557. * Normalize the current Plane in place.
  60558. * @returns the updated Plane.
  60559. */
  60560. normalize(): Plane;
  60561. /**
  60562. * Applies a transformation the plane and returns the result
  60563. * @param transformation the transformation matrix to be applied to the plane
  60564. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  60565. */
  60566. transform(transformation: DeepImmutable<Matrix>): Plane;
  60567. /**
  60568. * Calcualtte the dot product between the point and the plane normal
  60569. * @param point point to calculate the dot product with
  60570. * @returns the dot product (float) of the point coordinates and the plane normal.
  60571. */
  60572. dotCoordinate(point: DeepImmutable<Vector3>): number;
  60573. /**
  60574. * Updates the current Plane from the plane defined by the three given points.
  60575. * @param point1 one of the points used to contruct the plane
  60576. * @param point2 one of the points used to contruct the plane
  60577. * @param point3 one of the points used to contruct the plane
  60578. * @returns the updated Plane.
  60579. */
  60580. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  60581. /**
  60582. * Checks if the plane is facing a given direction
  60583. * @param direction the direction to check if the plane is facing
  60584. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  60585. * @returns True is the vector "direction" is the same side than the plane normal.
  60586. */
  60587. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  60588. /**
  60589. * Calculates the distance to a point
  60590. * @param point point to calculate distance to
  60591. * @returns the signed distance (float) from the given point to the Plane.
  60592. */
  60593. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  60594. /**
  60595. * Creates a plane from an array
  60596. * @param array the array to create a plane from
  60597. * @returns a new Plane from the given array.
  60598. */
  60599. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  60600. /**
  60601. * Creates a plane from three points
  60602. * @param point1 point used to create the plane
  60603. * @param point2 point used to create the plane
  60604. * @param point3 point used to create the plane
  60605. * @returns a new Plane defined by the three given points.
  60606. */
  60607. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  60608. /**
  60609. * Creates a plane from an origin point and a normal
  60610. * @param origin origin of the plane to be constructed
  60611. * @param normal normal of the plane to be constructed
  60612. * @returns a new Plane the normal vector to this plane at the given origin point.
  60613. * Note : the vector "normal" is updated because normalized.
  60614. */
  60615. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  60616. /**
  60617. * Calculates the distance from a plane and a point
  60618. * @param origin origin of the plane to be constructed
  60619. * @param normal normal of the plane to be constructed
  60620. * @param point point to calculate distance to
  60621. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  60622. */
  60623. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  60624. }
  60625. /**
  60626. * Class used to represent a viewport on screen
  60627. */
  60628. export class Viewport {
  60629. /** viewport left coordinate */
  60630. x: number;
  60631. /** viewport top coordinate */
  60632. y: number;
  60633. /**viewport width */
  60634. width: number;
  60635. /** viewport height */
  60636. height: number;
  60637. /**
  60638. * Creates a Viewport object located at (x, y) and sized (width, height)
  60639. * @param x defines viewport left coordinate
  60640. * @param y defines viewport top coordinate
  60641. * @param width defines the viewport width
  60642. * @param height defines the viewport height
  60643. */
  60644. constructor(
  60645. /** viewport left coordinate */
  60646. x: number,
  60647. /** viewport top coordinate */
  60648. y: number,
  60649. /**viewport width */
  60650. width: number,
  60651. /** viewport height */
  60652. height: number);
  60653. /**
  60654. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  60655. * @param renderWidth defines the rendering width
  60656. * @param renderHeight defines the rendering height
  60657. * @returns a new Viewport
  60658. */
  60659. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  60660. /**
  60661. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  60662. * @param renderWidth defines the rendering width
  60663. * @param renderHeight defines the rendering height
  60664. * @param ref defines the target viewport
  60665. * @returns the current viewport
  60666. */
  60667. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  60668. /**
  60669. * Returns a new Viewport copied from the current one
  60670. * @returns a new Viewport
  60671. */
  60672. clone(): Viewport;
  60673. }
  60674. /**
  60675. * Reprasents a camera frustum
  60676. */
  60677. export class Frustum {
  60678. /**
  60679. * Gets the planes representing the frustum
  60680. * @param transform matrix to be applied to the returned planes
  60681. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  60682. */
  60683. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  60684. /**
  60685. * Gets the near frustum plane transformed by the transform matrix
  60686. * @param transform transformation matrix to be applied to the resulting frustum plane
  60687. * @param frustumPlane the resuling frustum plane
  60688. */
  60689. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  60690. /**
  60691. * Gets the far frustum plane transformed by the transform matrix
  60692. * @param transform transformation matrix to be applied to the resulting frustum plane
  60693. * @param frustumPlane the resuling frustum plane
  60694. */
  60695. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  60696. /**
  60697. * Gets the left frustum plane transformed by the transform matrix
  60698. * @param transform transformation matrix to be applied to the resulting frustum plane
  60699. * @param frustumPlane the resuling frustum plane
  60700. */
  60701. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  60702. /**
  60703. * Gets the right frustum plane transformed by the transform matrix
  60704. * @param transform transformation matrix to be applied to the resulting frustum plane
  60705. * @param frustumPlane the resuling frustum plane
  60706. */
  60707. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  60708. /**
  60709. * Gets the top frustum plane transformed by the transform matrix
  60710. * @param transform transformation matrix to be applied to the resulting frustum plane
  60711. * @param frustumPlane the resuling frustum plane
  60712. */
  60713. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  60714. /**
  60715. * Gets the bottom frustum plane transformed by the transform matrix
  60716. * @param transform transformation matrix to be applied to the resulting frustum plane
  60717. * @param frustumPlane the resuling frustum plane
  60718. */
  60719. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  60720. /**
  60721. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  60722. * @param transform transformation matrix to be applied to the resulting frustum planes
  60723. * @param frustumPlanes the resuling frustum planes
  60724. */
  60725. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  60726. }
  60727. /** Defines supported spaces */
  60728. export enum Space {
  60729. /** Local (object) space */
  60730. LOCAL = 0,
  60731. /** World space */
  60732. WORLD = 1,
  60733. /** Bone space */
  60734. BONE = 2
  60735. }
  60736. /** Defines the 3 main axes */
  60737. export class Axis {
  60738. /** X axis */
  60739. static X: Vector3;
  60740. /** Y axis */
  60741. static Y: Vector3;
  60742. /** Z axis */
  60743. static Z: Vector3;
  60744. }
  60745. /** Class used to represent a Bezier curve */
  60746. export class BezierCurve {
  60747. /**
  60748. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  60749. * @param t defines the time
  60750. * @param x1 defines the left coordinate on X axis
  60751. * @param y1 defines the left coordinate on Y axis
  60752. * @param x2 defines the right coordinate on X axis
  60753. * @param y2 defines the right coordinate on Y axis
  60754. * @returns the interpolated value
  60755. */
  60756. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  60757. }
  60758. /**
  60759. * Defines potential orientation for back face culling
  60760. */
  60761. export enum Orientation {
  60762. /**
  60763. * Clockwise
  60764. */
  60765. CW = 0,
  60766. /** Counter clockwise */
  60767. CCW = 1
  60768. }
  60769. /**
  60770. * Defines angle representation
  60771. */
  60772. export class Angle {
  60773. private _radians;
  60774. /**
  60775. * Creates an Angle object of "radians" radians (float).
  60776. * @param radians the angle in radians
  60777. */
  60778. constructor(radians: number);
  60779. /**
  60780. * Get value in degrees
  60781. * @returns the Angle value in degrees (float)
  60782. */
  60783. degrees(): number;
  60784. /**
  60785. * Get value in radians
  60786. * @returns the Angle value in radians (float)
  60787. */
  60788. radians(): number;
  60789. /**
  60790. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  60791. * @param a defines first vector
  60792. * @param b defines second vector
  60793. * @returns a new Angle
  60794. */
  60795. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  60796. /**
  60797. * Gets a new Angle object from the given float in radians
  60798. * @param radians defines the angle value in radians
  60799. * @returns a new Angle
  60800. */
  60801. static FromRadians(radians: number): Angle;
  60802. /**
  60803. * Gets a new Angle object from the given float in degrees
  60804. * @param degrees defines the angle value in degrees
  60805. * @returns a new Angle
  60806. */
  60807. static FromDegrees(degrees: number): Angle;
  60808. }
  60809. /**
  60810. * This represents an arc in a 2d space.
  60811. */
  60812. export class Arc2 {
  60813. /** Defines the start point of the arc */
  60814. startPoint: Vector2;
  60815. /** Defines the mid point of the arc */
  60816. midPoint: Vector2;
  60817. /** Defines the end point of the arc */
  60818. endPoint: Vector2;
  60819. /**
  60820. * Defines the center point of the arc.
  60821. */
  60822. centerPoint: Vector2;
  60823. /**
  60824. * Defines the radius of the arc.
  60825. */
  60826. radius: number;
  60827. /**
  60828. * Defines the angle of the arc (from mid point to end point).
  60829. */
  60830. angle: Angle;
  60831. /**
  60832. * Defines the start angle of the arc (from start point to middle point).
  60833. */
  60834. startAngle: Angle;
  60835. /**
  60836. * Defines the orientation of the arc (clock wise/counter clock wise).
  60837. */
  60838. orientation: Orientation;
  60839. /**
  60840. * Creates an Arc object from the three given points : start, middle and end.
  60841. * @param startPoint Defines the start point of the arc
  60842. * @param midPoint Defines the midlle point of the arc
  60843. * @param endPoint Defines the end point of the arc
  60844. */
  60845. constructor(
  60846. /** Defines the start point of the arc */
  60847. startPoint: Vector2,
  60848. /** Defines the mid point of the arc */
  60849. midPoint: Vector2,
  60850. /** Defines the end point of the arc */
  60851. endPoint: Vector2);
  60852. }
  60853. /**
  60854. * Represents a 2D path made up of multiple 2D points
  60855. */
  60856. export class Path2 {
  60857. private _points;
  60858. private _length;
  60859. /**
  60860. * If the path start and end point are the same
  60861. */
  60862. closed: boolean;
  60863. /**
  60864. * Creates a Path2 object from the starting 2D coordinates x and y.
  60865. * @param x the starting points x value
  60866. * @param y the starting points y value
  60867. */
  60868. constructor(x: number, y: number);
  60869. /**
  60870. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  60871. * @param x the added points x value
  60872. * @param y the added points y value
  60873. * @returns the updated Path2.
  60874. */
  60875. addLineTo(x: number, y: number): Path2;
  60876. /**
  60877. * 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.
  60878. * @param midX middle point x value
  60879. * @param midY middle point y value
  60880. * @param endX end point x value
  60881. * @param endY end point y value
  60882. * @param numberOfSegments (default: 36)
  60883. * @returns the updated Path2.
  60884. */
  60885. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  60886. /**
  60887. * Closes the Path2.
  60888. * @returns the Path2.
  60889. */
  60890. close(): Path2;
  60891. /**
  60892. * Gets the sum of the distance between each sequential point in the path
  60893. * @returns the Path2 total length (float).
  60894. */
  60895. length(): number;
  60896. /**
  60897. * Gets the points which construct the path
  60898. * @returns the Path2 internal array of points.
  60899. */
  60900. getPoints(): Vector2[];
  60901. /**
  60902. * Retreives the point at the distance aways from the starting point
  60903. * @param normalizedLengthPosition the length along the path to retreive the point from
  60904. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  60905. */
  60906. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  60907. /**
  60908. * Creates a new path starting from an x and y position
  60909. * @param x starting x value
  60910. * @param y starting y value
  60911. * @returns a new Path2 starting at the coordinates (x, y).
  60912. */
  60913. static StartingAt(x: number, y: number): Path2;
  60914. }
  60915. /**
  60916. * Represents a 3D path made up of multiple 3D points
  60917. */
  60918. export class Path3D {
  60919. /**
  60920. * an array of Vector3, the curve axis of the Path3D
  60921. */
  60922. path: Vector3[];
  60923. private _curve;
  60924. private _distances;
  60925. private _tangents;
  60926. private _normals;
  60927. private _binormals;
  60928. private _raw;
  60929. /**
  60930. * new Path3D(path, normal, raw)
  60931. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  60932. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  60933. * @param path an array of Vector3, the curve axis of the Path3D
  60934. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  60935. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  60936. */
  60937. constructor(
  60938. /**
  60939. * an array of Vector3, the curve axis of the Path3D
  60940. */
  60941. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  60942. /**
  60943. * Returns the Path3D array of successive Vector3 designing its curve.
  60944. * @returns the Path3D array of successive Vector3 designing its curve.
  60945. */
  60946. getCurve(): Vector3[];
  60947. /**
  60948. * Returns an array populated with tangent vectors on each Path3D curve point.
  60949. * @returns an array populated with tangent vectors on each Path3D curve point.
  60950. */
  60951. getTangents(): Vector3[];
  60952. /**
  60953. * Returns an array populated with normal vectors on each Path3D curve point.
  60954. * @returns an array populated with normal vectors on each Path3D curve point.
  60955. */
  60956. getNormals(): Vector3[];
  60957. /**
  60958. * Returns an array populated with binormal vectors on each Path3D curve point.
  60959. * @returns an array populated with binormal vectors on each Path3D curve point.
  60960. */
  60961. getBinormals(): Vector3[];
  60962. /**
  60963. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  60964. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  60965. */
  60966. getDistances(): number[];
  60967. /**
  60968. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  60969. * @param path path which all values are copied into the curves points
  60970. * @param firstNormal which should be projected onto the curve
  60971. * @returns the same object updated.
  60972. */
  60973. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  60974. private _compute;
  60975. private _getFirstNonNullVector;
  60976. private _getLastNonNullVector;
  60977. private _normalVector;
  60978. }
  60979. /**
  60980. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  60981. * A Curve3 is designed from a series of successive Vector3.
  60982. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  60983. */
  60984. export class Curve3 {
  60985. private _points;
  60986. private _length;
  60987. /**
  60988. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  60989. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  60990. * @param v1 (Vector3) the control point
  60991. * @param v2 (Vector3) the end point of the Quadratic Bezier
  60992. * @param nbPoints (integer) the wanted number of points in the curve
  60993. * @returns the created Curve3
  60994. */
  60995. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  60996. /**
  60997. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  60998. * @param v0 (Vector3) the origin point of the Cubic Bezier
  60999. * @param v1 (Vector3) the first control point
  61000. * @param v2 (Vector3) the second control point
  61001. * @param v3 (Vector3) the end point of the Cubic Bezier
  61002. * @param nbPoints (integer) the wanted number of points in the curve
  61003. * @returns the created Curve3
  61004. */
  61005. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  61006. /**
  61007. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  61008. * @param p1 (Vector3) the origin point of the Hermite Spline
  61009. * @param t1 (Vector3) the tangent vector at the origin point
  61010. * @param p2 (Vector3) the end point of the Hermite Spline
  61011. * @param t2 (Vector3) the tangent vector at the end point
  61012. * @param nbPoints (integer) the wanted number of points in the curve
  61013. * @returns the created Curve3
  61014. */
  61015. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  61016. /**
  61017. * Returns a Curve3 object along a CatmullRom Spline curve :
  61018. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  61019. * @param nbPoints (integer) the wanted number of points between each curve control points
  61020. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  61021. * @returns the created Curve3
  61022. */
  61023. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  61024. /**
  61025. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  61026. * A Curve3 is designed from a series of successive Vector3.
  61027. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  61028. * @param points points which make up the curve
  61029. */
  61030. constructor(points: Vector3[]);
  61031. /**
  61032. * @returns the Curve3 stored array of successive Vector3
  61033. */
  61034. getPoints(): Vector3[];
  61035. /**
  61036. * @returns the computed length (float) of the curve.
  61037. */
  61038. length(): number;
  61039. /**
  61040. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  61041. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  61042. * curveA and curveB keep unchanged.
  61043. * @param curve the curve to continue from this curve
  61044. * @returns the newly constructed curve
  61045. */
  61046. continue(curve: DeepImmutable<Curve3>): Curve3;
  61047. private _computeLength;
  61048. }
  61049. /**
  61050. * Contains position and normal vectors for a vertex
  61051. */
  61052. export class PositionNormalVertex {
  61053. /** the position of the vertex (defaut: 0,0,0) */
  61054. position: Vector3;
  61055. /** the normal of the vertex (defaut: 0,1,0) */
  61056. normal: Vector3;
  61057. /**
  61058. * Creates a PositionNormalVertex
  61059. * @param position the position of the vertex (defaut: 0,0,0)
  61060. * @param normal the normal of the vertex (defaut: 0,1,0)
  61061. */
  61062. constructor(
  61063. /** the position of the vertex (defaut: 0,0,0) */
  61064. position?: Vector3,
  61065. /** the normal of the vertex (defaut: 0,1,0) */
  61066. normal?: Vector3);
  61067. /**
  61068. * Clones the PositionNormalVertex
  61069. * @returns the cloned PositionNormalVertex
  61070. */
  61071. clone(): PositionNormalVertex;
  61072. }
  61073. /**
  61074. * Contains position, normal and uv vectors for a vertex
  61075. */
  61076. export class PositionNormalTextureVertex {
  61077. /** the position of the vertex (defaut: 0,0,0) */
  61078. position: Vector3;
  61079. /** the normal of the vertex (defaut: 0,1,0) */
  61080. normal: Vector3;
  61081. /** the uv of the vertex (default: 0,0) */
  61082. uv: Vector2;
  61083. /**
  61084. * Creates a PositionNormalTextureVertex
  61085. * @param position the position of the vertex (defaut: 0,0,0)
  61086. * @param normal the normal of the vertex (defaut: 0,1,0)
  61087. * @param uv the uv of the vertex (default: 0,0)
  61088. */
  61089. constructor(
  61090. /** the position of the vertex (defaut: 0,0,0) */
  61091. position?: Vector3,
  61092. /** the normal of the vertex (defaut: 0,1,0) */
  61093. normal?: Vector3,
  61094. /** the uv of the vertex (default: 0,0) */
  61095. uv?: Vector2);
  61096. /**
  61097. * Clones the PositionNormalTextureVertex
  61098. * @returns the cloned PositionNormalTextureVertex
  61099. */
  61100. clone(): PositionNormalTextureVertex;
  61101. }
  61102. /**
  61103. * @hidden
  61104. */
  61105. export class Tmp {
  61106. static Color3: Color3[];
  61107. static Color4: Color4[];
  61108. static Vector2: Vector2[];
  61109. static Vector3: Vector3[];
  61110. static Vector4: Vector4[];
  61111. static Quaternion: Quaternion[];
  61112. static Matrix: Matrix[];
  61113. }
  61114. }
  61115. declare module BABYLON {
  61116. /**
  61117. * Class used to enable access to offline support
  61118. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  61119. */
  61120. export interface IOfflineProvider {
  61121. /**
  61122. * Gets a boolean indicating if scene must be saved in the database
  61123. */
  61124. enableSceneOffline: boolean;
  61125. /**
  61126. * Gets a boolean indicating if textures must be saved in the database
  61127. */
  61128. enableTexturesOffline: boolean;
  61129. /**
  61130. * Open the offline support and make it available
  61131. * @param successCallback defines the callback to call on success
  61132. * @param errorCallback defines the callback to call on error
  61133. */
  61134. open(successCallback: () => void, errorCallback: () => void): void;
  61135. /**
  61136. * Loads an image from the offline support
  61137. * @param url defines the url to load from
  61138. * @param image defines the target DOM image
  61139. */
  61140. loadImage(url: string, image: HTMLImageElement): void;
  61141. /**
  61142. * Loads a file from offline support
  61143. * @param url defines the URL to load from
  61144. * @param sceneLoaded defines a callback to call on success
  61145. * @param progressCallBack defines a callback to call when progress changed
  61146. * @param errorCallback defines a callback to call on error
  61147. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  61148. */
  61149. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  61150. }
  61151. }
  61152. declare module BABYLON {
  61153. /**
  61154. * A class serves as a medium between the observable and its observers
  61155. */
  61156. export class EventState {
  61157. /**
  61158. * Create a new EventState
  61159. * @param mask defines the mask associated with this state
  61160. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  61161. * @param target defines the original target of the state
  61162. * @param currentTarget defines the current target of the state
  61163. */
  61164. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  61165. /**
  61166. * Initialize the current event state
  61167. * @param mask defines the mask associated with this state
  61168. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  61169. * @param target defines the original target of the state
  61170. * @param currentTarget defines the current target of the state
  61171. * @returns the current event state
  61172. */
  61173. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  61174. /**
  61175. * An Observer can set this property to true to prevent subsequent observers of being notified
  61176. */
  61177. skipNextObservers: boolean;
  61178. /**
  61179. * Get the mask value that were used to trigger the event corresponding to this EventState object
  61180. */
  61181. mask: number;
  61182. /**
  61183. * The object that originally notified the event
  61184. */
  61185. target?: any;
  61186. /**
  61187. * The current object in the bubbling phase
  61188. */
  61189. currentTarget?: any;
  61190. /**
  61191. * This will be populated with the return value of the last function that was executed.
  61192. * If it is the first function in the callback chain it will be the event data.
  61193. */
  61194. lastReturnValue?: any;
  61195. }
  61196. /**
  61197. * Represent an Observer registered to a given Observable object.
  61198. */
  61199. export class Observer<T> {
  61200. /**
  61201. * Defines the callback to call when the observer is notified
  61202. */
  61203. callback: (eventData: T, eventState: EventState) => void;
  61204. /**
  61205. * Defines the mask of the observer (used to filter notifications)
  61206. */
  61207. mask: number;
  61208. /**
  61209. * Defines the current scope used to restore the JS context
  61210. */
  61211. scope: any;
  61212. /** @hidden */
  61213. _willBeUnregistered: boolean;
  61214. /**
  61215. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  61216. */
  61217. unregisterOnNextCall: boolean;
  61218. /**
  61219. * Creates a new observer
  61220. * @param callback defines the callback to call when the observer is notified
  61221. * @param mask defines the mask of the observer (used to filter notifications)
  61222. * @param scope defines the current scope used to restore the JS context
  61223. */
  61224. constructor(
  61225. /**
  61226. * Defines the callback to call when the observer is notified
  61227. */
  61228. callback: (eventData: T, eventState: EventState) => void,
  61229. /**
  61230. * Defines the mask of the observer (used to filter notifications)
  61231. */
  61232. mask: number,
  61233. /**
  61234. * Defines the current scope used to restore the JS context
  61235. */
  61236. scope?: any);
  61237. }
  61238. /**
  61239. * Represent a list of observers registered to multiple Observables object.
  61240. */
  61241. export class MultiObserver<T> {
  61242. private _observers;
  61243. private _observables;
  61244. /**
  61245. * Release associated resources
  61246. */
  61247. dispose(): void;
  61248. /**
  61249. * Raise a callback when one of the observable will notify
  61250. * @param observables defines a list of observables to watch
  61251. * @param callback defines the callback to call on notification
  61252. * @param mask defines the mask used to filter notifications
  61253. * @param scope defines the current scope used to restore the JS context
  61254. * @returns the new MultiObserver
  61255. */
  61256. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  61257. }
  61258. /**
  61259. * The Observable class is a simple implementation of the Observable pattern.
  61260. *
  61261. * 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.
  61262. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  61263. * 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).
  61264. * 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.
  61265. */
  61266. export class Observable<T> {
  61267. private _observers;
  61268. private _eventState;
  61269. private _onObserverAdded;
  61270. /**
  61271. * Creates a new observable
  61272. * @param onObserverAdded defines a callback to call when a new observer is added
  61273. */
  61274. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  61275. /**
  61276. * Create a new Observer with the specified callback
  61277. * @param callback the callback that will be executed for that Observer
  61278. * @param mask the mask used to filter observers
  61279. * @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.
  61280. * @param scope optional scope for the callback to be called from
  61281. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  61282. * @returns the new observer created for the callback
  61283. */
  61284. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  61285. /**
  61286. * Create a new Observer with the specified callback and unregisters after the next notification
  61287. * @param callback the callback that will be executed for that Observer
  61288. * @returns the new observer created for the callback
  61289. */
  61290. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  61291. /**
  61292. * Remove an Observer from the Observable object
  61293. * @param observer the instance of the Observer to remove
  61294. * @returns false if it doesn't belong to this Observable
  61295. */
  61296. remove(observer: Nullable<Observer<T>>): boolean;
  61297. /**
  61298. * Remove a callback from the Observable object
  61299. * @param callback the callback to remove
  61300. * @param scope optional scope. If used only the callbacks with this scope will be removed
  61301. * @returns false if it doesn't belong to this Observable
  61302. */
  61303. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  61304. private _deferUnregister;
  61305. private _remove;
  61306. /**
  61307. * Notify all Observers by calling their respective callback with the given data
  61308. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  61309. * @param eventData defines the data to send to all observers
  61310. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  61311. * @param target defines the original target of the state
  61312. * @param currentTarget defines the current target of the state
  61313. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  61314. */
  61315. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  61316. /**
  61317. * Calling this will execute each callback, expecting it to be a promise or return a value.
  61318. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  61319. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  61320. * and it is crucial that all callbacks will be executed.
  61321. * The order of the callbacks is kept, callbacks are not executed parallel.
  61322. *
  61323. * @param eventData The data to be sent to each callback
  61324. * @param mask is used to filter observers defaults to -1
  61325. * @param target defines the callback target (see EventState)
  61326. * @param currentTarget defines he current object in the bubbling phase
  61327. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  61328. */
  61329. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  61330. /**
  61331. * Notify a specific observer
  61332. * @param observer defines the observer to notify
  61333. * @param eventData defines the data to be sent to each callback
  61334. * @param mask is used to filter observers defaults to -1
  61335. */
  61336. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  61337. /**
  61338. * Gets a boolean indicating if the observable has at least one observer
  61339. * @returns true is the Observable has at least one Observer registered
  61340. */
  61341. hasObservers(): boolean;
  61342. /**
  61343. * Clear the list of observers
  61344. */
  61345. clear(): void;
  61346. /**
  61347. * Clone the current observable
  61348. * @returns a new observable
  61349. */
  61350. clone(): Observable<T>;
  61351. /**
  61352. * Does this observable handles observer registered with a given mask
  61353. * @param mask defines the mask to be tested
  61354. * @return whether or not one observer registered with the given mask is handeled
  61355. **/
  61356. hasSpecificMask(mask?: number): boolean;
  61357. }
  61358. }
  61359. declare module BABYLON {
  61360. /**
  61361. * Class used to help managing file picking and drag'n'drop
  61362. * File Storage
  61363. */
  61364. export class FilesInputStore {
  61365. /**
  61366. * List of files ready to be loaded
  61367. */
  61368. static FilesToLoad: {
  61369. [key: string]: File;
  61370. };
  61371. }
  61372. }
  61373. declare module BABYLON {
  61374. /** Defines the cross module used constants to avoid circular dependncies */
  61375. export class Constants {
  61376. /** Defines that alpha blending is disabled */
  61377. static readonly ALPHA_DISABLE: number;
  61378. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  61379. static readonly ALPHA_ADD: number;
  61380. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  61381. static readonly ALPHA_COMBINE: number;
  61382. /** Defines that alpha blending to DEST - SRC * DEST */
  61383. static readonly ALPHA_SUBTRACT: number;
  61384. /** Defines that alpha blending to SRC * DEST */
  61385. static readonly ALPHA_MULTIPLY: number;
  61386. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  61387. static readonly ALPHA_MAXIMIZED: number;
  61388. /** Defines that alpha blending to SRC + DEST */
  61389. static readonly ALPHA_ONEONE: number;
  61390. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  61391. static readonly ALPHA_PREMULTIPLIED: number;
  61392. /**
  61393. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  61394. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  61395. */
  61396. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  61397. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  61398. static readonly ALPHA_INTERPOLATE: number;
  61399. /**
  61400. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  61401. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  61402. */
  61403. static readonly ALPHA_SCREENMODE: number;
  61404. /** Defines that the ressource is not delayed*/
  61405. static readonly DELAYLOADSTATE_NONE: number;
  61406. /** Defines that the ressource was successfully delay loaded */
  61407. static readonly DELAYLOADSTATE_LOADED: number;
  61408. /** Defines that the ressource is currently delay loading */
  61409. static readonly DELAYLOADSTATE_LOADING: number;
  61410. /** Defines that the ressource is delayed and has not started loading */
  61411. static readonly DELAYLOADSTATE_NOTLOADED: number;
  61412. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  61413. static readonly NEVER: number;
  61414. /** 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 */
  61415. static readonly ALWAYS: number;
  61416. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  61417. static readonly LESS: number;
  61418. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  61419. static readonly EQUAL: number;
  61420. /** 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 */
  61421. static readonly LEQUAL: number;
  61422. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  61423. static readonly GREATER: number;
  61424. /** 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 */
  61425. static readonly GEQUAL: number;
  61426. /** 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 */
  61427. static readonly NOTEQUAL: number;
  61428. /** Passed to stencilOperation to specify that stencil value must be kept */
  61429. static readonly KEEP: number;
  61430. /** Passed to stencilOperation to specify that stencil value must be replaced */
  61431. static readonly REPLACE: number;
  61432. /** Passed to stencilOperation to specify that stencil value must be incremented */
  61433. static readonly INCR: number;
  61434. /** Passed to stencilOperation to specify that stencil value must be decremented */
  61435. static readonly DECR: number;
  61436. /** Passed to stencilOperation to specify that stencil value must be inverted */
  61437. static readonly INVERT: number;
  61438. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  61439. static readonly INCR_WRAP: number;
  61440. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  61441. static readonly DECR_WRAP: number;
  61442. /** Texture is not repeating outside of 0..1 UVs */
  61443. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  61444. /** Texture is repeating outside of 0..1 UVs */
  61445. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  61446. /** Texture is repeating and mirrored */
  61447. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  61448. /** ALPHA */
  61449. static readonly TEXTUREFORMAT_ALPHA: number;
  61450. /** LUMINANCE */
  61451. static readonly TEXTUREFORMAT_LUMINANCE: number;
  61452. /** LUMINANCE_ALPHA */
  61453. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  61454. /** RGB */
  61455. static readonly TEXTUREFORMAT_RGB: number;
  61456. /** RGBA */
  61457. static readonly TEXTUREFORMAT_RGBA: number;
  61458. /** RED */
  61459. static readonly TEXTUREFORMAT_RED: number;
  61460. /** RED (2nd reference) */
  61461. static readonly TEXTUREFORMAT_R: number;
  61462. /** RG */
  61463. static readonly TEXTUREFORMAT_RG: number;
  61464. /** RED_INTEGER */
  61465. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  61466. /** RED_INTEGER (2nd reference) */
  61467. static readonly TEXTUREFORMAT_R_INTEGER: number;
  61468. /** RG_INTEGER */
  61469. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  61470. /** RGB_INTEGER */
  61471. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  61472. /** RGBA_INTEGER */
  61473. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  61474. /** UNSIGNED_BYTE */
  61475. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  61476. /** UNSIGNED_BYTE (2nd reference) */
  61477. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  61478. /** FLOAT */
  61479. static readonly TEXTURETYPE_FLOAT: number;
  61480. /** HALF_FLOAT */
  61481. static readonly TEXTURETYPE_HALF_FLOAT: number;
  61482. /** BYTE */
  61483. static readonly TEXTURETYPE_BYTE: number;
  61484. /** SHORT */
  61485. static readonly TEXTURETYPE_SHORT: number;
  61486. /** UNSIGNED_SHORT */
  61487. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  61488. /** INT */
  61489. static readonly TEXTURETYPE_INT: number;
  61490. /** UNSIGNED_INT */
  61491. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  61492. /** UNSIGNED_SHORT_4_4_4_4 */
  61493. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  61494. /** UNSIGNED_SHORT_5_5_5_1 */
  61495. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  61496. /** UNSIGNED_SHORT_5_6_5 */
  61497. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  61498. /** UNSIGNED_INT_2_10_10_10_REV */
  61499. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  61500. /** UNSIGNED_INT_24_8 */
  61501. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  61502. /** UNSIGNED_INT_10F_11F_11F_REV */
  61503. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  61504. /** UNSIGNED_INT_5_9_9_9_REV */
  61505. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  61506. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  61507. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  61508. /** nearest is mag = nearest and min = nearest and mip = linear */
  61509. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  61510. /** Bilinear is mag = linear and min = linear and mip = nearest */
  61511. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  61512. /** Trilinear is mag = linear and min = linear and mip = linear */
  61513. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  61514. /** nearest is mag = nearest and min = nearest and mip = linear */
  61515. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  61516. /** Bilinear is mag = linear and min = linear and mip = nearest */
  61517. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  61518. /** Trilinear is mag = linear and min = linear and mip = linear */
  61519. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  61520. /** mag = nearest and min = nearest and mip = nearest */
  61521. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  61522. /** mag = nearest and min = linear and mip = nearest */
  61523. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  61524. /** mag = nearest and min = linear and mip = linear */
  61525. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  61526. /** mag = nearest and min = linear and mip = none */
  61527. static readonly TEXTURE_NEAREST_LINEAR: number;
  61528. /** mag = nearest and min = nearest and mip = none */
  61529. static readonly TEXTURE_NEAREST_NEAREST: number;
  61530. /** mag = linear and min = nearest and mip = nearest */
  61531. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  61532. /** mag = linear and min = nearest and mip = linear */
  61533. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  61534. /** mag = linear and min = linear and mip = none */
  61535. static readonly TEXTURE_LINEAR_LINEAR: number;
  61536. /** mag = linear and min = nearest and mip = none */
  61537. static readonly TEXTURE_LINEAR_NEAREST: number;
  61538. /** Explicit coordinates mode */
  61539. static readonly TEXTURE_EXPLICIT_MODE: number;
  61540. /** Spherical coordinates mode */
  61541. static readonly TEXTURE_SPHERICAL_MODE: number;
  61542. /** Planar coordinates mode */
  61543. static readonly TEXTURE_PLANAR_MODE: number;
  61544. /** Cubic coordinates mode */
  61545. static readonly TEXTURE_CUBIC_MODE: number;
  61546. /** Projection coordinates mode */
  61547. static readonly TEXTURE_PROJECTION_MODE: number;
  61548. /** Skybox coordinates mode */
  61549. static readonly TEXTURE_SKYBOX_MODE: number;
  61550. /** Inverse Cubic coordinates mode */
  61551. static readonly TEXTURE_INVCUBIC_MODE: number;
  61552. /** Equirectangular coordinates mode */
  61553. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  61554. /** Equirectangular Fixed coordinates mode */
  61555. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  61556. /** Equirectangular Fixed Mirrored coordinates mode */
  61557. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  61558. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  61559. static readonly SCALEMODE_FLOOR: number;
  61560. /** Defines that texture rescaling will look for the nearest power of 2 size */
  61561. static readonly SCALEMODE_NEAREST: number;
  61562. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  61563. static readonly SCALEMODE_CEILING: number;
  61564. /**
  61565. * The dirty texture flag value
  61566. */
  61567. static readonly MATERIAL_TextureDirtyFlag: number;
  61568. /**
  61569. * The dirty light flag value
  61570. */
  61571. static readonly MATERIAL_LightDirtyFlag: number;
  61572. /**
  61573. * The dirty fresnel flag value
  61574. */
  61575. static readonly MATERIAL_FresnelDirtyFlag: number;
  61576. /**
  61577. * The dirty attribute flag value
  61578. */
  61579. static readonly MATERIAL_AttributesDirtyFlag: number;
  61580. /**
  61581. * The dirty misc flag value
  61582. */
  61583. static readonly MATERIAL_MiscDirtyFlag: number;
  61584. /**
  61585. * The all dirty flag value
  61586. */
  61587. static readonly MATERIAL_AllDirtyFlag: number;
  61588. /**
  61589. * Returns the triangle fill mode
  61590. */
  61591. static readonly MATERIAL_TriangleFillMode: number;
  61592. /**
  61593. * Returns the wireframe mode
  61594. */
  61595. static readonly MATERIAL_WireFrameFillMode: number;
  61596. /**
  61597. * Returns the point fill mode
  61598. */
  61599. static readonly MATERIAL_PointFillMode: number;
  61600. /**
  61601. * Returns the point list draw mode
  61602. */
  61603. static readonly MATERIAL_PointListDrawMode: number;
  61604. /**
  61605. * Returns the line list draw mode
  61606. */
  61607. static readonly MATERIAL_LineListDrawMode: number;
  61608. /**
  61609. * Returns the line loop draw mode
  61610. */
  61611. static readonly MATERIAL_LineLoopDrawMode: number;
  61612. /**
  61613. * Returns the line strip draw mode
  61614. */
  61615. static readonly MATERIAL_LineStripDrawMode: number;
  61616. /**
  61617. * Returns the triangle strip draw mode
  61618. */
  61619. static readonly MATERIAL_TriangleStripDrawMode: number;
  61620. /**
  61621. * Returns the triangle fan draw mode
  61622. */
  61623. static readonly MATERIAL_TriangleFanDrawMode: number;
  61624. /**
  61625. * Stores the clock-wise side orientation
  61626. */
  61627. static readonly MATERIAL_ClockWiseSideOrientation: number;
  61628. /**
  61629. * Stores the counter clock-wise side orientation
  61630. */
  61631. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  61632. /**
  61633. * Nothing
  61634. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61635. */
  61636. static readonly ACTION_NothingTrigger: number;
  61637. /**
  61638. * On pick
  61639. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61640. */
  61641. static readonly ACTION_OnPickTrigger: number;
  61642. /**
  61643. * On left pick
  61644. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61645. */
  61646. static readonly ACTION_OnLeftPickTrigger: number;
  61647. /**
  61648. * On right pick
  61649. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61650. */
  61651. static readonly ACTION_OnRightPickTrigger: number;
  61652. /**
  61653. * On center pick
  61654. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61655. */
  61656. static readonly ACTION_OnCenterPickTrigger: number;
  61657. /**
  61658. * On pick down
  61659. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61660. */
  61661. static readonly ACTION_OnPickDownTrigger: number;
  61662. /**
  61663. * On double pick
  61664. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61665. */
  61666. static readonly ACTION_OnDoublePickTrigger: number;
  61667. /**
  61668. * On pick up
  61669. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61670. */
  61671. static readonly ACTION_OnPickUpTrigger: number;
  61672. /**
  61673. * On pick out.
  61674. * This trigger will only be raised if you also declared a OnPickDown
  61675. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61676. */
  61677. static readonly ACTION_OnPickOutTrigger: number;
  61678. /**
  61679. * On long press
  61680. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61681. */
  61682. static readonly ACTION_OnLongPressTrigger: number;
  61683. /**
  61684. * On pointer over
  61685. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61686. */
  61687. static readonly ACTION_OnPointerOverTrigger: number;
  61688. /**
  61689. * On pointer out
  61690. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61691. */
  61692. static readonly ACTION_OnPointerOutTrigger: number;
  61693. /**
  61694. * On every frame
  61695. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61696. */
  61697. static readonly ACTION_OnEveryFrameTrigger: number;
  61698. /**
  61699. * On intersection enter
  61700. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61701. */
  61702. static readonly ACTION_OnIntersectionEnterTrigger: number;
  61703. /**
  61704. * On intersection exit
  61705. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61706. */
  61707. static readonly ACTION_OnIntersectionExitTrigger: number;
  61708. /**
  61709. * On key down
  61710. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61711. */
  61712. static readonly ACTION_OnKeyDownTrigger: number;
  61713. /**
  61714. * On key up
  61715. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61716. */
  61717. static readonly ACTION_OnKeyUpTrigger: number;
  61718. /**
  61719. * Billboard mode will only apply to Y axis
  61720. */
  61721. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  61722. /**
  61723. * Billboard mode will apply to all axes
  61724. */
  61725. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  61726. /**
  61727. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  61728. */
  61729. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  61730. /**
  61731. * Gets or sets base Assets URL
  61732. */
  61733. static readonly PARTICLES_BaseAssetsUrl: string;
  61734. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  61735. * Test order :
  61736. * Is the bounding sphere outside the frustum ?
  61737. * If not, are the bounding box vertices outside the frustum ?
  61738. * It not, then the cullable object is in the frustum.
  61739. */
  61740. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  61741. /** Culling strategy : Bounding Sphere Only.
  61742. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  61743. * It's also less accurate than the standard because some not visible objects can still be selected.
  61744. * Test : is the bounding sphere outside the frustum ?
  61745. * If not, then the cullable object is in the frustum.
  61746. */
  61747. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  61748. /** Culling strategy : Optimistic Inclusion.
  61749. * This in an inclusion test first, then the standard exclusion test.
  61750. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  61751. * 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.
  61752. * Anyway, it's as accurate as the standard strategy.
  61753. * Test :
  61754. * Is the cullable object bounding sphere center in the frustum ?
  61755. * If not, apply the default culling strategy.
  61756. */
  61757. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  61758. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  61759. * This in an inclusion test first, then the bounding sphere only exclusion test.
  61760. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  61761. * 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.
  61762. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  61763. * Test :
  61764. * Is the cullable object bounding sphere center in the frustum ?
  61765. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  61766. */
  61767. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  61768. /**
  61769. * No logging while loading
  61770. */
  61771. static readonly SCENELOADER_NO_LOGGING: number;
  61772. /**
  61773. * Minimal logging while loading
  61774. */
  61775. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  61776. /**
  61777. * Summary logging while loading
  61778. */
  61779. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  61780. /**
  61781. * Detailled logging while loading
  61782. */
  61783. static readonly SCENELOADER_DETAILED_LOGGING: number;
  61784. }
  61785. }
  61786. declare module BABYLON {
  61787. /**
  61788. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  61789. * Babylon.js
  61790. */
  61791. export class DomManagement {
  61792. /**
  61793. * Checks if the window object exists
  61794. * @returns true if the window object exists
  61795. */
  61796. static IsWindowObjectExist(): boolean;
  61797. /**
  61798. * Extracts text content from a DOM element hierarchy
  61799. * @param element defines the root element
  61800. * @returns a string
  61801. */
  61802. static GetDOMTextContent(element: HTMLElement): string;
  61803. }
  61804. }
  61805. declare module BABYLON {
  61806. /**
  61807. * Logger used througouht the application to allow configuration of
  61808. * the log level required for the messages.
  61809. */
  61810. export class Logger {
  61811. /**
  61812. * No log
  61813. */
  61814. static readonly NoneLogLevel: number;
  61815. /**
  61816. * Only message logs
  61817. */
  61818. static readonly MessageLogLevel: number;
  61819. /**
  61820. * Only warning logs
  61821. */
  61822. static readonly WarningLogLevel: number;
  61823. /**
  61824. * Only error logs
  61825. */
  61826. static readonly ErrorLogLevel: number;
  61827. /**
  61828. * All logs
  61829. */
  61830. static readonly AllLogLevel: number;
  61831. private static _LogCache;
  61832. /**
  61833. * Gets a value indicating the number of loading errors
  61834. * @ignorenaming
  61835. */
  61836. static errorsCount: number;
  61837. /**
  61838. * Callback called when a new log is added
  61839. */
  61840. static OnNewCacheEntry: (entry: string) => void;
  61841. private static _AddLogEntry;
  61842. private static _FormatMessage;
  61843. private static _LogDisabled;
  61844. private static _LogEnabled;
  61845. private static _WarnDisabled;
  61846. private static _WarnEnabled;
  61847. private static _ErrorDisabled;
  61848. private static _ErrorEnabled;
  61849. /**
  61850. * Log a message to the console
  61851. */
  61852. static Log: (message: string) => void;
  61853. /**
  61854. * Write a warning message to the console
  61855. */
  61856. static Warn: (message: string) => void;
  61857. /**
  61858. * Write an error message to the console
  61859. */
  61860. static Error: (message: string) => void;
  61861. /**
  61862. * Gets current log cache (list of logs)
  61863. */
  61864. static readonly LogCache: string;
  61865. /**
  61866. * Clears the log cache
  61867. */
  61868. static ClearLogCache(): void;
  61869. /**
  61870. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  61871. */
  61872. static LogLevels: number;
  61873. }
  61874. }
  61875. declare module BABYLON {
  61876. /** @hidden */
  61877. export class _TypeStore {
  61878. /** @hidden */
  61879. static RegisteredTypes: {
  61880. [key: string]: Object;
  61881. };
  61882. /** @hidden */
  61883. static GetClass(fqdn: string): any;
  61884. }
  61885. }
  61886. declare module BABYLON {
  61887. /**
  61888. * Class containing a set of static utilities functions for deep copy.
  61889. */
  61890. export class DeepCopier {
  61891. /**
  61892. * Tries to copy an object by duplicating every property
  61893. * @param source defines the source object
  61894. * @param destination defines the target object
  61895. * @param doNotCopyList defines a list of properties to avoid
  61896. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  61897. */
  61898. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  61899. }
  61900. }
  61901. declare module BABYLON {
  61902. /**
  61903. * Class containing a set of static utilities functions for precision date
  61904. */
  61905. export class PrecisionDate {
  61906. /**
  61907. * Gets either window.performance.now() if supported or Date.now() else
  61908. */
  61909. static readonly Now: number;
  61910. }
  61911. }
  61912. declare module BABYLON {
  61913. /** @hidden */
  61914. export class _DevTools {
  61915. static WarnImport(name: string): string;
  61916. }
  61917. }
  61918. declare module BABYLON {
  61919. /**
  61920. * Class used to evalaute queries containing `and` and `or` operators
  61921. */
  61922. export class AndOrNotEvaluator {
  61923. /**
  61924. * Evaluate a query
  61925. * @param query defines the query to evaluate
  61926. * @param evaluateCallback defines the callback used to filter result
  61927. * @returns true if the query matches
  61928. */
  61929. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  61930. private static _HandleParenthesisContent;
  61931. private static _SimplifyNegation;
  61932. }
  61933. }
  61934. declare module BABYLON {
  61935. /**
  61936. * Class used to store custom tags
  61937. */
  61938. export class Tags {
  61939. /**
  61940. * Adds support for tags on the given object
  61941. * @param obj defines the object to use
  61942. */
  61943. static EnableFor(obj: any): void;
  61944. /**
  61945. * Removes tags support
  61946. * @param obj defines the object to use
  61947. */
  61948. static DisableFor(obj: any): void;
  61949. /**
  61950. * Gets a boolean indicating if the given object has tags
  61951. * @param obj defines the object to use
  61952. * @returns a boolean
  61953. */
  61954. static HasTags(obj: any): boolean;
  61955. /**
  61956. * Gets the tags available on a given object
  61957. * @param obj defines the object to use
  61958. * @param asString defines if the tags must be returned as a string instead of an array of strings
  61959. * @returns the tags
  61960. */
  61961. static GetTags(obj: any, asString?: boolean): any;
  61962. /**
  61963. * Adds tags to an object
  61964. * @param obj defines the object to use
  61965. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  61966. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  61967. */
  61968. static AddTagsTo(obj: any, tagsString: string): void;
  61969. /**
  61970. * @hidden
  61971. */
  61972. static _AddTagTo(obj: any, tag: string): void;
  61973. /**
  61974. * Removes specific tags from a specific object
  61975. * @param obj defines the object to use
  61976. * @param tagsString defines the tags to remove
  61977. */
  61978. static RemoveTagsFrom(obj: any, tagsString: string): void;
  61979. /**
  61980. * @hidden
  61981. */
  61982. static _RemoveTagFrom(obj: any, tag: string): void;
  61983. /**
  61984. * Defines if tags hosted on an object match a given query
  61985. * @param obj defines the object to use
  61986. * @param tagsQuery defines the tag query
  61987. * @returns a boolean
  61988. */
  61989. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  61990. }
  61991. }
  61992. declare module BABYLON {
  61993. /**
  61994. * Manages the defines for the Material
  61995. */
  61996. export class MaterialDefines {
  61997. private _keys;
  61998. private _isDirty;
  61999. /** @hidden */
  62000. _renderId: number;
  62001. /** @hidden */
  62002. _areLightsDirty: boolean;
  62003. /** @hidden */
  62004. _areAttributesDirty: boolean;
  62005. /** @hidden */
  62006. _areTexturesDirty: boolean;
  62007. /** @hidden */
  62008. _areFresnelDirty: boolean;
  62009. /** @hidden */
  62010. _areMiscDirty: boolean;
  62011. /** @hidden */
  62012. _areImageProcessingDirty: boolean;
  62013. /** @hidden */
  62014. _normals: boolean;
  62015. /** @hidden */
  62016. _uvs: boolean;
  62017. /** @hidden */
  62018. _needNormals: boolean;
  62019. /** @hidden */
  62020. _needUVs: boolean;
  62021. /**
  62022. * Specifies if the material needs to be re-calculated
  62023. */
  62024. readonly isDirty: boolean;
  62025. /**
  62026. * Marks the material to indicate that it has been re-calculated
  62027. */
  62028. markAsProcessed(): void;
  62029. /**
  62030. * Marks the material to indicate that it needs to be re-calculated
  62031. */
  62032. markAsUnprocessed(): void;
  62033. /**
  62034. * Marks the material to indicate all of its defines need to be re-calculated
  62035. */
  62036. markAllAsDirty(): void;
  62037. /**
  62038. * Marks the material to indicate that image processing needs to be re-calculated
  62039. */
  62040. markAsImageProcessingDirty(): void;
  62041. /**
  62042. * Marks the material to indicate the lights need to be re-calculated
  62043. */
  62044. markAsLightDirty(): void;
  62045. /**
  62046. * Marks the attribute state as changed
  62047. */
  62048. markAsAttributesDirty(): void;
  62049. /**
  62050. * Marks the texture state as changed
  62051. */
  62052. markAsTexturesDirty(): void;
  62053. /**
  62054. * Marks the fresnel state as changed
  62055. */
  62056. markAsFresnelDirty(): void;
  62057. /**
  62058. * Marks the misc state as changed
  62059. */
  62060. markAsMiscDirty(): void;
  62061. /**
  62062. * Rebuilds the material defines
  62063. */
  62064. rebuild(): void;
  62065. /**
  62066. * Specifies if two material defines are equal
  62067. * @param other - A material define instance to compare to
  62068. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  62069. */
  62070. isEqual(other: MaterialDefines): boolean;
  62071. /**
  62072. * Clones this instance's defines to another instance
  62073. * @param other - material defines to clone values to
  62074. */
  62075. cloneTo(other: MaterialDefines): void;
  62076. /**
  62077. * Resets the material define values
  62078. */
  62079. reset(): void;
  62080. /**
  62081. * Converts the material define values to a string
  62082. * @returns - String of material define information
  62083. */
  62084. toString(): string;
  62085. }
  62086. }
  62087. declare module BABYLON {
  62088. /**
  62089. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  62090. */
  62091. export class PerformanceMonitor {
  62092. private _enabled;
  62093. private _rollingFrameTime;
  62094. private _lastFrameTimeMs;
  62095. /**
  62096. * constructor
  62097. * @param frameSampleSize The number of samples required to saturate the sliding window
  62098. */
  62099. constructor(frameSampleSize?: number);
  62100. /**
  62101. * Samples current frame
  62102. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  62103. */
  62104. sampleFrame(timeMs?: number): void;
  62105. /**
  62106. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  62107. */
  62108. readonly averageFrameTime: number;
  62109. /**
  62110. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  62111. */
  62112. readonly averageFrameTimeVariance: number;
  62113. /**
  62114. * Returns the frame time of the most recent frame
  62115. */
  62116. readonly instantaneousFrameTime: number;
  62117. /**
  62118. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  62119. */
  62120. readonly averageFPS: number;
  62121. /**
  62122. * Returns the average framerate in frames per second using the most recent frame time
  62123. */
  62124. readonly instantaneousFPS: number;
  62125. /**
  62126. * Returns true if enough samples have been taken to completely fill the sliding window
  62127. */
  62128. readonly isSaturated: boolean;
  62129. /**
  62130. * Enables contributions to the sliding window sample set
  62131. */
  62132. enable(): void;
  62133. /**
  62134. * Disables contributions to the sliding window sample set
  62135. * Samples will not be interpolated over the disabled period
  62136. */
  62137. disable(): void;
  62138. /**
  62139. * Returns true if sampling is enabled
  62140. */
  62141. readonly isEnabled: boolean;
  62142. /**
  62143. * Resets performance monitor
  62144. */
  62145. reset(): void;
  62146. }
  62147. /**
  62148. * RollingAverage
  62149. *
  62150. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  62151. */
  62152. export class RollingAverage {
  62153. /**
  62154. * Current average
  62155. */
  62156. average: number;
  62157. /**
  62158. * Current variance
  62159. */
  62160. variance: number;
  62161. protected _samples: Array<number>;
  62162. protected _sampleCount: number;
  62163. protected _pos: number;
  62164. protected _m2: number;
  62165. /**
  62166. * constructor
  62167. * @param length The number of samples required to saturate the sliding window
  62168. */
  62169. constructor(length: number);
  62170. /**
  62171. * Adds a sample to the sample set
  62172. * @param v The sample value
  62173. */
  62174. add(v: number): void;
  62175. /**
  62176. * Returns previously added values or null if outside of history or outside the sliding window domain
  62177. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  62178. * @return Value previously recorded with add() or null if outside of range
  62179. */
  62180. history(i: number): number;
  62181. /**
  62182. * Returns true if enough samples have been taken to completely fill the sliding window
  62183. * @return true if sample-set saturated
  62184. */
  62185. isSaturated(): boolean;
  62186. /**
  62187. * Resets the rolling average (equivalent to 0 samples taken so far)
  62188. */
  62189. reset(): void;
  62190. /**
  62191. * Wraps a value around the sample range boundaries
  62192. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  62193. * @return Wrapped position in sample range
  62194. */
  62195. protected _wrapPosition(i: number): number;
  62196. }
  62197. }
  62198. declare module BABYLON {
  62199. /**
  62200. * This class implement a typical dictionary using a string as key and the generic type T as value.
  62201. * The underlying implementation relies on an associative array to ensure the best performances.
  62202. * The value can be anything including 'null' but except 'undefined'
  62203. */
  62204. export class StringDictionary<T> {
  62205. /**
  62206. * This will clear this dictionary and copy the content from the 'source' one.
  62207. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  62208. * @param source the dictionary to take the content from and copy to this dictionary
  62209. */
  62210. copyFrom(source: StringDictionary<T>): void;
  62211. /**
  62212. * Get a value based from its key
  62213. * @param key the given key to get the matching value from
  62214. * @return the value if found, otherwise undefined is returned
  62215. */
  62216. get(key: string): T | undefined;
  62217. /**
  62218. * Get a value from its key or add it if it doesn't exist.
  62219. * This method will ensure you that a given key/data will be present in the dictionary.
  62220. * @param key the given key to get the matching value from
  62221. * @param factory the factory that will create the value if the key is not present in the dictionary.
  62222. * The factory will only be invoked if there's no data for the given key.
  62223. * @return the value corresponding to the key.
  62224. */
  62225. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  62226. /**
  62227. * Get a value from its key if present in the dictionary otherwise add it
  62228. * @param key the key to get the value from
  62229. * @param val if there's no such key/value pair in the dictionary add it with this value
  62230. * @return the value corresponding to the key
  62231. */
  62232. getOrAdd(key: string, val: T): T;
  62233. /**
  62234. * Check if there's a given key in the dictionary
  62235. * @param key the key to check for
  62236. * @return true if the key is present, false otherwise
  62237. */
  62238. contains(key: string): boolean;
  62239. /**
  62240. * Add a new key and its corresponding value
  62241. * @param key the key to add
  62242. * @param value the value corresponding to the key
  62243. * @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
  62244. */
  62245. add(key: string, value: T): boolean;
  62246. /**
  62247. * Update a specific value associated to a key
  62248. * @param key defines the key to use
  62249. * @param value defines the value to store
  62250. * @returns true if the value was updated (or false if the key was not found)
  62251. */
  62252. set(key: string, value: T): boolean;
  62253. /**
  62254. * Get the element of the given key and remove it from the dictionary
  62255. * @param key defines the key to search
  62256. * @returns the value associated with the key or null if not found
  62257. */
  62258. getAndRemove(key: string): Nullable<T>;
  62259. /**
  62260. * Remove a key/value from the dictionary.
  62261. * @param key the key to remove
  62262. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  62263. */
  62264. remove(key: string): boolean;
  62265. /**
  62266. * Clear the whole content of the dictionary
  62267. */
  62268. clear(): void;
  62269. /**
  62270. * Gets the current count
  62271. */
  62272. readonly count: number;
  62273. /**
  62274. * Execute a callback on each key/val of the dictionary.
  62275. * Note that you can remove any element in this dictionary in the callback implementation
  62276. * @param callback the callback to execute on a given key/value pair
  62277. */
  62278. forEach(callback: (key: string, val: T) => void): void;
  62279. /**
  62280. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  62281. * If the callback returns null or undefined the method will iterate to the next key/value pair
  62282. * Note that you can remove any element in this dictionary in the callback implementation
  62283. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  62284. * @returns the first item
  62285. */
  62286. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  62287. private _count;
  62288. private _data;
  62289. }
  62290. }
  62291. declare module BABYLON {
  62292. /**
  62293. * Helper class that provides a small promise polyfill
  62294. */
  62295. export class PromisePolyfill {
  62296. /**
  62297. * Static function used to check if the polyfill is required
  62298. * If this is the case then the function will inject the polyfill to window.Promise
  62299. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  62300. */
  62301. static Apply(force?: boolean): void;
  62302. }
  62303. }
  62304. declare module BABYLON {
  62305. /**
  62306. * Class used to store data that will be store in GPU memory
  62307. */
  62308. export class Buffer {
  62309. private _engine;
  62310. private _buffer;
  62311. /** @hidden */
  62312. _data: Nullable<DataArray>;
  62313. private _updatable;
  62314. private _instanced;
  62315. /**
  62316. * Gets the byte stride.
  62317. */
  62318. readonly byteStride: number;
  62319. /**
  62320. * Constructor
  62321. * @param engine the engine
  62322. * @param data the data to use for this buffer
  62323. * @param updatable whether the data is updatable
  62324. * @param stride the stride (optional)
  62325. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  62326. * @param instanced whether the buffer is instanced (optional)
  62327. * @param useBytes set to true if the stride in in bytes (optional)
  62328. */
  62329. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  62330. /**
  62331. * Create a new VertexBuffer based on the current buffer
  62332. * @param kind defines the vertex buffer kind (position, normal, etc.)
  62333. * @param offset defines offset in the buffer (0 by default)
  62334. * @param size defines the size in floats of attributes (position is 3 for instance)
  62335. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  62336. * @param instanced defines if the vertex buffer contains indexed data
  62337. * @param useBytes defines if the offset and stride are in bytes
  62338. * @returns the new vertex buffer
  62339. */
  62340. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  62341. /**
  62342. * Gets a boolean indicating if the Buffer is updatable?
  62343. * @returns true if the buffer is updatable
  62344. */
  62345. isUpdatable(): boolean;
  62346. /**
  62347. * Gets current buffer's data
  62348. * @returns a DataArray or null
  62349. */
  62350. getData(): Nullable<DataArray>;
  62351. /**
  62352. * Gets underlying native buffer
  62353. * @returns underlying native buffer
  62354. */
  62355. getBuffer(): Nullable<WebGLBuffer>;
  62356. /**
  62357. * Gets the stride in float32 units (i.e. byte stride / 4).
  62358. * May not be an integer if the byte stride is not divisible by 4.
  62359. * DEPRECATED. Use byteStride instead.
  62360. * @returns the stride in float32 units
  62361. */
  62362. getStrideSize(): number;
  62363. /**
  62364. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  62365. * @param data defines the data to store
  62366. */
  62367. create(data?: Nullable<DataArray>): void;
  62368. /** @hidden */
  62369. _rebuild(): void;
  62370. /**
  62371. * Update current buffer data
  62372. * @param data defines the data to store
  62373. */
  62374. update(data: DataArray): void;
  62375. /**
  62376. * Updates the data directly.
  62377. * @param data the new data
  62378. * @param offset the new offset
  62379. * @param vertexCount the vertex count (optional)
  62380. * @param useBytes set to true if the offset is in bytes
  62381. */
  62382. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  62383. /**
  62384. * Release all resources
  62385. */
  62386. dispose(): void;
  62387. }
  62388. /**
  62389. * Specialized buffer used to store vertex data
  62390. */
  62391. export class VertexBuffer {
  62392. /** @hidden */
  62393. _buffer: Buffer;
  62394. private _kind;
  62395. private _size;
  62396. private _ownsBuffer;
  62397. private _instanced;
  62398. private _instanceDivisor;
  62399. /**
  62400. * The byte type.
  62401. */
  62402. static readonly BYTE: number;
  62403. /**
  62404. * The unsigned byte type.
  62405. */
  62406. static readonly UNSIGNED_BYTE: number;
  62407. /**
  62408. * The short type.
  62409. */
  62410. static readonly SHORT: number;
  62411. /**
  62412. * The unsigned short type.
  62413. */
  62414. static readonly UNSIGNED_SHORT: number;
  62415. /**
  62416. * The integer type.
  62417. */
  62418. static readonly INT: number;
  62419. /**
  62420. * The unsigned integer type.
  62421. */
  62422. static readonly UNSIGNED_INT: number;
  62423. /**
  62424. * The float type.
  62425. */
  62426. static readonly FLOAT: number;
  62427. /**
  62428. * Gets or sets the instance divisor when in instanced mode
  62429. */
  62430. instanceDivisor: number;
  62431. /**
  62432. * Gets the byte stride.
  62433. */
  62434. readonly byteStride: number;
  62435. /**
  62436. * Gets the byte offset.
  62437. */
  62438. readonly byteOffset: number;
  62439. /**
  62440. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  62441. */
  62442. readonly normalized: boolean;
  62443. /**
  62444. * Gets the data type of each component in the array.
  62445. */
  62446. readonly type: number;
  62447. /**
  62448. * Constructor
  62449. * @param engine the engine
  62450. * @param data the data to use for this vertex buffer
  62451. * @param kind the vertex buffer kind
  62452. * @param updatable whether the data is updatable
  62453. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  62454. * @param stride the stride (optional)
  62455. * @param instanced whether the buffer is instanced (optional)
  62456. * @param offset the offset of the data (optional)
  62457. * @param size the number of components (optional)
  62458. * @param type the type of the component (optional)
  62459. * @param normalized whether the data contains normalized data (optional)
  62460. * @param useBytes set to true if stride and offset are in bytes (optional)
  62461. */
  62462. 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);
  62463. /** @hidden */
  62464. _rebuild(): void;
  62465. /**
  62466. * Returns the kind of the VertexBuffer (string)
  62467. * @returns a string
  62468. */
  62469. getKind(): string;
  62470. /**
  62471. * Gets a boolean indicating if the VertexBuffer is updatable?
  62472. * @returns true if the buffer is updatable
  62473. */
  62474. isUpdatable(): boolean;
  62475. /**
  62476. * Gets current buffer's data
  62477. * @returns a DataArray or null
  62478. */
  62479. getData(): Nullable<DataArray>;
  62480. /**
  62481. * Gets underlying native buffer
  62482. * @returns underlying native buffer
  62483. */
  62484. getBuffer(): Nullable<WebGLBuffer>;
  62485. /**
  62486. * Gets the stride in float32 units (i.e. byte stride / 4).
  62487. * May not be an integer if the byte stride is not divisible by 4.
  62488. * DEPRECATED. Use byteStride instead.
  62489. * @returns the stride in float32 units
  62490. */
  62491. getStrideSize(): number;
  62492. /**
  62493. * Returns the offset as a multiple of the type byte length.
  62494. * DEPRECATED. Use byteOffset instead.
  62495. * @returns the offset in bytes
  62496. */
  62497. getOffset(): number;
  62498. /**
  62499. * Returns the number of components per vertex attribute (integer)
  62500. * @returns the size in float
  62501. */
  62502. getSize(): number;
  62503. /**
  62504. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  62505. * @returns true if this buffer is instanced
  62506. */
  62507. getIsInstanced(): boolean;
  62508. /**
  62509. * Returns the instancing divisor, zero for non-instanced (integer).
  62510. * @returns a number
  62511. */
  62512. getInstanceDivisor(): number;
  62513. /**
  62514. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  62515. * @param data defines the data to store
  62516. */
  62517. create(data?: DataArray): void;
  62518. /**
  62519. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  62520. * This function will create a new buffer if the current one is not updatable
  62521. * @param data defines the data to store
  62522. */
  62523. update(data: DataArray): void;
  62524. /**
  62525. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  62526. * Returns the directly updated WebGLBuffer.
  62527. * @param data the new data
  62528. * @param offset the new offset
  62529. * @param useBytes set to true if the offset is in bytes
  62530. */
  62531. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  62532. /**
  62533. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  62534. */
  62535. dispose(): void;
  62536. /**
  62537. * Enumerates each value of this vertex buffer as numbers.
  62538. * @param count the number of values to enumerate
  62539. * @param callback the callback function called for each value
  62540. */
  62541. forEach(count: number, callback: (value: number, index: number) => void): void;
  62542. /**
  62543. * Positions
  62544. */
  62545. static readonly PositionKind: string;
  62546. /**
  62547. * Normals
  62548. */
  62549. static readonly NormalKind: string;
  62550. /**
  62551. * Tangents
  62552. */
  62553. static readonly TangentKind: string;
  62554. /**
  62555. * Texture coordinates
  62556. */
  62557. static readonly UVKind: string;
  62558. /**
  62559. * Texture coordinates 2
  62560. */
  62561. static readonly UV2Kind: string;
  62562. /**
  62563. * Texture coordinates 3
  62564. */
  62565. static readonly UV3Kind: string;
  62566. /**
  62567. * Texture coordinates 4
  62568. */
  62569. static readonly UV4Kind: string;
  62570. /**
  62571. * Texture coordinates 5
  62572. */
  62573. static readonly UV5Kind: string;
  62574. /**
  62575. * Texture coordinates 6
  62576. */
  62577. static readonly UV6Kind: string;
  62578. /**
  62579. * Colors
  62580. */
  62581. static readonly ColorKind: string;
  62582. /**
  62583. * Matrix indices (for bones)
  62584. */
  62585. static readonly MatricesIndicesKind: string;
  62586. /**
  62587. * Matrix weights (for bones)
  62588. */
  62589. static readonly MatricesWeightsKind: string;
  62590. /**
  62591. * Additional matrix indices (for bones)
  62592. */
  62593. static readonly MatricesIndicesExtraKind: string;
  62594. /**
  62595. * Additional matrix weights (for bones)
  62596. */
  62597. static readonly MatricesWeightsExtraKind: string;
  62598. /**
  62599. * Deduces the stride given a kind.
  62600. * @param kind The kind string to deduce
  62601. * @returns The deduced stride
  62602. */
  62603. static DeduceStride(kind: string): number;
  62604. /**
  62605. * Gets the byte length of the given type.
  62606. * @param type the type
  62607. * @returns the number of bytes
  62608. */
  62609. static GetTypeByteLength(type: number): number;
  62610. /**
  62611. * Enumerates each value of the given parameters as numbers.
  62612. * @param data the data to enumerate
  62613. * @param byteOffset the byte offset of the data
  62614. * @param byteStride the byte stride of the data
  62615. * @param componentCount the number of components per element
  62616. * @param componentType the type of the component
  62617. * @param count the total number of components
  62618. * @param normalized whether the data is normalized
  62619. * @param callback the callback function called for each value
  62620. */
  62621. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  62622. private static _GetFloatValue;
  62623. }
  62624. }
  62625. declare module BABYLON {
  62626. /**
  62627. * Class representing spherical polynomial coefficients to the 3rd degree
  62628. */
  62629. export class SphericalPolynomial {
  62630. /**
  62631. * The x coefficients of the spherical polynomial
  62632. */
  62633. x: Vector3;
  62634. /**
  62635. * The y coefficients of the spherical polynomial
  62636. */
  62637. y: Vector3;
  62638. /**
  62639. * The z coefficients of the spherical polynomial
  62640. */
  62641. z: Vector3;
  62642. /**
  62643. * The xx coefficients of the spherical polynomial
  62644. */
  62645. xx: Vector3;
  62646. /**
  62647. * The yy coefficients of the spherical polynomial
  62648. */
  62649. yy: Vector3;
  62650. /**
  62651. * The zz coefficients of the spherical polynomial
  62652. */
  62653. zz: Vector3;
  62654. /**
  62655. * The xy coefficients of the spherical polynomial
  62656. */
  62657. xy: Vector3;
  62658. /**
  62659. * The yz coefficients of the spherical polynomial
  62660. */
  62661. yz: Vector3;
  62662. /**
  62663. * The zx coefficients of the spherical polynomial
  62664. */
  62665. zx: Vector3;
  62666. /**
  62667. * Adds an ambient color to the spherical polynomial
  62668. * @param color the color to add
  62669. */
  62670. addAmbient(color: Color3): void;
  62671. /**
  62672. * Scales the spherical polynomial by the given amount
  62673. * @param scale the amount to scale
  62674. */
  62675. scale(scale: number): void;
  62676. /**
  62677. * Gets the spherical polynomial from harmonics
  62678. * @param harmonics the spherical harmonics
  62679. * @returns the spherical polynomial
  62680. */
  62681. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  62682. /**
  62683. * Constructs a spherical polynomial from an array.
  62684. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  62685. * @returns the spherical polynomial
  62686. */
  62687. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  62688. }
  62689. /**
  62690. * Class representing spherical harmonics coefficients to the 3rd degree
  62691. */
  62692. export class SphericalHarmonics {
  62693. /**
  62694. * The l0,0 coefficients of the spherical harmonics
  62695. */
  62696. l00: Vector3;
  62697. /**
  62698. * The l1,-1 coefficients of the spherical harmonics
  62699. */
  62700. l1_1: Vector3;
  62701. /**
  62702. * The l1,0 coefficients of the spherical harmonics
  62703. */
  62704. l10: Vector3;
  62705. /**
  62706. * The l1,1 coefficients of the spherical harmonics
  62707. */
  62708. l11: Vector3;
  62709. /**
  62710. * The l2,-2 coefficients of the spherical harmonics
  62711. */
  62712. l2_2: Vector3;
  62713. /**
  62714. * The l2,-1 coefficients of the spherical harmonics
  62715. */
  62716. l2_1: Vector3;
  62717. /**
  62718. * The l2,0 coefficients of the spherical harmonics
  62719. */
  62720. l20: Vector3;
  62721. /**
  62722. * The l2,1 coefficients of the spherical harmonics
  62723. */
  62724. l21: Vector3;
  62725. /**
  62726. * The l2,2 coefficients of the spherical harmonics
  62727. */
  62728. lL22: Vector3;
  62729. /**
  62730. * Adds a light to the spherical harmonics
  62731. * @param direction the direction of the light
  62732. * @param color the color of the light
  62733. * @param deltaSolidAngle the delta solid angle of the light
  62734. */
  62735. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  62736. /**
  62737. * Scales the spherical harmonics by the given amount
  62738. * @param scale the amount to scale
  62739. */
  62740. scale(scale: number): void;
  62741. /**
  62742. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  62743. *
  62744. * ```
  62745. * E_lm = A_l * L_lm
  62746. * ```
  62747. *
  62748. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  62749. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  62750. * the scaling factors are given in equation 9.
  62751. */
  62752. convertIncidentRadianceToIrradiance(): void;
  62753. /**
  62754. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  62755. *
  62756. * ```
  62757. * L = (1/pi) * E * rho
  62758. * ```
  62759. *
  62760. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  62761. */
  62762. convertIrradianceToLambertianRadiance(): void;
  62763. /**
  62764. * Gets the spherical harmonics from polynomial
  62765. * @param polynomial the spherical polynomial
  62766. * @returns the spherical harmonics
  62767. */
  62768. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  62769. /**
  62770. * Constructs a spherical harmonics from an array.
  62771. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  62772. * @returns the spherical harmonics
  62773. */
  62774. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  62775. }
  62776. }
  62777. declare module BABYLON {
  62778. /**
  62779. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  62780. */
  62781. export interface CubeMapInfo {
  62782. /**
  62783. * The pixel array for the front face.
  62784. * This is stored in format, left to right, up to down format.
  62785. */
  62786. front: Nullable<ArrayBufferView>;
  62787. /**
  62788. * The pixel array for the back face.
  62789. * This is stored in format, left to right, up to down format.
  62790. */
  62791. back: Nullable<ArrayBufferView>;
  62792. /**
  62793. * The pixel array for the left face.
  62794. * This is stored in format, left to right, up to down format.
  62795. */
  62796. left: Nullable<ArrayBufferView>;
  62797. /**
  62798. * The pixel array for the right face.
  62799. * This is stored in format, left to right, up to down format.
  62800. */
  62801. right: Nullable<ArrayBufferView>;
  62802. /**
  62803. * The pixel array for the up face.
  62804. * This is stored in format, left to right, up to down format.
  62805. */
  62806. up: Nullable<ArrayBufferView>;
  62807. /**
  62808. * The pixel array for the down face.
  62809. * This is stored in format, left to right, up to down format.
  62810. */
  62811. down: Nullable<ArrayBufferView>;
  62812. /**
  62813. * The size of the cubemap stored.
  62814. *
  62815. * Each faces will be size * size pixels.
  62816. */
  62817. size: number;
  62818. /**
  62819. * The format of the texture.
  62820. *
  62821. * RGBA, RGB.
  62822. */
  62823. format: number;
  62824. /**
  62825. * The type of the texture data.
  62826. *
  62827. * UNSIGNED_INT, FLOAT.
  62828. */
  62829. type: number;
  62830. /**
  62831. * Specifies whether the texture is in gamma space.
  62832. */
  62833. gammaSpace: boolean;
  62834. }
  62835. /**
  62836. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  62837. */
  62838. export class PanoramaToCubeMapTools {
  62839. private static FACE_FRONT;
  62840. private static FACE_BACK;
  62841. private static FACE_RIGHT;
  62842. private static FACE_LEFT;
  62843. private static FACE_DOWN;
  62844. private static FACE_UP;
  62845. /**
  62846. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  62847. *
  62848. * @param float32Array The source data.
  62849. * @param inputWidth The width of the input panorama.
  62850. * @param inputHeight The height of the input panorama.
  62851. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  62852. * @return The cubemap data
  62853. */
  62854. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  62855. private static CreateCubemapTexture;
  62856. private static CalcProjectionSpherical;
  62857. }
  62858. }
  62859. declare module BABYLON {
  62860. /**
  62861. * Helper class dealing with the extraction of spherical polynomial dataArray
  62862. * from a cube map.
  62863. */
  62864. export class CubeMapToSphericalPolynomialTools {
  62865. private static FileFaces;
  62866. /**
  62867. * Converts a texture to the according Spherical Polynomial data.
  62868. * This extracts the first 3 orders only as they are the only one used in the lighting.
  62869. *
  62870. * @param texture The texture to extract the information from.
  62871. * @return The Spherical Polynomial data.
  62872. */
  62873. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  62874. /**
  62875. * Converts a cubemap to the according Spherical Polynomial data.
  62876. * This extracts the first 3 orders only as they are the only one used in the lighting.
  62877. *
  62878. * @param cubeInfo The Cube map to extract the information from.
  62879. * @return The Spherical Polynomial data.
  62880. */
  62881. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  62882. }
  62883. }
  62884. declare module BABYLON {
  62885. /**
  62886. * The engine store class is responsible to hold all the instances of Engine and Scene created
  62887. * during the life time of the application.
  62888. */
  62889. export class EngineStore {
  62890. /** Gets the list of created engines */
  62891. static Instances: Engine[];
  62892. /**
  62893. * Gets the latest created engine
  62894. */
  62895. static readonly LastCreatedEngine: Nullable<Engine>;
  62896. /**
  62897. * Gets the latest created scene
  62898. */
  62899. static readonly LastCreatedScene: Nullable<Scene>;
  62900. }
  62901. }
  62902. declare module BABYLON {
  62903. /**
  62904. * Define options used to create a render target texture
  62905. */
  62906. export class RenderTargetCreationOptions {
  62907. /**
  62908. * Specifies is mipmaps must be generated
  62909. */
  62910. generateMipMaps?: boolean;
  62911. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  62912. generateDepthBuffer?: boolean;
  62913. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  62914. generateStencilBuffer?: boolean;
  62915. /** Defines texture type (int by default) */
  62916. type?: number;
  62917. /** Defines sampling mode (trilinear by default) */
  62918. samplingMode?: number;
  62919. /** Defines format (RGBA by default) */
  62920. format?: number;
  62921. }
  62922. }
  62923. declare module BABYLON {
  62924. /**
  62925. * @hidden
  62926. **/
  62927. export class _AlphaState {
  62928. private _isAlphaBlendDirty;
  62929. private _isBlendFunctionParametersDirty;
  62930. private _isBlendEquationParametersDirty;
  62931. private _isBlendConstantsDirty;
  62932. private _alphaBlend;
  62933. private _blendFunctionParameters;
  62934. private _blendEquationParameters;
  62935. private _blendConstants;
  62936. /**
  62937. * Initializes the state.
  62938. */
  62939. constructor();
  62940. readonly isDirty: boolean;
  62941. alphaBlend: boolean;
  62942. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  62943. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  62944. setAlphaEquationParameters(rgb: number, alpha: number): void;
  62945. reset(): void;
  62946. apply(gl: WebGLRenderingContext): void;
  62947. }
  62948. }
  62949. declare module BABYLON {
  62950. /**
  62951. * @hidden
  62952. **/
  62953. export class _DepthCullingState {
  62954. private _isDepthTestDirty;
  62955. private _isDepthMaskDirty;
  62956. private _isDepthFuncDirty;
  62957. private _isCullFaceDirty;
  62958. private _isCullDirty;
  62959. private _isZOffsetDirty;
  62960. private _isFrontFaceDirty;
  62961. private _depthTest;
  62962. private _depthMask;
  62963. private _depthFunc;
  62964. private _cull;
  62965. private _cullFace;
  62966. private _zOffset;
  62967. private _frontFace;
  62968. /**
  62969. * Initializes the state.
  62970. */
  62971. constructor();
  62972. readonly isDirty: boolean;
  62973. zOffset: number;
  62974. cullFace: Nullable<number>;
  62975. cull: Nullable<boolean>;
  62976. depthFunc: Nullable<number>;
  62977. depthMask: boolean;
  62978. depthTest: boolean;
  62979. frontFace: Nullable<number>;
  62980. reset(): void;
  62981. apply(gl: WebGLRenderingContext): void;
  62982. }
  62983. }
  62984. declare module BABYLON {
  62985. /**
  62986. * @hidden
  62987. **/
  62988. export class _StencilState {
  62989. /** 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 */
  62990. static readonly ALWAYS: number;
  62991. /** Passed to stencilOperation to specify that stencil value must be kept */
  62992. static readonly KEEP: number;
  62993. /** Passed to stencilOperation to specify that stencil value must be replaced */
  62994. static readonly REPLACE: number;
  62995. private _isStencilTestDirty;
  62996. private _isStencilMaskDirty;
  62997. private _isStencilFuncDirty;
  62998. private _isStencilOpDirty;
  62999. private _stencilTest;
  63000. private _stencilMask;
  63001. private _stencilFunc;
  63002. private _stencilFuncRef;
  63003. private _stencilFuncMask;
  63004. private _stencilOpStencilFail;
  63005. private _stencilOpDepthFail;
  63006. private _stencilOpStencilDepthPass;
  63007. readonly isDirty: boolean;
  63008. stencilFunc: number;
  63009. stencilFuncRef: number;
  63010. stencilFuncMask: number;
  63011. stencilOpStencilFail: number;
  63012. stencilOpDepthFail: number;
  63013. stencilOpStencilDepthPass: number;
  63014. stencilMask: number;
  63015. stencilTest: boolean;
  63016. constructor();
  63017. reset(): void;
  63018. apply(gl: WebGLRenderingContext): void;
  63019. }
  63020. }
  63021. declare module BABYLON {
  63022. /**
  63023. * @hidden
  63024. **/
  63025. export class _TimeToken {
  63026. _startTimeQuery: Nullable<WebGLQuery>;
  63027. _endTimeQuery: Nullable<WebGLQuery>;
  63028. _timeElapsedQuery: Nullable<WebGLQuery>;
  63029. _timeElapsedQueryEnded: boolean;
  63030. }
  63031. }
  63032. declare module BABYLON {
  63033. /**
  63034. * Internal interface used to track InternalTexture already bound to the GL context
  63035. */
  63036. export interface IInternalTextureTracker {
  63037. /**
  63038. * Gets or set the previous tracker in the list
  63039. */
  63040. previous: Nullable<IInternalTextureTracker>;
  63041. /**
  63042. * Gets or set the next tracker in the list
  63043. */
  63044. next: Nullable<IInternalTextureTracker>;
  63045. }
  63046. /**
  63047. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  63048. */
  63049. export class DummyInternalTextureTracker {
  63050. /**
  63051. * Gets or set the previous tracker in the list
  63052. */
  63053. previous: Nullable<IInternalTextureTracker>;
  63054. /**
  63055. * Gets or set the next tracker in the list
  63056. */
  63057. next: Nullable<IInternalTextureTracker>;
  63058. }
  63059. }
  63060. declare module BABYLON {
  63061. /**
  63062. * Class used to store data associated with WebGL texture data for the engine
  63063. * This class should not be used directly
  63064. */
  63065. export class InternalTexture implements IInternalTextureTracker {
  63066. /** hidden */
  63067. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  63068. /**
  63069. * The source of the texture data is unknown
  63070. */
  63071. static DATASOURCE_UNKNOWN: number;
  63072. /**
  63073. * Texture data comes from an URL
  63074. */
  63075. static DATASOURCE_URL: number;
  63076. /**
  63077. * Texture data is only used for temporary storage
  63078. */
  63079. static DATASOURCE_TEMP: number;
  63080. /**
  63081. * Texture data comes from raw data (ArrayBuffer)
  63082. */
  63083. static DATASOURCE_RAW: number;
  63084. /**
  63085. * Texture content is dynamic (video or dynamic texture)
  63086. */
  63087. static DATASOURCE_DYNAMIC: number;
  63088. /**
  63089. * Texture content is generated by rendering to it
  63090. */
  63091. static DATASOURCE_RENDERTARGET: number;
  63092. /**
  63093. * Texture content is part of a multi render target process
  63094. */
  63095. static DATASOURCE_MULTIRENDERTARGET: number;
  63096. /**
  63097. * Texture data comes from a cube data file
  63098. */
  63099. static DATASOURCE_CUBE: number;
  63100. /**
  63101. * Texture data comes from a raw cube data
  63102. */
  63103. static DATASOURCE_CUBERAW: number;
  63104. /**
  63105. * Texture data come from a prefiltered cube data file
  63106. */
  63107. static DATASOURCE_CUBEPREFILTERED: number;
  63108. /**
  63109. * Texture content is raw 3D data
  63110. */
  63111. static DATASOURCE_RAW3D: number;
  63112. /**
  63113. * Texture content is a depth texture
  63114. */
  63115. static DATASOURCE_DEPTHTEXTURE: number;
  63116. /**
  63117. * Texture data comes from a raw cube data encoded with RGBD
  63118. */
  63119. static DATASOURCE_CUBERAW_RGBD: number;
  63120. /**
  63121. * Defines if the texture is ready
  63122. */
  63123. isReady: boolean;
  63124. /**
  63125. * Defines if the texture is a cube texture
  63126. */
  63127. isCube: boolean;
  63128. /**
  63129. * Defines if the texture contains 3D data
  63130. */
  63131. is3D: boolean;
  63132. /**
  63133. * Gets the URL used to load this texture
  63134. */
  63135. url: string;
  63136. /**
  63137. * Gets the sampling mode of the texture
  63138. */
  63139. samplingMode: number;
  63140. /**
  63141. * Gets a boolean indicating if the texture needs mipmaps generation
  63142. */
  63143. generateMipMaps: boolean;
  63144. /**
  63145. * Gets the number of samples used by the texture (WebGL2+ only)
  63146. */
  63147. samples: number;
  63148. /**
  63149. * Gets the type of the texture (int, float...)
  63150. */
  63151. type: number;
  63152. /**
  63153. * Gets the format of the texture (RGB, RGBA...)
  63154. */
  63155. format: number;
  63156. /**
  63157. * Observable called when the texture is loaded
  63158. */
  63159. onLoadedObservable: Observable<InternalTexture>;
  63160. /**
  63161. * Gets the width of the texture
  63162. */
  63163. width: number;
  63164. /**
  63165. * Gets the height of the texture
  63166. */
  63167. height: number;
  63168. /**
  63169. * Gets the depth of the texture
  63170. */
  63171. depth: number;
  63172. /**
  63173. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  63174. */
  63175. baseWidth: number;
  63176. /**
  63177. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  63178. */
  63179. baseHeight: number;
  63180. /**
  63181. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  63182. */
  63183. baseDepth: number;
  63184. /**
  63185. * Gets a boolean indicating if the texture is inverted on Y axis
  63186. */
  63187. invertY: boolean;
  63188. /**
  63189. * Gets or set the previous tracker in the list
  63190. */
  63191. previous: Nullable<IInternalTextureTracker>;
  63192. /**
  63193. * Gets or set the next tracker in the list
  63194. */
  63195. next: Nullable<IInternalTextureTracker>;
  63196. /** @hidden */
  63197. _invertVScale: boolean;
  63198. /** @hidden */
  63199. _initialSlot: number;
  63200. /** @hidden */
  63201. _designatedSlot: number;
  63202. /** @hidden */
  63203. _dataSource: number;
  63204. /** @hidden */
  63205. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  63206. /** @hidden */
  63207. _bufferView: Nullable<ArrayBufferView>;
  63208. /** @hidden */
  63209. _bufferViewArray: Nullable<ArrayBufferView[]>;
  63210. /** @hidden */
  63211. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  63212. /** @hidden */
  63213. _size: number;
  63214. /** @hidden */
  63215. _extension: string;
  63216. /** @hidden */
  63217. _files: Nullable<string[]>;
  63218. /** @hidden */
  63219. _workingCanvas: HTMLCanvasElement;
  63220. /** @hidden */
  63221. _workingContext: CanvasRenderingContext2D;
  63222. /** @hidden */
  63223. _framebuffer: Nullable<WebGLFramebuffer>;
  63224. /** @hidden */
  63225. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  63226. /** @hidden */
  63227. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  63228. /** @hidden */
  63229. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  63230. /** @hidden */
  63231. _attachments: Nullable<number[]>;
  63232. /** @hidden */
  63233. _cachedCoordinatesMode: Nullable<number>;
  63234. /** @hidden */
  63235. _cachedWrapU: Nullable<number>;
  63236. /** @hidden */
  63237. _cachedWrapV: Nullable<number>;
  63238. /** @hidden */
  63239. _cachedWrapR: Nullable<number>;
  63240. /** @hidden */
  63241. _cachedAnisotropicFilteringLevel: Nullable<number>;
  63242. /** @hidden */
  63243. _isDisabled: boolean;
  63244. /** @hidden */
  63245. _compression: Nullable<string>;
  63246. /** @hidden */
  63247. _generateStencilBuffer: boolean;
  63248. /** @hidden */
  63249. _generateDepthBuffer: boolean;
  63250. /** @hidden */
  63251. _comparisonFunction: number;
  63252. /** @hidden */
  63253. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  63254. /** @hidden */
  63255. _lodGenerationScale: number;
  63256. /** @hidden */
  63257. _lodGenerationOffset: number;
  63258. /** @hidden */
  63259. _lodTextureHigh: BaseTexture;
  63260. /** @hidden */
  63261. _lodTextureMid: BaseTexture;
  63262. /** @hidden */
  63263. _lodTextureLow: BaseTexture;
  63264. /** @hidden */
  63265. _isRGBD: boolean;
  63266. /** @hidden */
  63267. _webGLTexture: Nullable<WebGLTexture>;
  63268. /** @hidden */
  63269. _references: number;
  63270. private _engine;
  63271. /**
  63272. * Gets the Engine the texture belongs to.
  63273. * @returns The babylon engine
  63274. */
  63275. getEngine(): Engine;
  63276. /**
  63277. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  63278. */
  63279. readonly dataSource: number;
  63280. /**
  63281. * Creates a new InternalTexture
  63282. * @param engine defines the engine to use
  63283. * @param dataSource defines the type of data that will be used
  63284. * @param delayAllocation if the texture allocation should be delayed (default: false)
  63285. */
  63286. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  63287. /**
  63288. * Increments the number of references (ie. the number of Texture that point to it)
  63289. */
  63290. incrementReferences(): void;
  63291. /**
  63292. * Change the size of the texture (not the size of the content)
  63293. * @param width defines the new width
  63294. * @param height defines the new height
  63295. * @param depth defines the new depth (1 by default)
  63296. */
  63297. updateSize(width: int, height: int, depth?: int): void;
  63298. /** @hidden */
  63299. _rebuild(): void;
  63300. /** @hidden */
  63301. _swapAndDie(target: InternalTexture): void;
  63302. /**
  63303. * Dispose the current allocated resources
  63304. */
  63305. dispose(): void;
  63306. }
  63307. }
  63308. declare module BABYLON {
  63309. /**
  63310. * This represents the main contract an easing function should follow.
  63311. * Easing functions are used throughout the animation system.
  63312. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63313. */
  63314. export interface IEasingFunction {
  63315. /**
  63316. * Given an input gradient between 0 and 1, this returns the corrseponding value
  63317. * of the easing function.
  63318. * The link below provides some of the most common examples of easing functions.
  63319. * @see https://easings.net/
  63320. * @param gradient Defines the value between 0 and 1 we want the easing value for
  63321. * @returns the corresponding value on the curve defined by the easing function
  63322. */
  63323. ease(gradient: number): number;
  63324. }
  63325. /**
  63326. * Base class used for every default easing function.
  63327. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63328. */
  63329. export class EasingFunction implements IEasingFunction {
  63330. /**
  63331. * Interpolation follows the mathematical formula associated with the easing function.
  63332. */
  63333. static readonly EASINGMODE_EASEIN: number;
  63334. /**
  63335. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  63336. */
  63337. static readonly EASINGMODE_EASEOUT: number;
  63338. /**
  63339. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  63340. */
  63341. static readonly EASINGMODE_EASEINOUT: number;
  63342. private _easingMode;
  63343. /**
  63344. * Sets the easing mode of the current function.
  63345. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  63346. */
  63347. setEasingMode(easingMode: number): void;
  63348. /**
  63349. * Gets the current easing mode.
  63350. * @returns the easing mode
  63351. */
  63352. getEasingMode(): number;
  63353. /**
  63354. * @hidden
  63355. */
  63356. easeInCore(gradient: number): number;
  63357. /**
  63358. * Given an input gradient between 0 and 1, this returns the corrseponding value
  63359. * of the easing function.
  63360. * @param gradient Defines the value between 0 and 1 we want the easing value for
  63361. * @returns the corresponding value on the curve defined by the easing function
  63362. */
  63363. ease(gradient: number): number;
  63364. }
  63365. /**
  63366. * Easing function with a circle shape (see link below).
  63367. * @see https://easings.net/#easeInCirc
  63368. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63369. */
  63370. export class CircleEase extends EasingFunction implements IEasingFunction {
  63371. /** @hidden */
  63372. easeInCore(gradient: number): number;
  63373. }
  63374. /**
  63375. * Easing function with a ease back shape (see link below).
  63376. * @see https://easings.net/#easeInBack
  63377. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63378. */
  63379. export class BackEase extends EasingFunction implements IEasingFunction {
  63380. /** Defines the amplitude of the function */
  63381. amplitude: number;
  63382. /**
  63383. * Instantiates a back ease easing
  63384. * @see https://easings.net/#easeInBack
  63385. * @param amplitude Defines the amplitude of the function
  63386. */
  63387. constructor(
  63388. /** Defines the amplitude of the function */
  63389. amplitude?: number);
  63390. /** @hidden */
  63391. easeInCore(gradient: number): number;
  63392. }
  63393. /**
  63394. * Easing function with a bouncing shape (see link below).
  63395. * @see https://easings.net/#easeInBounce
  63396. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63397. */
  63398. export class BounceEase extends EasingFunction implements IEasingFunction {
  63399. /** Defines the number of bounces */
  63400. bounces: number;
  63401. /** Defines the amplitude of the bounce */
  63402. bounciness: number;
  63403. /**
  63404. * Instantiates a bounce easing
  63405. * @see https://easings.net/#easeInBounce
  63406. * @param bounces Defines the number of bounces
  63407. * @param bounciness Defines the amplitude of the bounce
  63408. */
  63409. constructor(
  63410. /** Defines the number of bounces */
  63411. bounces?: number,
  63412. /** Defines the amplitude of the bounce */
  63413. bounciness?: number);
  63414. /** @hidden */
  63415. easeInCore(gradient: number): number;
  63416. }
  63417. /**
  63418. * Easing function with a power of 3 shape (see link below).
  63419. * @see https://easings.net/#easeInCubic
  63420. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63421. */
  63422. export class CubicEase extends EasingFunction implements IEasingFunction {
  63423. /** @hidden */
  63424. easeInCore(gradient: number): number;
  63425. }
  63426. /**
  63427. * Easing function with an elastic shape (see link below).
  63428. * @see https://easings.net/#easeInElastic
  63429. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63430. */
  63431. export class ElasticEase extends EasingFunction implements IEasingFunction {
  63432. /** Defines the number of oscillations*/
  63433. oscillations: number;
  63434. /** Defines the amplitude of the oscillations*/
  63435. springiness: number;
  63436. /**
  63437. * Instantiates an elastic easing function
  63438. * @see https://easings.net/#easeInElastic
  63439. * @param oscillations Defines the number of oscillations
  63440. * @param springiness Defines the amplitude of the oscillations
  63441. */
  63442. constructor(
  63443. /** Defines the number of oscillations*/
  63444. oscillations?: number,
  63445. /** Defines the amplitude of the oscillations*/
  63446. springiness?: number);
  63447. /** @hidden */
  63448. easeInCore(gradient: number): number;
  63449. }
  63450. /**
  63451. * Easing function with an exponential shape (see link below).
  63452. * @see https://easings.net/#easeInExpo
  63453. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63454. */
  63455. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  63456. /** Defines the exponent of the function */
  63457. exponent: number;
  63458. /**
  63459. * Instantiates an exponential easing function
  63460. * @see https://easings.net/#easeInExpo
  63461. * @param exponent Defines the exponent of the function
  63462. */
  63463. constructor(
  63464. /** Defines the exponent of the function */
  63465. exponent?: number);
  63466. /** @hidden */
  63467. easeInCore(gradient: number): number;
  63468. }
  63469. /**
  63470. * Easing function with a power shape (see link below).
  63471. * @see https://easings.net/#easeInQuad
  63472. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63473. */
  63474. export class PowerEase extends EasingFunction implements IEasingFunction {
  63475. /** Defines the power of the function */
  63476. power: number;
  63477. /**
  63478. * Instantiates an power base easing function
  63479. * @see https://easings.net/#easeInQuad
  63480. * @param power Defines the power of the function
  63481. */
  63482. constructor(
  63483. /** Defines the power of the function */
  63484. power?: number);
  63485. /** @hidden */
  63486. easeInCore(gradient: number): number;
  63487. }
  63488. /**
  63489. * Easing function with a power of 2 shape (see link below).
  63490. * @see https://easings.net/#easeInQuad
  63491. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63492. */
  63493. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  63494. /** @hidden */
  63495. easeInCore(gradient: number): number;
  63496. }
  63497. /**
  63498. * Easing function with a power of 4 shape (see link below).
  63499. * @see https://easings.net/#easeInQuart
  63500. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63501. */
  63502. export class QuarticEase extends EasingFunction implements IEasingFunction {
  63503. /** @hidden */
  63504. easeInCore(gradient: number): number;
  63505. }
  63506. /**
  63507. * Easing function with a power of 5 shape (see link below).
  63508. * @see https://easings.net/#easeInQuint
  63509. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63510. */
  63511. export class QuinticEase extends EasingFunction implements IEasingFunction {
  63512. /** @hidden */
  63513. easeInCore(gradient: number): number;
  63514. }
  63515. /**
  63516. * Easing function with a sin shape (see link below).
  63517. * @see https://easings.net/#easeInSine
  63518. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63519. */
  63520. export class SineEase extends EasingFunction implements IEasingFunction {
  63521. /** @hidden */
  63522. easeInCore(gradient: number): number;
  63523. }
  63524. /**
  63525. * Easing function with a bezier shape (see link below).
  63526. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  63527. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63528. */
  63529. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  63530. /** Defines the x component of the start tangent in the bezier curve */
  63531. x1: number;
  63532. /** Defines the y component of the start tangent in the bezier curve */
  63533. y1: number;
  63534. /** Defines the x component of the end tangent in the bezier curve */
  63535. x2: number;
  63536. /** Defines the y component of the end tangent in the bezier curve */
  63537. y2: number;
  63538. /**
  63539. * Instantiates a bezier function
  63540. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  63541. * @param x1 Defines the x component of the start tangent in the bezier curve
  63542. * @param y1 Defines the y component of the start tangent in the bezier curve
  63543. * @param x2 Defines the x component of the end tangent in the bezier curve
  63544. * @param y2 Defines the y component of the end tangent in the bezier curve
  63545. */
  63546. constructor(
  63547. /** Defines the x component of the start tangent in the bezier curve */
  63548. x1?: number,
  63549. /** Defines the y component of the start tangent in the bezier curve */
  63550. y1?: number,
  63551. /** Defines the x component of the end tangent in the bezier curve */
  63552. x2?: number,
  63553. /** Defines the y component of the end tangent in the bezier curve */
  63554. y2?: number);
  63555. /** @hidden */
  63556. easeInCore(gradient: number): number;
  63557. }
  63558. }
  63559. declare module BABYLON {
  63560. /**
  63561. * Defines an interface which represents an animation key frame
  63562. */
  63563. export interface IAnimationKey {
  63564. /**
  63565. * Frame of the key frame
  63566. */
  63567. frame: number;
  63568. /**
  63569. * Value at the specifies key frame
  63570. */
  63571. value: any;
  63572. /**
  63573. * The input tangent for the cubic hermite spline
  63574. */
  63575. inTangent?: any;
  63576. /**
  63577. * The output tangent for the cubic hermite spline
  63578. */
  63579. outTangent?: any;
  63580. /**
  63581. * The animation interpolation type
  63582. */
  63583. interpolation?: AnimationKeyInterpolation;
  63584. }
  63585. /**
  63586. * Enum for the animation key frame interpolation type
  63587. */
  63588. export enum AnimationKeyInterpolation {
  63589. /**
  63590. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  63591. */
  63592. STEP = 1
  63593. }
  63594. }
  63595. declare module BABYLON {
  63596. /**
  63597. * Represents the range of an animation
  63598. */
  63599. export class AnimationRange {
  63600. /**The name of the animation range**/
  63601. name: string;
  63602. /**The starting frame of the animation */
  63603. from: number;
  63604. /**The ending frame of the animation*/
  63605. to: number;
  63606. /**
  63607. * Initializes the range of an animation
  63608. * @param name The name of the animation range
  63609. * @param from The starting frame of the animation
  63610. * @param to The ending frame of the animation
  63611. */
  63612. constructor(
  63613. /**The name of the animation range**/
  63614. name: string,
  63615. /**The starting frame of the animation */
  63616. from: number,
  63617. /**The ending frame of the animation*/
  63618. to: number);
  63619. /**
  63620. * Makes a copy of the animation range
  63621. * @returns A copy of the animation range
  63622. */
  63623. clone(): AnimationRange;
  63624. }
  63625. }
  63626. declare module BABYLON {
  63627. /**
  63628. * Composed of a frame, and an action function
  63629. */
  63630. export class AnimationEvent {
  63631. /** The frame for which the event is triggered **/
  63632. frame: number;
  63633. /** The event to perform when triggered **/
  63634. action: (currentFrame: number) => void;
  63635. /** Specifies if the event should be triggered only once**/
  63636. onlyOnce?: boolean | undefined;
  63637. /**
  63638. * Specifies if the animation event is done
  63639. */
  63640. isDone: boolean;
  63641. /**
  63642. * Initializes the animation event
  63643. * @param frame The frame for which the event is triggered
  63644. * @param action The event to perform when triggered
  63645. * @param onlyOnce Specifies if the event should be triggered only once
  63646. */
  63647. constructor(
  63648. /** The frame for which the event is triggered **/
  63649. frame: number,
  63650. /** The event to perform when triggered **/
  63651. action: (currentFrame: number) => void,
  63652. /** Specifies if the event should be triggered only once**/
  63653. onlyOnce?: boolean | undefined);
  63654. /** @hidden */
  63655. _clone(): AnimationEvent;
  63656. }
  63657. }
  63658. declare module BABYLON {
  63659. /**
  63660. * Interface used to define a behavior
  63661. */
  63662. export interface Behavior<T> {
  63663. /** gets or sets behavior's name */
  63664. name: string;
  63665. /**
  63666. * Function called when the behavior needs to be initialized (after attaching it to a target)
  63667. */
  63668. init(): void;
  63669. /**
  63670. * Called when the behavior is attached to a target
  63671. * @param target defines the target where the behavior is attached to
  63672. */
  63673. attach(target: T): void;
  63674. /**
  63675. * Called when the behavior is detached from its target
  63676. */
  63677. detach(): void;
  63678. }
  63679. /**
  63680. * Interface implemented by classes supporting behaviors
  63681. */
  63682. export interface IBehaviorAware<T> {
  63683. /**
  63684. * Attach a behavior
  63685. * @param behavior defines the behavior to attach
  63686. * @returns the current host
  63687. */
  63688. addBehavior(behavior: Behavior<T>): T;
  63689. /**
  63690. * Remove a behavior from the current object
  63691. * @param behavior defines the behavior to detach
  63692. * @returns the current host
  63693. */
  63694. removeBehavior(behavior: Behavior<T>): T;
  63695. /**
  63696. * Gets a behavior using its name to search
  63697. * @param name defines the name to search
  63698. * @returns the behavior or null if not found
  63699. */
  63700. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  63701. }
  63702. }
  63703. declare module BABYLON {
  63704. /**
  63705. * @hidden
  63706. */
  63707. export class IntersectionInfo {
  63708. bu: Nullable<number>;
  63709. bv: Nullable<number>;
  63710. distance: number;
  63711. faceId: number;
  63712. subMeshId: number;
  63713. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  63714. }
  63715. }
  63716. declare module BABYLON {
  63717. /**
  63718. * Class used to store bounding sphere information
  63719. */
  63720. export class BoundingSphere {
  63721. /**
  63722. * Gets the center of the bounding sphere in local space
  63723. */
  63724. readonly center: Vector3;
  63725. /**
  63726. * Radius of the bounding sphere in local space
  63727. */
  63728. radius: number;
  63729. /**
  63730. * Gets the center of the bounding sphere in world space
  63731. */
  63732. readonly centerWorld: Vector3;
  63733. /**
  63734. * Radius of the bounding sphere in world space
  63735. */
  63736. radiusWorld: number;
  63737. /**
  63738. * Gets the minimum vector in local space
  63739. */
  63740. readonly minimum: Vector3;
  63741. /**
  63742. * Gets the maximum vector in local space
  63743. */
  63744. readonly maximum: Vector3;
  63745. private _worldMatrix;
  63746. private static readonly TmpVector3;
  63747. /**
  63748. * Creates a new bounding sphere
  63749. * @param min defines the minimum vector (in local space)
  63750. * @param max defines the maximum vector (in local space)
  63751. * @param worldMatrix defines the new world matrix
  63752. */
  63753. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  63754. /**
  63755. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  63756. * @param min defines the new minimum vector (in local space)
  63757. * @param max defines the new maximum vector (in local space)
  63758. * @param worldMatrix defines the new world matrix
  63759. */
  63760. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  63761. /**
  63762. * Scale the current bounding sphere by applying a scale factor
  63763. * @param factor defines the scale factor to apply
  63764. * @returns the current bounding box
  63765. */
  63766. scale(factor: number): BoundingSphere;
  63767. /**
  63768. * Gets the world matrix of the bounding box
  63769. * @returns a matrix
  63770. */
  63771. getWorldMatrix(): DeepImmutable<Matrix>;
  63772. /** @hidden */
  63773. _update(worldMatrix: DeepImmutable<Matrix>): void;
  63774. /**
  63775. * Tests if the bounding sphere is intersecting the frustum planes
  63776. * @param frustumPlanes defines the frustum planes to test
  63777. * @returns true if there is an intersection
  63778. */
  63779. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63780. /**
  63781. * Tests if the bounding sphere center is in between the frustum planes.
  63782. * Used for optimistic fast inclusion.
  63783. * @param frustumPlanes defines the frustum planes to test
  63784. * @returns true if the sphere center is in between the frustum planes
  63785. */
  63786. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63787. /**
  63788. * Tests if a point is inside the bounding sphere
  63789. * @param point defines the point to test
  63790. * @returns true if the point is inside the bounding sphere
  63791. */
  63792. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  63793. /**
  63794. * Checks if two sphere intersct
  63795. * @param sphere0 sphere 0
  63796. * @param sphere1 sphere 1
  63797. * @returns true if the speres intersect
  63798. */
  63799. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  63800. }
  63801. }
  63802. declare module BABYLON {
  63803. /**
  63804. * Class used to store bounding box information
  63805. */
  63806. export class BoundingBox implements ICullable {
  63807. /**
  63808. * Gets the 8 vectors representing the bounding box in local space
  63809. */
  63810. readonly vectors: Vector3[];
  63811. /**
  63812. * Gets the center of the bounding box in local space
  63813. */
  63814. readonly center: Vector3;
  63815. /**
  63816. * Gets the center of the bounding box in world space
  63817. */
  63818. readonly centerWorld: Vector3;
  63819. /**
  63820. * Gets the extend size in local space
  63821. */
  63822. readonly extendSize: Vector3;
  63823. /**
  63824. * Gets the extend size in world space
  63825. */
  63826. readonly extendSizeWorld: Vector3;
  63827. /**
  63828. * Gets the OBB (object bounding box) directions
  63829. */
  63830. readonly directions: Vector3[];
  63831. /**
  63832. * Gets the 8 vectors representing the bounding box in world space
  63833. */
  63834. readonly vectorsWorld: Vector3[];
  63835. /**
  63836. * Gets the minimum vector in world space
  63837. */
  63838. readonly minimumWorld: Vector3;
  63839. /**
  63840. * Gets the maximum vector in world space
  63841. */
  63842. readonly maximumWorld: Vector3;
  63843. /**
  63844. * Gets the minimum vector in local space
  63845. */
  63846. readonly minimum: Vector3;
  63847. /**
  63848. * Gets the maximum vector in local space
  63849. */
  63850. readonly maximum: Vector3;
  63851. private _worldMatrix;
  63852. private static readonly TmpVector3;
  63853. /**
  63854. * @hidden
  63855. */
  63856. _tag: number;
  63857. /**
  63858. * Creates a new bounding box
  63859. * @param min defines the minimum vector (in local space)
  63860. * @param max defines the maximum vector (in local space)
  63861. * @param worldMatrix defines the new world matrix
  63862. */
  63863. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  63864. /**
  63865. * Recreates the entire bounding box from scratch as if we call the constructor in place
  63866. * @param min defines the new minimum vector (in local space)
  63867. * @param max defines the new maximum vector (in local space)
  63868. * @param worldMatrix defines the new world matrix
  63869. */
  63870. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  63871. /**
  63872. * Scale the current bounding box by applying a scale factor
  63873. * @param factor defines the scale factor to apply
  63874. * @returns the current bounding box
  63875. */
  63876. scale(factor: number): BoundingBox;
  63877. /**
  63878. * Gets the world matrix of the bounding box
  63879. * @returns a matrix
  63880. */
  63881. getWorldMatrix(): DeepImmutable<Matrix>;
  63882. /** @hidden */
  63883. _update(world: DeepImmutable<Matrix>): void;
  63884. /**
  63885. * Tests if the bounding box is intersecting the frustum planes
  63886. * @param frustumPlanes defines the frustum planes to test
  63887. * @returns true if there is an intersection
  63888. */
  63889. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63890. /**
  63891. * Tests if the bounding box is entirely inside the frustum planes
  63892. * @param frustumPlanes defines the frustum planes to test
  63893. * @returns true if there is an inclusion
  63894. */
  63895. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63896. /**
  63897. * Tests if a point is inside the bounding box
  63898. * @param point defines the point to test
  63899. * @returns true if the point is inside the bounding box
  63900. */
  63901. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  63902. /**
  63903. * Tests if the bounding box intersects with a bounding sphere
  63904. * @param sphere defines the sphere to test
  63905. * @returns true if there is an intersection
  63906. */
  63907. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  63908. /**
  63909. * Tests if the bounding box intersects with a box defined by a min and max vectors
  63910. * @param min defines the min vector to use
  63911. * @param max defines the max vector to use
  63912. * @returns true if there is an intersection
  63913. */
  63914. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  63915. /**
  63916. * Tests if two bounding boxes are intersections
  63917. * @param box0 defines the first box to test
  63918. * @param box1 defines the second box to test
  63919. * @returns true if there is an intersection
  63920. */
  63921. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  63922. /**
  63923. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  63924. * @param minPoint defines the minimum vector of the bounding box
  63925. * @param maxPoint defines the maximum vector of the bounding box
  63926. * @param sphereCenter defines the sphere center
  63927. * @param sphereRadius defines the sphere radius
  63928. * @returns true if there is an intersection
  63929. */
  63930. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  63931. /**
  63932. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  63933. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  63934. * @param frustumPlanes defines the frustum planes to test
  63935. * @return true if there is an inclusion
  63936. */
  63937. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63938. /**
  63939. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  63940. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  63941. * @param frustumPlanes defines the frustum planes to test
  63942. * @return true if there is an intersection
  63943. */
  63944. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63945. }
  63946. }
  63947. declare module BABYLON {
  63948. /** @hidden */
  63949. export class Collider {
  63950. /** Define if a collision was found */
  63951. collisionFound: boolean;
  63952. /**
  63953. * Define last intersection point in local space
  63954. */
  63955. intersectionPoint: Vector3;
  63956. /**
  63957. * Define last collided mesh
  63958. */
  63959. collidedMesh: Nullable<AbstractMesh>;
  63960. private _collisionPoint;
  63961. private _planeIntersectionPoint;
  63962. private _tempVector;
  63963. private _tempVector2;
  63964. private _tempVector3;
  63965. private _tempVector4;
  63966. private _edge;
  63967. private _baseToVertex;
  63968. private _destinationPoint;
  63969. private _slidePlaneNormal;
  63970. private _displacementVector;
  63971. /** @hidden */
  63972. _radius: Vector3;
  63973. /** @hidden */
  63974. _retry: number;
  63975. private _velocity;
  63976. private _basePoint;
  63977. private _epsilon;
  63978. /** @hidden */
  63979. _velocityWorldLength: number;
  63980. /** @hidden */
  63981. _basePointWorld: Vector3;
  63982. private _velocityWorld;
  63983. private _normalizedVelocity;
  63984. /** @hidden */
  63985. _initialVelocity: Vector3;
  63986. /** @hidden */
  63987. _initialPosition: Vector3;
  63988. private _nearestDistance;
  63989. private _collisionMask;
  63990. collisionMask: number;
  63991. /**
  63992. * Gets the plane normal used to compute the sliding response (in local space)
  63993. */
  63994. readonly slidePlaneNormal: Vector3;
  63995. /** @hidden */
  63996. _initialize(source: Vector3, dir: Vector3, e: number): void;
  63997. /** @hidden */
  63998. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  63999. /** @hidden */
  64000. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  64001. /** @hidden */
  64002. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  64003. /** @hidden */
  64004. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  64005. /** @hidden */
  64006. _getResponse(pos: Vector3, vel: Vector3): void;
  64007. }
  64008. }
  64009. declare module BABYLON {
  64010. /**
  64011. * Interface for cullable objects
  64012. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  64013. */
  64014. export interface ICullable {
  64015. /**
  64016. * Checks if the object or part of the object is in the frustum
  64017. * @param frustumPlanes Camera near/planes
  64018. * @returns true if the object is in frustum otherwise false
  64019. */
  64020. isInFrustum(frustumPlanes: Plane[]): boolean;
  64021. /**
  64022. * Checks if a cullable object (mesh...) is in the camera frustum
  64023. * Unlike isInFrustum this cheks the full bounding box
  64024. * @param frustumPlanes Camera near/planes
  64025. * @returns true if the object is in frustum otherwise false
  64026. */
  64027. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  64028. }
  64029. /**
  64030. * Info for a bounding data of a mesh
  64031. */
  64032. export class BoundingInfo implements ICullable {
  64033. /**
  64034. * Bounding box for the mesh
  64035. */
  64036. readonly boundingBox: BoundingBox;
  64037. /**
  64038. * Bounding sphere for the mesh
  64039. */
  64040. readonly boundingSphere: BoundingSphere;
  64041. private _isLocked;
  64042. private static readonly TmpVector3;
  64043. /**
  64044. * Constructs bounding info
  64045. * @param minimum min vector of the bounding box/sphere
  64046. * @param maximum max vector of the bounding box/sphere
  64047. * @param worldMatrix defines the new world matrix
  64048. */
  64049. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  64050. /**
  64051. * Recreates the entire bounding info from scratch as if we call the constructor in place
  64052. * @param min defines the new minimum vector (in local space)
  64053. * @param max defines the new maximum vector (in local space)
  64054. * @param worldMatrix defines the new world matrix
  64055. */
  64056. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  64057. /**
  64058. * min vector of the bounding box/sphere
  64059. */
  64060. readonly minimum: Vector3;
  64061. /**
  64062. * max vector of the bounding box/sphere
  64063. */
  64064. readonly maximum: Vector3;
  64065. /**
  64066. * If the info is locked and won't be updated to avoid perf overhead
  64067. */
  64068. isLocked: boolean;
  64069. /**
  64070. * Updates the bounding sphere and box
  64071. * @param world world matrix to be used to update
  64072. */
  64073. update(world: DeepImmutable<Matrix>): void;
  64074. /**
  64075. * Recreate the bounding info to be centered around a specific point given a specific extend.
  64076. * @param center New center of the bounding info
  64077. * @param extend New extend of the bounding info
  64078. * @returns the current bounding info
  64079. */
  64080. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  64081. /**
  64082. * Scale the current bounding info by applying a scale factor
  64083. * @param factor defines the scale factor to apply
  64084. * @returns the current bounding info
  64085. */
  64086. scale(factor: number): BoundingInfo;
  64087. /**
  64088. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  64089. * @param frustumPlanes defines the frustum to test
  64090. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  64091. * @returns true if the bounding info is in the frustum planes
  64092. */
  64093. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  64094. /**
  64095. * Gets the world distance between the min and max points of the bounding box
  64096. */
  64097. readonly diagonalLength: number;
  64098. /**
  64099. * Checks if a cullable object (mesh...) is in the camera frustum
  64100. * Unlike isInFrustum this cheks the full bounding box
  64101. * @param frustumPlanes Camera near/planes
  64102. * @returns true if the object is in frustum otherwise false
  64103. */
  64104. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64105. /** @hidden */
  64106. _checkCollision(collider: Collider): boolean;
  64107. /**
  64108. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  64109. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  64110. * @param point the point to check intersection with
  64111. * @returns if the point intersects
  64112. */
  64113. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  64114. /**
  64115. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  64116. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  64117. * @param boundingInfo the bounding info to check intersection with
  64118. * @param precise if the intersection should be done using OBB
  64119. * @returns if the bounding info intersects
  64120. */
  64121. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  64122. }
  64123. }
  64124. declare module BABYLON {
  64125. /**
  64126. * Defines an array and its length.
  64127. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  64128. */
  64129. export interface ISmartArrayLike<T> {
  64130. /**
  64131. * The data of the array.
  64132. */
  64133. data: Array<T>;
  64134. /**
  64135. * The active length of the array.
  64136. */
  64137. length: number;
  64138. }
  64139. /**
  64140. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  64141. */
  64142. export class SmartArray<T> implements ISmartArrayLike<T> {
  64143. /**
  64144. * The full set of data from the array.
  64145. */
  64146. data: Array<T>;
  64147. /**
  64148. * The active length of the array.
  64149. */
  64150. length: number;
  64151. protected _id: number;
  64152. /**
  64153. * Instantiates a Smart Array.
  64154. * @param capacity defines the default capacity of the array.
  64155. */
  64156. constructor(capacity: number);
  64157. /**
  64158. * Pushes a value at the end of the active data.
  64159. * @param value defines the object to push in the array.
  64160. */
  64161. push(value: T): void;
  64162. /**
  64163. * Iterates over the active data and apply the lambda to them.
  64164. * @param func defines the action to apply on each value.
  64165. */
  64166. forEach(func: (content: T) => void): void;
  64167. /**
  64168. * Sorts the full sets of data.
  64169. * @param compareFn defines the comparison function to apply.
  64170. */
  64171. sort(compareFn: (a: T, b: T) => number): void;
  64172. /**
  64173. * Resets the active data to an empty array.
  64174. */
  64175. reset(): void;
  64176. /**
  64177. * Releases all the data from the array as well as the array.
  64178. */
  64179. dispose(): void;
  64180. /**
  64181. * Concats the active data with a given array.
  64182. * @param array defines the data to concatenate with.
  64183. */
  64184. concat(array: any): void;
  64185. /**
  64186. * Returns the position of a value in the active data.
  64187. * @param value defines the value to find the index for
  64188. * @returns the index if found in the active data otherwise -1
  64189. */
  64190. indexOf(value: T): number;
  64191. /**
  64192. * Returns whether an element is part of the active data.
  64193. * @param value defines the value to look for
  64194. * @returns true if found in the active data otherwise false
  64195. */
  64196. contains(value: T): boolean;
  64197. private static _GlobalId;
  64198. }
  64199. /**
  64200. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  64201. * The data in this array can only be present once
  64202. */
  64203. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  64204. private _duplicateId;
  64205. /**
  64206. * Pushes a value at the end of the active data.
  64207. * THIS DOES NOT PREVENT DUPPLICATE DATA
  64208. * @param value defines the object to push in the array.
  64209. */
  64210. push(value: T): void;
  64211. /**
  64212. * Pushes a value at the end of the active data.
  64213. * If the data is already present, it won t be added again
  64214. * @param value defines the object to push in the array.
  64215. * @returns true if added false if it was already present
  64216. */
  64217. pushNoDuplicate(value: T): boolean;
  64218. /**
  64219. * Resets the active data to an empty array.
  64220. */
  64221. reset(): void;
  64222. /**
  64223. * Concats the active data with a given array.
  64224. * This ensures no dupplicate will be present in the result.
  64225. * @param array defines the data to concatenate with.
  64226. */
  64227. concatWithNoDuplicate(array: any): void;
  64228. }
  64229. }
  64230. declare module BABYLON {
  64231. /**
  64232. * A multi-material is used to apply different materials to different parts of the same object without the need of
  64233. * separate meshes. This can be use to improve performances.
  64234. * @see http://doc.babylonjs.com/how_to/multi_materials
  64235. */
  64236. export class MultiMaterial extends Material {
  64237. private _subMaterials;
  64238. /**
  64239. * Gets or Sets the list of Materials used within the multi material.
  64240. * They need to be ordered according to the submeshes order in the associated mesh
  64241. */
  64242. subMaterials: Nullable<Material>[];
  64243. /**
  64244. * Function used to align with Node.getChildren()
  64245. * @returns the list of Materials used within the multi material
  64246. */
  64247. getChildren(): Nullable<Material>[];
  64248. /**
  64249. * Instantiates a new Multi Material
  64250. * A multi-material is used to apply different materials to different parts of the same object without the need of
  64251. * separate meshes. This can be use to improve performances.
  64252. * @see http://doc.babylonjs.com/how_to/multi_materials
  64253. * @param name Define the name in the scene
  64254. * @param scene Define the scene the material belongs to
  64255. */
  64256. constructor(name: string, scene: Scene);
  64257. private _hookArray;
  64258. /**
  64259. * Get one of the submaterial by its index in the submaterials array
  64260. * @param index The index to look the sub material at
  64261. * @returns The Material if the index has been defined
  64262. */
  64263. getSubMaterial(index: number): Nullable<Material>;
  64264. /**
  64265. * Get the list of active textures for the whole sub materials list.
  64266. * @returns All the textures that will be used during the rendering
  64267. */
  64268. getActiveTextures(): BaseTexture[];
  64269. /**
  64270. * Gets the current class name of the material e.g. "MultiMaterial"
  64271. * Mainly use in serialization.
  64272. * @returns the class name
  64273. */
  64274. getClassName(): string;
  64275. /**
  64276. * Checks if the material is ready to render the requested sub mesh
  64277. * @param mesh Define the mesh the submesh belongs to
  64278. * @param subMesh Define the sub mesh to look readyness for
  64279. * @param useInstances Define whether or not the material is used with instances
  64280. * @returns true if ready, otherwise false
  64281. */
  64282. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  64283. /**
  64284. * Clones the current material and its related sub materials
  64285. * @param name Define the name of the newly cloned material
  64286. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  64287. * @returns the cloned material
  64288. */
  64289. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  64290. /**
  64291. * Serializes the materials into a JSON representation.
  64292. * @returns the JSON representation
  64293. */
  64294. serialize(): any;
  64295. /**
  64296. * Dispose the material and release its associated resources
  64297. * @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)
  64298. * @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)
  64299. * @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)
  64300. */
  64301. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  64302. /**
  64303. * Creates a MultiMaterial from parsed MultiMaterial data.
  64304. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  64305. * @param scene defines the hosting scene
  64306. * @returns a new MultiMaterial
  64307. */
  64308. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  64309. }
  64310. }
  64311. declare module BABYLON {
  64312. /**
  64313. * Class used to represent data loading progression
  64314. */
  64315. export class SceneLoaderFlags {
  64316. private static _ForceFullSceneLoadingForIncremental;
  64317. private static _ShowLoadingScreen;
  64318. private static _CleanBoneMatrixWeights;
  64319. private static _loggingLevel;
  64320. /**
  64321. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  64322. */
  64323. static ForceFullSceneLoadingForIncremental: boolean;
  64324. /**
  64325. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  64326. */
  64327. static ShowLoadingScreen: boolean;
  64328. /**
  64329. * Defines the current logging level (while loading the scene)
  64330. * @ignorenaming
  64331. */
  64332. static loggingLevel: number;
  64333. /**
  64334. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  64335. */
  64336. static CleanBoneMatrixWeights: boolean;
  64337. }
  64338. }
  64339. declare module BABYLON {
  64340. /**
  64341. * 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.
  64342. * @see https://doc.babylonjs.com/how_to/transformnode
  64343. */
  64344. export class TransformNode extends Node {
  64345. /**
  64346. * Object will not rotate to face the camera
  64347. */
  64348. static BILLBOARDMODE_NONE: number;
  64349. /**
  64350. * Object will rotate to face the camera but only on the x axis
  64351. */
  64352. static BILLBOARDMODE_X: number;
  64353. /**
  64354. * Object will rotate to face the camera but only on the y axis
  64355. */
  64356. static BILLBOARDMODE_Y: number;
  64357. /**
  64358. * Object will rotate to face the camera but only on the z axis
  64359. */
  64360. static BILLBOARDMODE_Z: number;
  64361. /**
  64362. * Object will rotate to face the camera
  64363. */
  64364. static BILLBOARDMODE_ALL: number;
  64365. private _forward;
  64366. private _forwardInverted;
  64367. private _up;
  64368. private _right;
  64369. private _rightInverted;
  64370. private _position;
  64371. private _rotation;
  64372. private _rotationQuaternion;
  64373. protected _scaling: Vector3;
  64374. protected _isDirty: boolean;
  64375. private _transformToBoneReferal;
  64376. /**
  64377. * Set the billboard mode. Default is 0.
  64378. *
  64379. * | Value | Type | Description |
  64380. * | --- | --- | --- |
  64381. * | 0 | BILLBOARDMODE_NONE | |
  64382. * | 1 | BILLBOARDMODE_X | |
  64383. * | 2 | BILLBOARDMODE_Y | |
  64384. * | 4 | BILLBOARDMODE_Z | |
  64385. * | 7 | BILLBOARDMODE_ALL | |
  64386. *
  64387. */
  64388. billboardMode: number;
  64389. /**
  64390. * 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
  64391. */
  64392. scalingDeterminant: number;
  64393. /**
  64394. * Sets the distance of the object to max, often used by skybox
  64395. */
  64396. infiniteDistance: boolean;
  64397. /**
  64398. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  64399. * By default the system will update normals to compensate
  64400. */
  64401. ignoreNonUniformScaling: boolean;
  64402. /** @hidden */
  64403. _poseMatrix: Matrix;
  64404. /** @hidden */
  64405. _localMatrix: Matrix;
  64406. private _absolutePosition;
  64407. private _pivotMatrix;
  64408. private _pivotMatrixInverse;
  64409. protected _postMultiplyPivotMatrix: boolean;
  64410. protected _isWorldMatrixFrozen: boolean;
  64411. /** @hidden */
  64412. _indexInSceneTransformNodesArray: number;
  64413. /**
  64414. * An event triggered after the world matrix is updated
  64415. */
  64416. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  64417. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  64418. /**
  64419. * Gets a string identifying the name of the class
  64420. * @returns "TransformNode" string
  64421. */
  64422. getClassName(): string;
  64423. /**
  64424. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  64425. */
  64426. position: Vector3;
  64427. /**
  64428. * 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)).
  64429. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  64430. */
  64431. rotation: Vector3;
  64432. /**
  64433. * 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)).
  64434. */
  64435. scaling: Vector3;
  64436. /**
  64437. * 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).
  64438. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  64439. */
  64440. rotationQuaternion: Nullable<Quaternion>;
  64441. /**
  64442. * The forward direction of that transform in world space.
  64443. */
  64444. readonly forward: Vector3;
  64445. /**
  64446. * The up direction of that transform in world space.
  64447. */
  64448. readonly up: Vector3;
  64449. /**
  64450. * The right direction of that transform in world space.
  64451. */
  64452. readonly right: Vector3;
  64453. /**
  64454. * Copies the parameter passed Matrix into the mesh Pose matrix.
  64455. * @param matrix the matrix to copy the pose from
  64456. * @returns this TransformNode.
  64457. */
  64458. updatePoseMatrix(matrix: Matrix): TransformNode;
  64459. /**
  64460. * Returns the mesh Pose matrix.
  64461. * @returns the pose matrix
  64462. */
  64463. getPoseMatrix(): Matrix;
  64464. /** @hidden */
  64465. _isSynchronized(): boolean;
  64466. /** @hidden */
  64467. _initCache(): void;
  64468. /**
  64469. * Flag the transform node as dirty (Forcing it to update everything)
  64470. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  64471. * @returns this transform node
  64472. */
  64473. markAsDirty(property: string): TransformNode;
  64474. /**
  64475. * Returns the current mesh absolute position.
  64476. * Returns a Vector3.
  64477. */
  64478. readonly absolutePosition: Vector3;
  64479. /**
  64480. * Sets a new matrix to apply before all other transformation
  64481. * @param matrix defines the transform matrix
  64482. * @returns the current TransformNode
  64483. */
  64484. setPreTransformMatrix(matrix: Matrix): TransformNode;
  64485. /**
  64486. * Sets a new pivot matrix to the current node
  64487. * @param matrix defines the new pivot matrix to use
  64488. * @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
  64489. * @returns the current TransformNode
  64490. */
  64491. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  64492. /**
  64493. * Returns the mesh pivot matrix.
  64494. * Default : Identity.
  64495. * @returns the matrix
  64496. */
  64497. getPivotMatrix(): Matrix;
  64498. /**
  64499. * Prevents the World matrix to be computed any longer.
  64500. * @returns the TransformNode.
  64501. */
  64502. freezeWorldMatrix(): TransformNode;
  64503. /**
  64504. * Allows back the World matrix computation.
  64505. * @returns the TransformNode.
  64506. */
  64507. unfreezeWorldMatrix(): this;
  64508. /**
  64509. * True if the World matrix has been frozen.
  64510. */
  64511. readonly isWorldMatrixFrozen: boolean;
  64512. /**
  64513. * Retuns the mesh absolute position in the World.
  64514. * @returns a Vector3.
  64515. */
  64516. getAbsolutePosition(): Vector3;
  64517. /**
  64518. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  64519. * @param absolutePosition the absolute position to set
  64520. * @returns the TransformNode.
  64521. */
  64522. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  64523. /**
  64524. * Sets the mesh position in its local space.
  64525. * @param vector3 the position to set in localspace
  64526. * @returns the TransformNode.
  64527. */
  64528. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  64529. /**
  64530. * Returns the mesh position in the local space from the current World matrix values.
  64531. * @returns a new Vector3.
  64532. */
  64533. getPositionExpressedInLocalSpace(): Vector3;
  64534. /**
  64535. * Translates the mesh along the passed Vector3 in its local space.
  64536. * @param vector3 the distance to translate in localspace
  64537. * @returns the TransformNode.
  64538. */
  64539. locallyTranslate(vector3: Vector3): TransformNode;
  64540. private static _lookAtVectorCache;
  64541. /**
  64542. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  64543. * @param targetPoint the position (must be in same space as current mesh) to look at
  64544. * @param yawCor optional yaw (y-axis) correction in radians
  64545. * @param pitchCor optional pitch (x-axis) correction in radians
  64546. * @param rollCor optional roll (z-axis) correction in radians
  64547. * @param space the choosen space of the target
  64548. * @returns the TransformNode.
  64549. */
  64550. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  64551. /**
  64552. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  64553. * This Vector3 is expressed in the World space.
  64554. * @param localAxis axis to rotate
  64555. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  64556. */
  64557. getDirection(localAxis: Vector3): Vector3;
  64558. /**
  64559. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  64560. * localAxis is expressed in the mesh local space.
  64561. * result is computed in the Wordl space from the mesh World matrix.
  64562. * @param localAxis axis to rotate
  64563. * @param result the resulting transformnode
  64564. * @returns this TransformNode.
  64565. */
  64566. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  64567. /**
  64568. * Sets this transform node rotation to the given local axis.
  64569. * @param localAxis the axis in local space
  64570. * @param yawCor optional yaw (y-axis) correction in radians
  64571. * @param pitchCor optional pitch (x-axis) correction in radians
  64572. * @param rollCor optional roll (z-axis) correction in radians
  64573. * @returns this TransformNode
  64574. */
  64575. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  64576. /**
  64577. * Sets a new pivot point to the current node
  64578. * @param point defines the new pivot point to use
  64579. * @param space defines if the point is in world or local space (local by default)
  64580. * @returns the current TransformNode
  64581. */
  64582. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  64583. /**
  64584. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  64585. * @returns the pivot point
  64586. */
  64587. getPivotPoint(): Vector3;
  64588. /**
  64589. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  64590. * @param result the vector3 to store the result
  64591. * @returns this TransformNode.
  64592. */
  64593. getPivotPointToRef(result: Vector3): TransformNode;
  64594. /**
  64595. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  64596. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  64597. */
  64598. getAbsolutePivotPoint(): Vector3;
  64599. /**
  64600. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  64601. * @param result vector3 to store the result
  64602. * @returns this TransformNode.
  64603. */
  64604. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  64605. /**
  64606. * Defines the passed node as the parent of the current node.
  64607. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  64608. * @param node the node ot set as the parent
  64609. * @returns this TransformNode.
  64610. */
  64611. setParent(node: Nullable<Node>): TransformNode;
  64612. private _nonUniformScaling;
  64613. /**
  64614. * True if the scaling property of this object is non uniform eg. (1,2,1)
  64615. */
  64616. readonly nonUniformScaling: boolean;
  64617. /** @hidden */
  64618. _updateNonUniformScalingState(value: boolean): boolean;
  64619. /**
  64620. * Attach the current TransformNode to another TransformNode associated with a bone
  64621. * @param bone Bone affecting the TransformNode
  64622. * @param affectedTransformNode TransformNode associated with the bone
  64623. * @returns this object
  64624. */
  64625. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  64626. /**
  64627. * Detach the transform node if its associated with a bone
  64628. * @returns this object
  64629. */
  64630. detachFromBone(): TransformNode;
  64631. private static _rotationAxisCache;
  64632. /**
  64633. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  64634. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  64635. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  64636. * The passed axis is also normalized.
  64637. * @param axis the axis to rotate around
  64638. * @param amount the amount to rotate in radians
  64639. * @param space Space to rotate in (Default: local)
  64640. * @returns the TransformNode.
  64641. */
  64642. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  64643. /**
  64644. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  64645. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  64646. * The passed axis is also normalized. .
  64647. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  64648. * @param point the point to rotate around
  64649. * @param axis the axis to rotate around
  64650. * @param amount the amount to rotate in radians
  64651. * @returns the TransformNode
  64652. */
  64653. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  64654. /**
  64655. * Translates the mesh along the axis vector for the passed distance in the given space.
  64656. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  64657. * @param axis the axis to translate in
  64658. * @param distance the distance to translate
  64659. * @param space Space to rotate in (Default: local)
  64660. * @returns the TransformNode.
  64661. */
  64662. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  64663. /**
  64664. * Adds a rotation step to the mesh current rotation.
  64665. * x, y, z are Euler angles expressed in radians.
  64666. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  64667. * This means this rotation is made in the mesh local space only.
  64668. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  64669. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  64670. * ```javascript
  64671. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  64672. * ```
  64673. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  64674. * 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.
  64675. * @param x Rotation to add
  64676. * @param y Rotation to add
  64677. * @param z Rotation to add
  64678. * @returns the TransformNode.
  64679. */
  64680. addRotation(x: number, y: number, z: number): TransformNode;
  64681. /**
  64682. * Computes the world matrix of the node
  64683. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  64684. * @returns the world matrix
  64685. */
  64686. computeWorldMatrix(force?: boolean): Matrix;
  64687. protected _afterComputeWorldMatrix(): void;
  64688. /**
  64689. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  64690. * @param func callback function to add
  64691. *
  64692. * @returns the TransformNode.
  64693. */
  64694. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  64695. /**
  64696. * Removes a registered callback function.
  64697. * @param func callback function to remove
  64698. * @returns the TransformNode.
  64699. */
  64700. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  64701. /**
  64702. * Gets the position of the current mesh in camera space
  64703. * @param camera defines the camera to use
  64704. * @returns a position
  64705. */
  64706. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  64707. /**
  64708. * Returns the distance from the mesh to the active camera
  64709. * @param camera defines the camera to use
  64710. * @returns the distance
  64711. */
  64712. getDistanceToCamera(camera?: Nullable<Camera>): number;
  64713. /**
  64714. * Clone the current transform node
  64715. * @param name Name of the new clone
  64716. * @param newParent New parent for the clone
  64717. * @param doNotCloneChildren Do not clone children hierarchy
  64718. * @returns the new transform node
  64719. */
  64720. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  64721. /**
  64722. * Serializes the objects information.
  64723. * @param currentSerializationObject defines the object to serialize in
  64724. * @returns the serialized object
  64725. */
  64726. serialize(currentSerializationObject?: any): any;
  64727. /**
  64728. * Returns a new TransformNode object parsed from the source provided.
  64729. * @param parsedTransformNode is the source.
  64730. * @param scene the scne the object belongs to
  64731. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  64732. * @returns a new TransformNode object parsed from the source provided.
  64733. */
  64734. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  64735. /**
  64736. * Get all child-transformNodes of this node
  64737. * @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
  64738. * @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
  64739. * @returns an array of TransformNode
  64740. */
  64741. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  64742. /**
  64743. * Releases resources associated with this transform node.
  64744. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  64745. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  64746. */
  64747. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  64748. }
  64749. }
  64750. declare module BABYLON {
  64751. /**
  64752. * Class used to override all child animations of a given target
  64753. */
  64754. export class AnimationPropertiesOverride {
  64755. /**
  64756. * Gets or sets a value indicating if animation blending must be used
  64757. */
  64758. enableBlending: boolean;
  64759. /**
  64760. * Gets or sets the blending speed to use when enableBlending is true
  64761. */
  64762. blendingSpeed: number;
  64763. /**
  64764. * Gets or sets the default loop mode to use
  64765. */
  64766. loopMode: number;
  64767. }
  64768. }
  64769. declare module BABYLON {
  64770. /**
  64771. * Class used to store bone information
  64772. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  64773. */
  64774. export class Bone extends Node {
  64775. /**
  64776. * defines the bone name
  64777. */
  64778. name: string;
  64779. private static _tmpVecs;
  64780. private static _tmpQuat;
  64781. private static _tmpMats;
  64782. /**
  64783. * Gets the list of child bones
  64784. */
  64785. children: Bone[];
  64786. /** Gets the animations associated with this bone */
  64787. animations: Animation[];
  64788. /**
  64789. * Gets or sets bone length
  64790. */
  64791. length: number;
  64792. /**
  64793. * @hidden Internal only
  64794. * Set this value to map this bone to a different index in the transform matrices
  64795. * Set this value to -1 to exclude the bone from the transform matrices
  64796. */
  64797. _index: Nullable<number>;
  64798. private _skeleton;
  64799. private _localMatrix;
  64800. private _restPose;
  64801. private _baseMatrix;
  64802. private _absoluteTransform;
  64803. private _invertedAbsoluteTransform;
  64804. private _parent;
  64805. private _scalingDeterminant;
  64806. private _worldTransform;
  64807. private _localScaling;
  64808. private _localRotation;
  64809. private _localPosition;
  64810. private _needToDecompose;
  64811. private _needToCompose;
  64812. /** @hidden */
  64813. _linkedTransformNode: Nullable<TransformNode>;
  64814. /** @hidden */
  64815. /** @hidden */
  64816. _matrix: Matrix;
  64817. /**
  64818. * Create a new bone
  64819. * @param name defines the bone name
  64820. * @param skeleton defines the parent skeleton
  64821. * @param parentBone defines the parent (can be null if the bone is the root)
  64822. * @param localMatrix defines the local matrix
  64823. * @param restPose defines the rest pose matrix
  64824. * @param baseMatrix defines the base matrix
  64825. * @param index defines index of the bone in the hiearchy
  64826. */
  64827. constructor(
  64828. /**
  64829. * defines the bone name
  64830. */
  64831. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  64832. /**
  64833. * Gets the parent skeleton
  64834. * @returns a skeleton
  64835. */
  64836. getSkeleton(): Skeleton;
  64837. /**
  64838. * Gets parent bone
  64839. * @returns a bone or null if the bone is the root of the bone hierarchy
  64840. */
  64841. getParent(): Nullable<Bone>;
  64842. /**
  64843. * Sets the parent bone
  64844. * @param parent defines the parent (can be null if the bone is the root)
  64845. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  64846. */
  64847. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  64848. /**
  64849. * Gets the local matrix
  64850. * @returns a matrix
  64851. */
  64852. getLocalMatrix(): Matrix;
  64853. /**
  64854. * Gets the base matrix (initial matrix which remains unchanged)
  64855. * @returns a matrix
  64856. */
  64857. getBaseMatrix(): Matrix;
  64858. /**
  64859. * Gets the rest pose matrix
  64860. * @returns a matrix
  64861. */
  64862. getRestPose(): Matrix;
  64863. /**
  64864. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  64865. */
  64866. getWorldMatrix(): Matrix;
  64867. /**
  64868. * Sets the local matrix to rest pose matrix
  64869. */
  64870. returnToRest(): void;
  64871. /**
  64872. * Gets the inverse of the absolute transform matrix.
  64873. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  64874. * @returns a matrix
  64875. */
  64876. getInvertedAbsoluteTransform(): Matrix;
  64877. /**
  64878. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  64879. * @returns a matrix
  64880. */
  64881. getAbsoluteTransform(): Matrix;
  64882. /**
  64883. * Links with the given transform node.
  64884. * The local matrix of this bone is copied from the transform node every frame.
  64885. * @param transformNode defines the transform node to link to
  64886. */
  64887. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  64888. /** Gets or sets current position (in local space) */
  64889. position: Vector3;
  64890. /** Gets or sets current rotation (in local space) */
  64891. rotation: Vector3;
  64892. /** Gets or sets current rotation quaternion (in local space) */
  64893. rotationQuaternion: Quaternion;
  64894. /** Gets or sets current scaling (in local space) */
  64895. scaling: Vector3;
  64896. /**
  64897. * Gets the animation properties override
  64898. */
  64899. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  64900. private _decompose;
  64901. private _compose;
  64902. /**
  64903. * Update the base and local matrices
  64904. * @param matrix defines the new base or local matrix
  64905. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  64906. * @param updateLocalMatrix defines if the local matrix should be updated
  64907. */
  64908. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  64909. /** @hidden */
  64910. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  64911. /**
  64912. * Flag the bone as dirty (Forcing it to update everything)
  64913. */
  64914. markAsDirty(): void;
  64915. private _markAsDirtyAndCompose;
  64916. private _markAsDirtyAndDecompose;
  64917. /**
  64918. * Translate the bone in local or world space
  64919. * @param vec The amount to translate the bone
  64920. * @param space The space that the translation is in
  64921. * @param mesh The mesh that this bone is attached to. This is only used in world space
  64922. */
  64923. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  64924. /**
  64925. * Set the postion of the bone in local or world space
  64926. * @param position The position to set the bone
  64927. * @param space The space that the position is in
  64928. * @param mesh The mesh that this bone is attached to. This is only used in world space
  64929. */
  64930. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  64931. /**
  64932. * Set the absolute position of the bone (world space)
  64933. * @param position The position to set the bone
  64934. * @param mesh The mesh that this bone is attached to
  64935. */
  64936. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  64937. /**
  64938. * Scale the bone on the x, y and z axes (in local space)
  64939. * @param x The amount to scale the bone on the x axis
  64940. * @param y The amount to scale the bone on the y axis
  64941. * @param z The amount to scale the bone on the z axis
  64942. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  64943. */
  64944. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  64945. /**
  64946. * Set the bone scaling in local space
  64947. * @param scale defines the scaling vector
  64948. */
  64949. setScale(scale: Vector3): void;
  64950. /**
  64951. * Gets the current scaling in local space
  64952. * @returns the current scaling vector
  64953. */
  64954. getScale(): Vector3;
  64955. /**
  64956. * Gets the current scaling in local space and stores it in a target vector
  64957. * @param result defines the target vector
  64958. */
  64959. getScaleToRef(result: Vector3): void;
  64960. /**
  64961. * Set the yaw, pitch, and roll of the bone in local or world space
  64962. * @param yaw The rotation of the bone on the y axis
  64963. * @param pitch The rotation of the bone on the x axis
  64964. * @param roll The rotation of the bone on the z axis
  64965. * @param space The space that the axes of rotation are in
  64966. * @param mesh The mesh that this bone is attached to. This is only used in world space
  64967. */
  64968. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  64969. /**
  64970. * Add a rotation to the bone on an axis in local or world space
  64971. * @param axis The axis to rotate the bone on
  64972. * @param amount The amount to rotate the bone
  64973. * @param space The space that the axis is in
  64974. * @param mesh The mesh that this bone is attached to. This is only used in world space
  64975. */
  64976. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  64977. /**
  64978. * Set the rotation of the bone to a particular axis angle in local or world space
  64979. * @param axis The axis to rotate the bone on
  64980. * @param angle The angle that the bone should be rotated to
  64981. * @param space The space that the axis is in
  64982. * @param mesh The mesh that this bone is attached to. This is only used in world space
  64983. */
  64984. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  64985. /**
  64986. * Set the euler rotation of the bone in local of world space
  64987. * @param rotation The euler rotation that the bone should be set to
  64988. * @param space The space that the rotation is in
  64989. * @param mesh The mesh that this bone is attached to. This is only used in world space
  64990. */
  64991. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  64992. /**
  64993. * Set the quaternion rotation of the bone in local of world space
  64994. * @param quat The quaternion rotation that the bone should be set to
  64995. * @param space The space that the rotation is in
  64996. * @param mesh The mesh that this bone is attached to. This is only used in world space
  64997. */
  64998. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  64999. /**
  65000. * Set the rotation matrix of the bone in local of world space
  65001. * @param rotMat The rotation matrix that the bone should be set to
  65002. * @param space The space that the rotation is in
  65003. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65004. */
  65005. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  65006. private _rotateWithMatrix;
  65007. private _getNegativeRotationToRef;
  65008. /**
  65009. * Get the position of the bone in local or world space
  65010. * @param space The space that the returned position is in
  65011. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65012. * @returns The position of the bone
  65013. */
  65014. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  65015. /**
  65016. * Copy the position of the bone to a vector3 in local or world space
  65017. * @param space The space that the returned position is in
  65018. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65019. * @param result The vector3 to copy the position to
  65020. */
  65021. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  65022. /**
  65023. * Get the absolute position of the bone (world space)
  65024. * @param mesh The mesh that this bone is attached to
  65025. * @returns The absolute position of the bone
  65026. */
  65027. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  65028. /**
  65029. * Copy the absolute position of the bone (world space) to the result param
  65030. * @param mesh The mesh that this bone is attached to
  65031. * @param result The vector3 to copy the absolute position to
  65032. */
  65033. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  65034. /**
  65035. * Compute the absolute transforms of this bone and its children
  65036. */
  65037. computeAbsoluteTransforms(): void;
  65038. /**
  65039. * Get the world direction from an axis that is in the local space of the bone
  65040. * @param localAxis The local direction that is used to compute the world direction
  65041. * @param mesh The mesh that this bone is attached to
  65042. * @returns The world direction
  65043. */
  65044. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  65045. /**
  65046. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  65047. * @param localAxis The local direction that is used to compute the world direction
  65048. * @param mesh The mesh that this bone is attached to
  65049. * @param result The vector3 that the world direction will be copied to
  65050. */
  65051. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65052. /**
  65053. * Get the euler rotation of the bone in local or world space
  65054. * @param space The space that the rotation should be in
  65055. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65056. * @returns The euler rotation
  65057. */
  65058. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  65059. /**
  65060. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  65061. * @param space The space that the rotation should be in
  65062. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65063. * @param result The vector3 that the rotation should be copied to
  65064. */
  65065. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65066. /**
  65067. * Get the quaternion rotation of the bone in either local or world space
  65068. * @param space The space that the rotation should be in
  65069. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65070. * @returns The quaternion rotation
  65071. */
  65072. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  65073. /**
  65074. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  65075. * @param space The space that the rotation should be in
  65076. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65077. * @param result The quaternion that the rotation should be copied to
  65078. */
  65079. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  65080. /**
  65081. * Get the rotation matrix of the bone in local or world space
  65082. * @param space The space that the rotation should be in
  65083. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65084. * @returns The rotation matrix
  65085. */
  65086. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  65087. /**
  65088. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  65089. * @param space The space that the rotation should be in
  65090. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65091. * @param result The quaternion that the rotation should be copied to
  65092. */
  65093. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  65094. /**
  65095. * Get the world position of a point that is in the local space of the bone
  65096. * @param position The local position
  65097. * @param mesh The mesh that this bone is attached to
  65098. * @returns The world position
  65099. */
  65100. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  65101. /**
  65102. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  65103. * @param position The local position
  65104. * @param mesh The mesh that this bone is attached to
  65105. * @param result The vector3 that the world position should be copied to
  65106. */
  65107. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65108. /**
  65109. * Get the local position of a point that is in world space
  65110. * @param position The world position
  65111. * @param mesh The mesh that this bone is attached to
  65112. * @returns The local position
  65113. */
  65114. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  65115. /**
  65116. * Get the local position of a point that is in world space and copy it to the result param
  65117. * @param position The world position
  65118. * @param mesh The mesh that this bone is attached to
  65119. * @param result The vector3 that the local position should be copied to
  65120. */
  65121. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65122. }
  65123. }
  65124. declare module BABYLON {
  65125. /**
  65126. * Class for creating a cube texture
  65127. */
  65128. export class CubeTexture extends BaseTexture {
  65129. private _delayedOnLoad;
  65130. /**
  65131. * The url of the texture
  65132. */
  65133. url: string;
  65134. /**
  65135. * Gets or sets the center of the bounding box associated with the cube texture.
  65136. * It must define where the camera used to render the texture was set
  65137. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  65138. */
  65139. boundingBoxPosition: Vector3;
  65140. private _boundingBoxSize;
  65141. /**
  65142. * Gets or sets the size of the bounding box associated with the cube texture
  65143. * When defined, the cubemap will switch to local mode
  65144. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  65145. * @example https://www.babylonjs-playground.com/#RNASML
  65146. */
  65147. /**
  65148. * Returns the bounding box size
  65149. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  65150. */
  65151. boundingBoxSize: Vector3;
  65152. protected _rotationY: number;
  65153. /**
  65154. * Sets texture matrix rotation angle around Y axis in radians.
  65155. */
  65156. /**
  65157. * Gets texture matrix rotation angle around Y axis radians.
  65158. */
  65159. rotationY: number;
  65160. /**
  65161. * Are mip maps generated for this texture or not.
  65162. */
  65163. readonly noMipmap: boolean;
  65164. private _noMipmap;
  65165. private _files;
  65166. private _extensions;
  65167. private _textureMatrix;
  65168. private _format;
  65169. private _createPolynomials;
  65170. /** @hidden */
  65171. _prefiltered: boolean;
  65172. /**
  65173. * Creates a cube texture from an array of image urls
  65174. * @param files defines an array of image urls
  65175. * @param scene defines the hosting scene
  65176. * @param noMipmap specifies if mip maps are not used
  65177. * @returns a cube texture
  65178. */
  65179. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  65180. /**
  65181. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  65182. * @param url defines the url of the prefiltered texture
  65183. * @param scene defines the scene the texture is attached to
  65184. * @param forcedExtension defines the extension of the file if different from the url
  65185. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  65186. * @return the prefiltered texture
  65187. */
  65188. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  65189. /**
  65190. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  65191. * as prefiltered data.
  65192. * @param rootUrl defines the url of the texture or the root name of the six images
  65193. * @param scene defines the scene the texture is attached to
  65194. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  65195. * @param noMipmap defines if mipmaps should be created or not
  65196. * @param files defines the six files to load for the different faces
  65197. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  65198. * @param onError defines a callback triggered in case of error during load
  65199. * @param format defines the internal format to use for the texture once loaded
  65200. * @param prefiltered defines whether or not the texture is created from prefiltered data
  65201. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  65202. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  65203. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  65204. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  65205. * @return the cube texture
  65206. */
  65207. 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);
  65208. /**
  65209. * Get the current class name of the texture useful for serialization or dynamic coding.
  65210. * @returns "CubeTexture"
  65211. */
  65212. getClassName(): string;
  65213. /**
  65214. * Update the url (and optional buffer) of this texture if url was null during construction.
  65215. * @param url the url of the texture
  65216. * @param forcedExtension defines the extension to use
  65217. * @param onLoad callback called when the texture is loaded (defaults to null)
  65218. */
  65219. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  65220. /**
  65221. * Delays loading of the cube texture
  65222. * @param forcedExtension defines the extension to use
  65223. */
  65224. delayLoad(forcedExtension?: string): void;
  65225. /**
  65226. * Returns the reflection texture matrix
  65227. * @returns the reflection texture matrix
  65228. */
  65229. getReflectionTextureMatrix(): Matrix;
  65230. /**
  65231. * Sets the reflection texture matrix
  65232. * @param value Reflection texture matrix
  65233. */
  65234. setReflectionTextureMatrix(value: Matrix): void;
  65235. /**
  65236. * Parses text to create a cube texture
  65237. * @param parsedTexture define the serialized text to read from
  65238. * @param scene defines the hosting scene
  65239. * @param rootUrl defines the root url of the cube texture
  65240. * @returns a cube texture
  65241. */
  65242. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  65243. /**
  65244. * Makes a clone, or deep copy, of the cube texture
  65245. * @returns a new cube texture
  65246. */
  65247. clone(): CubeTexture;
  65248. }
  65249. }
  65250. declare module BABYLON {
  65251. /** @hidden */
  65252. export var postprocessVertexShader: {
  65253. name: string;
  65254. shader: string;
  65255. };
  65256. }
  65257. declare module BABYLON {
  65258. /**
  65259. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  65260. * This is the base of the follow, arc rotate cameras and Free camera
  65261. * @see http://doc.babylonjs.com/features/cameras
  65262. */
  65263. export class TargetCamera extends Camera {
  65264. private static _RigCamTransformMatrix;
  65265. private static _TargetTransformMatrix;
  65266. private static _TargetFocalPoint;
  65267. /**
  65268. * Define the current direction the camera is moving to
  65269. */
  65270. cameraDirection: Vector3;
  65271. /**
  65272. * Define the current rotation the camera is rotating to
  65273. */
  65274. cameraRotation: Vector2;
  65275. /**
  65276. * When set, the up vector of the camera will be updated by the rotation of the camera
  65277. */
  65278. updateUpVectorFromRotation: boolean;
  65279. private _tmpQuaternion;
  65280. /**
  65281. * Define the current rotation of the camera
  65282. */
  65283. rotation: Vector3;
  65284. /**
  65285. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  65286. */
  65287. rotationQuaternion: Quaternion;
  65288. /**
  65289. * Define the current speed of the camera
  65290. */
  65291. speed: number;
  65292. /**
  65293. * Add cconstraint to the camera to prevent it to move freely in all directions and
  65294. * around all axis.
  65295. */
  65296. noRotationConstraint: boolean;
  65297. /**
  65298. * Define the current target of the camera as an object or a position.
  65299. */
  65300. lockedTarget: any;
  65301. /** @hidden */
  65302. _currentTarget: Vector3;
  65303. /** @hidden */
  65304. _initialFocalDistance: number;
  65305. /** @hidden */
  65306. _viewMatrix: Matrix;
  65307. /** @hidden */
  65308. _camMatrix: Matrix;
  65309. /** @hidden */
  65310. _cameraTransformMatrix: Matrix;
  65311. /** @hidden */
  65312. _cameraRotationMatrix: Matrix;
  65313. /** @hidden */
  65314. _referencePoint: Vector3;
  65315. /** @hidden */
  65316. _transformedReferencePoint: Vector3;
  65317. protected _globalCurrentTarget: Vector3;
  65318. protected _globalCurrentUpVector: Vector3;
  65319. /** @hidden */
  65320. _reset: () => void;
  65321. private _defaultUp;
  65322. /**
  65323. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  65324. * This is the base of the follow, arc rotate cameras and Free camera
  65325. * @see http://doc.babylonjs.com/features/cameras
  65326. * @param name Defines the name of the camera in the scene
  65327. * @param position Defines the start position of the camera in the scene
  65328. * @param scene Defines the scene the camera belongs to
  65329. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  65330. */
  65331. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  65332. /**
  65333. * Gets the position in front of the camera at a given distance.
  65334. * @param distance The distance from the camera we want the position to be
  65335. * @returns the position
  65336. */
  65337. getFrontPosition(distance: number): Vector3;
  65338. /** @hidden */
  65339. _getLockedTargetPosition(): Nullable<Vector3>;
  65340. private _storedPosition;
  65341. private _storedRotation;
  65342. private _storedRotationQuaternion;
  65343. /**
  65344. * Store current camera state of the camera (fov, position, rotation, etc..)
  65345. * @returns the camera
  65346. */
  65347. storeState(): Camera;
  65348. /**
  65349. * Restored camera state. You must call storeState() first
  65350. * @returns whether it was successful or not
  65351. * @hidden
  65352. */
  65353. _restoreStateValues(): boolean;
  65354. /** @hidden */
  65355. _initCache(): void;
  65356. /** @hidden */
  65357. _updateCache(ignoreParentClass?: boolean): void;
  65358. /** @hidden */
  65359. _isSynchronizedViewMatrix(): boolean;
  65360. /** @hidden */
  65361. _computeLocalCameraSpeed(): number;
  65362. /** @hidden */
  65363. setTarget(target: Vector3): void;
  65364. /**
  65365. * Return the current target position of the camera. This value is expressed in local space.
  65366. * @returns the target position
  65367. */
  65368. getTarget(): Vector3;
  65369. /** @hidden */
  65370. _decideIfNeedsToMove(): boolean;
  65371. /** @hidden */
  65372. _updatePosition(): void;
  65373. /** @hidden */
  65374. _checkInputs(): void;
  65375. protected _updateCameraRotationMatrix(): void;
  65376. /**
  65377. * 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)
  65378. * @returns the current camera
  65379. */
  65380. private _rotateUpVectorWithCameraRotationMatrix;
  65381. private _cachedRotationZ;
  65382. private _cachedQuaternionRotationZ;
  65383. /** @hidden */
  65384. _getViewMatrix(): Matrix;
  65385. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  65386. /**
  65387. * @hidden
  65388. */
  65389. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  65390. /**
  65391. * @hidden
  65392. */
  65393. _updateRigCameras(): void;
  65394. private _getRigCamPositionAndTarget;
  65395. /**
  65396. * Gets the current object class name.
  65397. * @return the class name
  65398. */
  65399. getClassName(): string;
  65400. }
  65401. }
  65402. declare module BABYLON {
  65403. /**
  65404. * @ignore
  65405. * This is a list of all the different input types that are available in the application.
  65406. * Fo instance: ArcRotateCameraGamepadInput...
  65407. */
  65408. export var CameraInputTypes: {};
  65409. /**
  65410. * This is the contract to implement in order to create a new input class.
  65411. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  65412. */
  65413. export interface ICameraInput<TCamera extends Camera> {
  65414. /**
  65415. * Defines the camera the input is attached to.
  65416. */
  65417. camera: Nullable<TCamera>;
  65418. /**
  65419. * Gets the class name of the current intput.
  65420. * @returns the class name
  65421. */
  65422. getClassName(): string;
  65423. /**
  65424. * Get the friendly name associated with the input class.
  65425. * @returns the input friendly name
  65426. */
  65427. getSimpleName(): string;
  65428. /**
  65429. * Attach the input controls to a specific dom element to get the input from.
  65430. * @param element Defines the element the controls should be listened from
  65431. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  65432. */
  65433. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  65434. /**
  65435. * Detach the current controls from the specified dom element.
  65436. * @param element Defines the element to stop listening the inputs from
  65437. */
  65438. detachControl(element: Nullable<HTMLElement>): void;
  65439. /**
  65440. * Update the current camera state depending on the inputs that have been used this frame.
  65441. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  65442. */
  65443. checkInputs?: () => void;
  65444. }
  65445. /**
  65446. * Represents a map of input types to input instance or input index to input instance.
  65447. */
  65448. export interface CameraInputsMap<TCamera extends Camera> {
  65449. /**
  65450. * Accessor to the input by input type.
  65451. */
  65452. [name: string]: ICameraInput<TCamera>;
  65453. /**
  65454. * Accessor to the input by input index.
  65455. */
  65456. [idx: number]: ICameraInput<TCamera>;
  65457. }
  65458. /**
  65459. * This represents the input manager used within a camera.
  65460. * It helps dealing with all the different kind of input attached to a camera.
  65461. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  65462. */
  65463. export class CameraInputsManager<TCamera extends Camera> {
  65464. /**
  65465. * Defines the list of inputs attahed to the camera.
  65466. */
  65467. attached: CameraInputsMap<TCamera>;
  65468. /**
  65469. * Defines the dom element the camera is collecting inputs from.
  65470. * This is null if the controls have not been attached.
  65471. */
  65472. attachedElement: Nullable<HTMLElement>;
  65473. /**
  65474. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  65475. */
  65476. noPreventDefault: boolean;
  65477. /**
  65478. * Defined the camera the input manager belongs to.
  65479. */
  65480. camera: TCamera;
  65481. /**
  65482. * Update the current camera state depending on the inputs that have been used this frame.
  65483. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  65484. */
  65485. checkInputs: () => void;
  65486. /**
  65487. * Instantiate a new Camera Input Manager.
  65488. * @param camera Defines the camera the input manager blongs to
  65489. */
  65490. constructor(camera: TCamera);
  65491. /**
  65492. * Add an input method to a camera
  65493. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  65494. * @param input camera input method
  65495. */
  65496. add(input: ICameraInput<TCamera>): void;
  65497. /**
  65498. * Remove a specific input method from a camera
  65499. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  65500. * @param inputToRemove camera input method
  65501. */
  65502. remove(inputToRemove: ICameraInput<TCamera>): void;
  65503. /**
  65504. * Remove a specific input type from a camera
  65505. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  65506. * @param inputType the type of the input to remove
  65507. */
  65508. removeByType(inputType: string): void;
  65509. private _addCheckInputs;
  65510. /**
  65511. * Attach the input controls to the currently attached dom element to listen the events from.
  65512. * @param input Defines the input to attach
  65513. */
  65514. attachInput(input: ICameraInput<TCamera>): void;
  65515. /**
  65516. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  65517. * @param element Defines the dom element to collect the events from
  65518. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  65519. */
  65520. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  65521. /**
  65522. * Detach the current manager inputs controls from a specific dom element.
  65523. * @param element Defines the dom element to collect the events from
  65524. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  65525. */
  65526. detachElement(element: HTMLElement, disconnect?: boolean): void;
  65527. /**
  65528. * Rebuild the dynamic inputCheck function from the current list of
  65529. * defined inputs in the manager.
  65530. */
  65531. rebuildInputCheck(): void;
  65532. /**
  65533. * Remove all attached input methods from a camera
  65534. */
  65535. clear(): void;
  65536. /**
  65537. * Serialize the current input manager attached to a camera.
  65538. * This ensures than once parsed,
  65539. * the input associated to the camera will be identical to the current ones
  65540. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  65541. */
  65542. serialize(serializedCamera: any): void;
  65543. /**
  65544. * Parses an input manager serialized JSON to restore the previous list of inputs
  65545. * and states associated to a camera.
  65546. * @param parsedCamera Defines the JSON to parse
  65547. */
  65548. parse(parsedCamera: any): void;
  65549. }
  65550. }
  65551. declare module BABYLON {
  65552. /**
  65553. * Gather the list of keyboard event types as constants.
  65554. */
  65555. export class KeyboardEventTypes {
  65556. /**
  65557. * The keydown event is fired when a key becomes active (pressed).
  65558. */
  65559. static readonly KEYDOWN: number;
  65560. /**
  65561. * The keyup event is fired when a key has been released.
  65562. */
  65563. static readonly KEYUP: number;
  65564. }
  65565. /**
  65566. * This class is used to store keyboard related info for the onKeyboardObservable event.
  65567. */
  65568. export class KeyboardInfo {
  65569. /**
  65570. * Defines the type of event (KeyboardEventTypes)
  65571. */
  65572. type: number;
  65573. /**
  65574. * Defines the related dom event
  65575. */
  65576. event: KeyboardEvent;
  65577. /**
  65578. * Instantiates a new keyboard info.
  65579. * This class is used to store keyboard related info for the onKeyboardObservable event.
  65580. * @param type Defines the type of event (KeyboardEventTypes)
  65581. * @param event Defines the related dom event
  65582. */
  65583. constructor(
  65584. /**
  65585. * Defines the type of event (KeyboardEventTypes)
  65586. */
  65587. type: number,
  65588. /**
  65589. * Defines the related dom event
  65590. */
  65591. event: KeyboardEvent);
  65592. }
  65593. /**
  65594. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  65595. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  65596. */
  65597. export class KeyboardInfoPre extends KeyboardInfo {
  65598. /**
  65599. * Defines the type of event (KeyboardEventTypes)
  65600. */
  65601. type: number;
  65602. /**
  65603. * Defines the related dom event
  65604. */
  65605. event: KeyboardEvent;
  65606. /**
  65607. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  65608. */
  65609. skipOnPointerObservable: boolean;
  65610. /**
  65611. * Instantiates a new keyboard pre info.
  65612. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  65613. * @param type Defines the type of event (KeyboardEventTypes)
  65614. * @param event Defines the related dom event
  65615. */
  65616. constructor(
  65617. /**
  65618. * Defines the type of event (KeyboardEventTypes)
  65619. */
  65620. type: number,
  65621. /**
  65622. * Defines the related dom event
  65623. */
  65624. event: KeyboardEvent);
  65625. }
  65626. }
  65627. declare module BABYLON {
  65628. /**
  65629. * Manage the keyboard inputs to control the movement of a free camera.
  65630. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  65631. */
  65632. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  65633. /**
  65634. * Defines the camera the input is attached to.
  65635. */
  65636. camera: FreeCamera;
  65637. /**
  65638. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  65639. */
  65640. keysUp: number[];
  65641. /**
  65642. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  65643. */
  65644. keysDown: number[];
  65645. /**
  65646. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  65647. */
  65648. keysLeft: number[];
  65649. /**
  65650. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  65651. */
  65652. keysRight: number[];
  65653. private _keys;
  65654. private _onCanvasBlurObserver;
  65655. private _onKeyboardObserver;
  65656. private _engine;
  65657. private _scene;
  65658. /**
  65659. * Attach the input controls to a specific dom element to get the input from.
  65660. * @param element Defines the element the controls should be listened from
  65661. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  65662. */
  65663. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  65664. /**
  65665. * Detach the current controls from the specified dom element.
  65666. * @param element Defines the element to stop listening the inputs from
  65667. */
  65668. detachControl(element: Nullable<HTMLElement>): void;
  65669. /**
  65670. * Update the current camera state depending on the inputs that have been used this frame.
  65671. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  65672. */
  65673. checkInputs(): void;
  65674. /**
  65675. * Gets the class name of the current intput.
  65676. * @returns the class name
  65677. */
  65678. getClassName(): string;
  65679. /** @hidden */
  65680. _onLostFocus(): void;
  65681. /**
  65682. * Get the friendly name associated with the input class.
  65683. * @returns the input friendly name
  65684. */
  65685. getSimpleName(): string;
  65686. }
  65687. }
  65688. declare module BABYLON {
  65689. /**
  65690. * Interface describing all the common properties and methods a shadow light needs to implement.
  65691. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  65692. * as well as binding the different shadow properties to the effects.
  65693. */
  65694. export interface IShadowLight extends Light {
  65695. /**
  65696. * The light id in the scene (used in scene.findLighById for instance)
  65697. */
  65698. id: string;
  65699. /**
  65700. * The position the shdow will be casted from.
  65701. */
  65702. position: Vector3;
  65703. /**
  65704. * In 2d mode (needCube being false), the direction used to cast the shadow.
  65705. */
  65706. direction: Vector3;
  65707. /**
  65708. * The transformed position. Position of the light in world space taking parenting in account.
  65709. */
  65710. transformedPosition: Vector3;
  65711. /**
  65712. * The transformed direction. Direction of the light in world space taking parenting in account.
  65713. */
  65714. transformedDirection: Vector3;
  65715. /**
  65716. * The friendly name of the light in the scene.
  65717. */
  65718. name: string;
  65719. /**
  65720. * Defines the shadow projection clipping minimum z value.
  65721. */
  65722. shadowMinZ: number;
  65723. /**
  65724. * Defines the shadow projection clipping maximum z value.
  65725. */
  65726. shadowMaxZ: number;
  65727. /**
  65728. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  65729. * @returns true if the information has been computed, false if it does not need to (no parenting)
  65730. */
  65731. computeTransformedInformation(): boolean;
  65732. /**
  65733. * Gets the scene the light belongs to.
  65734. * @returns The scene
  65735. */
  65736. getScene(): Scene;
  65737. /**
  65738. * Callback defining a custom Projection Matrix Builder.
  65739. * This can be used to override the default projection matrix computation.
  65740. */
  65741. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  65742. /**
  65743. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  65744. * @param matrix The materix to updated with the projection information
  65745. * @param viewMatrix The transform matrix of the light
  65746. * @param renderList The list of mesh to render in the map
  65747. * @returns The current light
  65748. */
  65749. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  65750. /**
  65751. * Gets the current depth scale used in ESM.
  65752. * @returns The scale
  65753. */
  65754. getDepthScale(): number;
  65755. /**
  65756. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  65757. * @returns true if a cube texture needs to be use
  65758. */
  65759. needCube(): boolean;
  65760. /**
  65761. * Detects if the projection matrix requires to be recomputed this frame.
  65762. * @returns true if it requires to be recomputed otherwise, false.
  65763. */
  65764. needProjectionMatrixCompute(): boolean;
  65765. /**
  65766. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  65767. */
  65768. forceProjectionMatrixCompute(): void;
  65769. /**
  65770. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  65771. * @param faceIndex The index of the face we are computed the direction to generate shadow
  65772. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  65773. */
  65774. getShadowDirection(faceIndex?: number): Vector3;
  65775. /**
  65776. * Gets the minZ used for shadow according to both the scene and the light.
  65777. * @param activeCamera The camera we are returning the min for
  65778. * @returns the depth min z
  65779. */
  65780. getDepthMinZ(activeCamera: Camera): number;
  65781. /**
  65782. * Gets the maxZ used for shadow according to both the scene and the light.
  65783. * @param activeCamera The camera we are returning the max for
  65784. * @returns the depth max z
  65785. */
  65786. getDepthMaxZ(activeCamera: Camera): number;
  65787. }
  65788. /**
  65789. * Base implementation IShadowLight
  65790. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  65791. */
  65792. export abstract class ShadowLight extends Light implements IShadowLight {
  65793. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  65794. protected _position: Vector3;
  65795. protected _setPosition(value: Vector3): void;
  65796. /**
  65797. * Sets the position the shadow will be casted from. Also use as the light position for both
  65798. * point and spot lights.
  65799. */
  65800. /**
  65801. * Sets the position the shadow will be casted from. Also use as the light position for both
  65802. * point and spot lights.
  65803. */
  65804. position: Vector3;
  65805. protected _direction: Vector3;
  65806. protected _setDirection(value: Vector3): void;
  65807. /**
  65808. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  65809. * Also use as the light direction on spot and directional lights.
  65810. */
  65811. /**
  65812. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  65813. * Also use as the light direction on spot and directional lights.
  65814. */
  65815. direction: Vector3;
  65816. private _shadowMinZ;
  65817. /**
  65818. * Gets the shadow projection clipping minimum z value.
  65819. */
  65820. /**
  65821. * Sets the shadow projection clipping minimum z value.
  65822. */
  65823. shadowMinZ: number;
  65824. private _shadowMaxZ;
  65825. /**
  65826. * Sets the shadow projection clipping maximum z value.
  65827. */
  65828. /**
  65829. * Gets the shadow projection clipping maximum z value.
  65830. */
  65831. shadowMaxZ: number;
  65832. /**
  65833. * Callback defining a custom Projection Matrix Builder.
  65834. * This can be used to override the default projection matrix computation.
  65835. */
  65836. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  65837. /**
  65838. * The transformed position. Position of the light in world space taking parenting in account.
  65839. */
  65840. transformedPosition: Vector3;
  65841. /**
  65842. * The transformed direction. Direction of the light in world space taking parenting in account.
  65843. */
  65844. transformedDirection: Vector3;
  65845. private _needProjectionMatrixCompute;
  65846. /**
  65847. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  65848. * @returns true if the information has been computed, false if it does not need to (no parenting)
  65849. */
  65850. computeTransformedInformation(): boolean;
  65851. /**
  65852. * Return the depth scale used for the shadow map.
  65853. * @returns the depth scale.
  65854. */
  65855. getDepthScale(): number;
  65856. /**
  65857. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  65858. * @param faceIndex The index of the face we are computed the direction to generate shadow
  65859. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  65860. */
  65861. getShadowDirection(faceIndex?: number): Vector3;
  65862. /**
  65863. * Returns the ShadowLight absolute position in the World.
  65864. * @returns the position vector in world space
  65865. */
  65866. getAbsolutePosition(): Vector3;
  65867. /**
  65868. * Sets the ShadowLight direction toward the passed target.
  65869. * @param target The point to target in local space
  65870. * @returns the updated ShadowLight direction
  65871. */
  65872. setDirectionToTarget(target: Vector3): Vector3;
  65873. /**
  65874. * Returns the light rotation in euler definition.
  65875. * @returns the x y z rotation in local space.
  65876. */
  65877. getRotation(): Vector3;
  65878. /**
  65879. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  65880. * @returns true if a cube texture needs to be use
  65881. */
  65882. needCube(): boolean;
  65883. /**
  65884. * Detects if the projection matrix requires to be recomputed this frame.
  65885. * @returns true if it requires to be recomputed otherwise, false.
  65886. */
  65887. needProjectionMatrixCompute(): boolean;
  65888. /**
  65889. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  65890. */
  65891. forceProjectionMatrixCompute(): void;
  65892. /** @hidden */
  65893. _initCache(): void;
  65894. /** @hidden */
  65895. _isSynchronized(): boolean;
  65896. /**
  65897. * Computes the world matrix of the node
  65898. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  65899. * @returns the world matrix
  65900. */
  65901. computeWorldMatrix(force?: boolean): Matrix;
  65902. /**
  65903. * Gets the minZ used for shadow according to both the scene and the light.
  65904. * @param activeCamera The camera we are returning the min for
  65905. * @returns the depth min z
  65906. */
  65907. getDepthMinZ(activeCamera: Camera): number;
  65908. /**
  65909. * Gets the maxZ used for shadow according to both the scene and the light.
  65910. * @param activeCamera The camera we are returning the max for
  65911. * @returns the depth max z
  65912. */
  65913. getDepthMaxZ(activeCamera: Camera): number;
  65914. /**
  65915. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  65916. * @param matrix The materix to updated with the projection information
  65917. * @param viewMatrix The transform matrix of the light
  65918. * @param renderList The list of mesh to render in the map
  65919. * @returns The current light
  65920. */
  65921. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  65922. }
  65923. }
  65924. declare module BABYLON {
  65925. /**
  65926. * "Static Class" containing the most commonly used helper while dealing with material for
  65927. * rendering purpose.
  65928. *
  65929. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  65930. *
  65931. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  65932. */
  65933. export class MaterialHelper {
  65934. /**
  65935. * Bind the current view position to an effect.
  65936. * @param effect The effect to be bound
  65937. * @param scene The scene the eyes position is used from
  65938. */
  65939. static BindEyePosition(effect: Effect, scene: Scene): void;
  65940. /**
  65941. * Helps preparing the defines values about the UVs in used in the effect.
  65942. * UVs are shared as much as we can accross channels in the shaders.
  65943. * @param texture The texture we are preparing the UVs for
  65944. * @param defines The defines to update
  65945. * @param key The channel key "diffuse", "specular"... used in the shader
  65946. */
  65947. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  65948. /**
  65949. * Binds a texture matrix value to its corrsponding uniform
  65950. * @param texture The texture to bind the matrix for
  65951. * @param uniformBuffer The uniform buffer receivin the data
  65952. * @param key The channel key "diffuse", "specular"... used in the shader
  65953. */
  65954. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  65955. /**
  65956. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  65957. * @param mesh defines the current mesh
  65958. * @param scene defines the current scene
  65959. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  65960. * @param pointsCloud defines if point cloud rendering has to be turned on
  65961. * @param fogEnabled defines if fog has to be turned on
  65962. * @param alphaTest defines if alpha testing has to be turned on
  65963. * @param defines defines the current list of defines
  65964. */
  65965. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  65966. /**
  65967. * Helper used to prepare the list of defines associated with frame values for shader compilation
  65968. * @param scene defines the current scene
  65969. * @param engine defines the current engine
  65970. * @param defines specifies the list of active defines
  65971. * @param useInstances defines if instances have to be turned on
  65972. * @param useClipPlane defines if clip plane have to be turned on
  65973. */
  65974. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  65975. /**
  65976. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  65977. * @param mesh The mesh containing the geometry data we will draw
  65978. * @param defines The defines to update
  65979. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  65980. * @param useBones Precise whether bones should be used or not (override mesh info)
  65981. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  65982. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  65983. * @returns false if defines are considered not dirty and have not been checked
  65984. */
  65985. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  65986. /**
  65987. * Prepares the defines related to the light information passed in parameter
  65988. * @param scene The scene we are intending to draw
  65989. * @param mesh The mesh the effect is compiling for
  65990. * @param defines The defines to update
  65991. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  65992. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  65993. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  65994. * @returns true if normals will be required for the rest of the effect
  65995. */
  65996. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  65997. /**
  65998. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  65999. * that won t be acctive due to defines being turned off.
  66000. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  66001. * @param samplersList The samplers list
  66002. * @param defines The defines helping in the list generation
  66003. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  66004. */
  66005. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  66006. /**
  66007. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  66008. * @param defines The defines to update while falling back
  66009. * @param fallbacks The authorized effect fallbacks
  66010. * @param maxSimultaneousLights The maximum number of lights allowed
  66011. * @param rank the current rank of the Effect
  66012. * @returns The newly affected rank
  66013. */
  66014. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  66015. /**
  66016. * Prepares the list of attributes required for morph targets according to the effect defines.
  66017. * @param attribs The current list of supported attribs
  66018. * @param mesh The mesh to prepare the morph targets attributes for
  66019. * @param defines The current Defines of the effect
  66020. */
  66021. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  66022. /**
  66023. * Prepares the list of attributes required for bones according to the effect defines.
  66024. * @param attribs The current list of supported attribs
  66025. * @param mesh The mesh to prepare the bones attributes for
  66026. * @param defines The current Defines of the effect
  66027. * @param fallbacks The current efffect fallback strategy
  66028. */
  66029. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  66030. /**
  66031. * Prepares the list of attributes required for instances according to the effect defines.
  66032. * @param attribs The current list of supported attribs
  66033. * @param defines The current Defines of the effect
  66034. */
  66035. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  66036. /**
  66037. * Binds the light shadow information to the effect for the given mesh.
  66038. * @param light The light containing the generator
  66039. * @param scene The scene the lights belongs to
  66040. * @param mesh The mesh we are binding the information to render
  66041. * @param lightIndex The light index in the effect used to render the mesh
  66042. * @param effect The effect we are binding the data to
  66043. */
  66044. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  66045. /**
  66046. * Binds the light information to the effect.
  66047. * @param light The light containing the generator
  66048. * @param effect The effect we are binding the data to
  66049. * @param lightIndex The light index in the effect used to render
  66050. */
  66051. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  66052. /**
  66053. * Binds the lights information from the scene to the effect for the given mesh.
  66054. * @param scene The scene the lights belongs to
  66055. * @param mesh The mesh we are binding the information to render
  66056. * @param effect The effect we are binding the data to
  66057. * @param defines The generated defines for the effect
  66058. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  66059. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  66060. */
  66061. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  66062. private static _tempFogColor;
  66063. /**
  66064. * Binds the fog information from the scene to the effect for the given mesh.
  66065. * @param scene The scene the lights belongs to
  66066. * @param mesh The mesh we are binding the information to render
  66067. * @param effect The effect we are binding the data to
  66068. * @param linearSpace Defines if the fog effect is applied in linear space
  66069. */
  66070. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  66071. /**
  66072. * Binds the bones information from the mesh to the effect.
  66073. * @param mesh The mesh we are binding the information to render
  66074. * @param effect The effect we are binding the data to
  66075. */
  66076. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  66077. /**
  66078. * Binds the morph targets information from the mesh to the effect.
  66079. * @param abstractMesh The mesh we are binding the information to render
  66080. * @param effect The effect we are binding the data to
  66081. */
  66082. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  66083. /**
  66084. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  66085. * @param defines The generated defines used in the effect
  66086. * @param effect The effect we are binding the data to
  66087. * @param scene The scene we are willing to render with logarithmic scale for
  66088. */
  66089. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  66090. /**
  66091. * Binds the clip plane information from the scene to the effect.
  66092. * @param scene The scene the clip plane information are extracted from
  66093. * @param effect The effect we are binding the data to
  66094. */
  66095. static BindClipPlane(effect: Effect, scene: Scene): void;
  66096. }
  66097. }
  66098. declare module BABYLON {
  66099. /** @hidden */
  66100. export var kernelBlurVaryingDeclaration: {
  66101. name: string;
  66102. shader: string;
  66103. };
  66104. }
  66105. declare module BABYLON {
  66106. /** @hidden */
  66107. export var kernelBlurFragment: {
  66108. name: string;
  66109. shader: string;
  66110. };
  66111. }
  66112. declare module BABYLON {
  66113. /** @hidden */
  66114. export var kernelBlurFragment2: {
  66115. name: string;
  66116. shader: string;
  66117. };
  66118. }
  66119. declare module BABYLON {
  66120. /** @hidden */
  66121. export var kernelBlurPixelShader: {
  66122. name: string;
  66123. shader: string;
  66124. };
  66125. }
  66126. declare module BABYLON {
  66127. /** @hidden */
  66128. export var kernelBlurVertex: {
  66129. name: string;
  66130. shader: string;
  66131. };
  66132. }
  66133. declare module BABYLON {
  66134. /** @hidden */
  66135. export var kernelBlurVertexShader: {
  66136. name: string;
  66137. shader: string;
  66138. };
  66139. }
  66140. declare module BABYLON {
  66141. /**
  66142. * The Blur Post Process which blurs an image based on a kernel and direction.
  66143. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  66144. */
  66145. export class BlurPostProcess extends PostProcess {
  66146. /** The direction in which to blur the image. */
  66147. direction: Vector2;
  66148. private blockCompilation;
  66149. protected _kernel: number;
  66150. protected _idealKernel: number;
  66151. protected _packedFloat: boolean;
  66152. private _staticDefines;
  66153. /**
  66154. * Sets the length in pixels of the blur sample region
  66155. */
  66156. /**
  66157. * Gets the length in pixels of the blur sample region
  66158. */
  66159. kernel: number;
  66160. /**
  66161. * Sets wether or not the blur needs to unpack/repack floats
  66162. */
  66163. /**
  66164. * Gets wether or not the blur is unpacking/repacking floats
  66165. */
  66166. packedFloat: boolean;
  66167. /**
  66168. * Creates a new instance BlurPostProcess
  66169. * @param name The name of the effect.
  66170. * @param direction The direction in which to blur the image.
  66171. * @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.
  66172. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  66173. * @param camera The camera to apply the render pass to.
  66174. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66175. * @param engine The engine which the post process will be applied. (default: current engine)
  66176. * @param reusable If the post process can be reused on the same frame. (default: false)
  66177. * @param textureType Type of textures used when performing the post process. (default: 0)
  66178. * @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)
  66179. */
  66180. constructor(name: string,
  66181. /** The direction in which to blur the image. */
  66182. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  66183. /**
  66184. * Updates the effect with the current post process compile time values and recompiles the shader.
  66185. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  66186. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  66187. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  66188. * @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
  66189. * @param onCompiled Called when the shader has been compiled.
  66190. * @param onError Called if there is an error when compiling a shader.
  66191. */
  66192. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  66193. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  66194. /**
  66195. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  66196. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  66197. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  66198. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  66199. * The gaps between physical kernels are compensated for in the weighting of the samples
  66200. * @param idealKernel Ideal blur kernel.
  66201. * @return Nearest best kernel.
  66202. */
  66203. protected _nearestBestKernel(idealKernel: number): number;
  66204. /**
  66205. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  66206. * @param x The point on the Gaussian distribution to sample.
  66207. * @return the value of the Gaussian function at x.
  66208. */
  66209. protected _gaussianWeight(x: number): number;
  66210. /**
  66211. * Generates a string that can be used as a floating point number in GLSL.
  66212. * @param x Value to print.
  66213. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  66214. * @return GLSL float string.
  66215. */
  66216. protected _glslFloat(x: number, decimalFigures?: number): string;
  66217. }
  66218. }
  66219. declare module BABYLON {
  66220. /** @hidden */
  66221. export var shadowMapPixelShader: {
  66222. name: string;
  66223. shader: string;
  66224. };
  66225. }
  66226. declare module BABYLON {
  66227. /** @hidden */
  66228. export var bonesDeclaration: {
  66229. name: string;
  66230. shader: string;
  66231. };
  66232. }
  66233. declare module BABYLON {
  66234. /** @hidden */
  66235. export var morphTargetsVertexGlobalDeclaration: {
  66236. name: string;
  66237. shader: string;
  66238. };
  66239. }
  66240. declare module BABYLON {
  66241. /** @hidden */
  66242. export var morphTargetsVertexDeclaration: {
  66243. name: string;
  66244. shader: string;
  66245. };
  66246. }
  66247. declare module BABYLON {
  66248. /** @hidden */
  66249. export var instancesDeclaration: {
  66250. name: string;
  66251. shader: string;
  66252. };
  66253. }
  66254. declare module BABYLON {
  66255. /** @hidden */
  66256. export var helperFunctions: {
  66257. name: string;
  66258. shader: string;
  66259. };
  66260. }
  66261. declare module BABYLON {
  66262. /** @hidden */
  66263. export var morphTargetsVertex: {
  66264. name: string;
  66265. shader: string;
  66266. };
  66267. }
  66268. declare module BABYLON {
  66269. /** @hidden */
  66270. export var instancesVertex: {
  66271. name: string;
  66272. shader: string;
  66273. };
  66274. }
  66275. declare module BABYLON {
  66276. /** @hidden */
  66277. export var bonesVertex: {
  66278. name: string;
  66279. shader: string;
  66280. };
  66281. }
  66282. declare module BABYLON {
  66283. /** @hidden */
  66284. export var shadowMapVertexShader: {
  66285. name: string;
  66286. shader: string;
  66287. };
  66288. }
  66289. declare module BABYLON {
  66290. /** @hidden */
  66291. export var depthBoxBlurPixelShader: {
  66292. name: string;
  66293. shader: string;
  66294. };
  66295. }
  66296. declare module BABYLON {
  66297. /**
  66298. * Defines the options associated with the creation of a custom shader for a shadow generator.
  66299. */
  66300. export interface ICustomShaderOptions {
  66301. /**
  66302. * Gets or sets the custom shader name to use
  66303. */
  66304. shaderName: string;
  66305. /**
  66306. * The list of attribute names used in the shader
  66307. */
  66308. attributes?: string[];
  66309. /**
  66310. * The list of unifrom names used in the shader
  66311. */
  66312. uniforms?: string[];
  66313. /**
  66314. * The list of sampler names used in the shader
  66315. */
  66316. samplers?: string[];
  66317. /**
  66318. * The list of defines used in the shader
  66319. */
  66320. defines?: string[];
  66321. }
  66322. /**
  66323. * Interface to implement to create a shadow generator compatible with BJS.
  66324. */
  66325. export interface IShadowGenerator {
  66326. /**
  66327. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  66328. * @returns The render target texture if present otherwise, null
  66329. */
  66330. getShadowMap(): Nullable<RenderTargetTexture>;
  66331. /**
  66332. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  66333. * @returns The render target texture if the shadow map is present otherwise, null
  66334. */
  66335. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  66336. /**
  66337. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  66338. * @param subMesh The submesh we want to render in the shadow map
  66339. * @param useInstances Defines wether will draw in the map using instances
  66340. * @returns true if ready otherwise, false
  66341. */
  66342. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66343. /**
  66344. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  66345. * @param defines Defines of the material we want to update
  66346. * @param lightIndex Index of the light in the enabled light list of the material
  66347. */
  66348. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  66349. /**
  66350. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  66351. * defined in the generator but impacting the effect).
  66352. * It implies the unifroms available on the materials are the standard BJS ones.
  66353. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  66354. * @param effect The effect we are binfing the information for
  66355. */
  66356. bindShadowLight(lightIndex: string, effect: Effect): void;
  66357. /**
  66358. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  66359. * (eq to shadow prjection matrix * light transform matrix)
  66360. * @returns The transform matrix used to create the shadow map
  66361. */
  66362. getTransformMatrix(): Matrix;
  66363. /**
  66364. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  66365. * Cube and 2D textures for instance.
  66366. */
  66367. recreateShadowMap(): void;
  66368. /**
  66369. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  66370. * @param onCompiled Callback triggered at the and of the effects compilation
  66371. * @param options Sets of optional options forcing the compilation with different modes
  66372. */
  66373. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  66374. useInstances: boolean;
  66375. }>): void;
  66376. /**
  66377. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  66378. * @param options Sets of optional options forcing the compilation with different modes
  66379. * @returns A promise that resolves when the compilation completes
  66380. */
  66381. forceCompilationAsync(options?: Partial<{
  66382. useInstances: boolean;
  66383. }>): Promise<void>;
  66384. /**
  66385. * Serializes the shadow generator setup to a json object.
  66386. * @returns The serialized JSON object
  66387. */
  66388. serialize(): any;
  66389. /**
  66390. * Disposes the Shadow map and related Textures and effects.
  66391. */
  66392. dispose(): void;
  66393. }
  66394. /**
  66395. * Default implementation IShadowGenerator.
  66396. * This is the main object responsible of generating shadows in the framework.
  66397. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  66398. */
  66399. export class ShadowGenerator implements IShadowGenerator {
  66400. /**
  66401. * Shadow generator mode None: no filtering applied.
  66402. */
  66403. static readonly FILTER_NONE: number;
  66404. /**
  66405. * Shadow generator mode ESM: Exponential Shadow Mapping.
  66406. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  66407. */
  66408. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  66409. /**
  66410. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  66411. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  66412. */
  66413. static readonly FILTER_POISSONSAMPLING: number;
  66414. /**
  66415. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  66416. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  66417. */
  66418. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  66419. /**
  66420. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  66421. * edge artifacts on steep falloff.
  66422. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  66423. */
  66424. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  66425. /**
  66426. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  66427. * edge artifacts on steep falloff.
  66428. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  66429. */
  66430. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  66431. /**
  66432. * Shadow generator mode PCF: Percentage Closer Filtering
  66433. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  66434. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  66435. */
  66436. static readonly FILTER_PCF: number;
  66437. /**
  66438. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  66439. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  66440. * Contact Hardening
  66441. */
  66442. static readonly FILTER_PCSS: number;
  66443. /**
  66444. * Reserved for PCF and PCSS
  66445. * Highest Quality.
  66446. *
  66447. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  66448. *
  66449. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  66450. */
  66451. static readonly QUALITY_HIGH: number;
  66452. /**
  66453. * Reserved for PCF and PCSS
  66454. * Good tradeoff for quality/perf cross devices
  66455. *
  66456. * Execute PCF on a 3*3 kernel.
  66457. *
  66458. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  66459. */
  66460. static readonly QUALITY_MEDIUM: number;
  66461. /**
  66462. * Reserved for PCF and PCSS
  66463. * The lowest quality but the fastest.
  66464. *
  66465. * Execute PCF on a 1*1 kernel.
  66466. *
  66467. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  66468. */
  66469. static readonly QUALITY_LOW: number;
  66470. /** Gets or sets the custom shader name to use */
  66471. customShaderOptions: ICustomShaderOptions;
  66472. /**
  66473. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  66474. */
  66475. onBeforeShadowMapRenderObservable: Observable<Effect>;
  66476. private _bias;
  66477. /**
  66478. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  66479. */
  66480. /**
  66481. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  66482. */
  66483. bias: number;
  66484. private _normalBias;
  66485. /**
  66486. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  66487. */
  66488. /**
  66489. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  66490. */
  66491. normalBias: number;
  66492. private _blurBoxOffset;
  66493. /**
  66494. * Gets the blur box offset: offset applied during the blur pass.
  66495. * Only useful if useKernelBlur = false
  66496. */
  66497. /**
  66498. * Sets the blur box offset: offset applied during the blur pass.
  66499. * Only useful if useKernelBlur = false
  66500. */
  66501. blurBoxOffset: number;
  66502. private _blurScale;
  66503. /**
  66504. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  66505. * 2 means half of the size.
  66506. */
  66507. /**
  66508. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  66509. * 2 means half of the size.
  66510. */
  66511. blurScale: number;
  66512. private _blurKernel;
  66513. /**
  66514. * Gets the blur kernel: kernel size of the blur pass.
  66515. * Only useful if useKernelBlur = true
  66516. */
  66517. /**
  66518. * Sets the blur kernel: kernel size of the blur pass.
  66519. * Only useful if useKernelBlur = true
  66520. */
  66521. blurKernel: number;
  66522. private _useKernelBlur;
  66523. /**
  66524. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  66525. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  66526. */
  66527. /**
  66528. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  66529. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  66530. */
  66531. useKernelBlur: boolean;
  66532. private _depthScale;
  66533. /**
  66534. * Gets the depth scale used in ESM mode.
  66535. */
  66536. /**
  66537. * Sets the depth scale used in ESM mode.
  66538. * This can override the scale stored on the light.
  66539. */
  66540. depthScale: number;
  66541. private _filter;
  66542. /**
  66543. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  66544. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  66545. */
  66546. /**
  66547. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  66548. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  66549. */
  66550. filter: number;
  66551. /**
  66552. * Gets if the current filter is set to Poisson Sampling.
  66553. */
  66554. /**
  66555. * Sets the current filter to Poisson Sampling.
  66556. */
  66557. usePoissonSampling: boolean;
  66558. /**
  66559. * Gets if the current filter is set to ESM.
  66560. */
  66561. /**
  66562. * Sets the current filter is to ESM.
  66563. */
  66564. useExponentialShadowMap: boolean;
  66565. /**
  66566. * Gets if the current filter is set to filtered ESM.
  66567. */
  66568. /**
  66569. * Gets if the current filter is set to filtered ESM.
  66570. */
  66571. useBlurExponentialShadowMap: boolean;
  66572. /**
  66573. * Gets if the current filter is set to "close ESM" (using the inverse of the
  66574. * exponential to prevent steep falloff artifacts).
  66575. */
  66576. /**
  66577. * Sets the current filter to "close ESM" (using the inverse of the
  66578. * exponential to prevent steep falloff artifacts).
  66579. */
  66580. useCloseExponentialShadowMap: boolean;
  66581. /**
  66582. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  66583. * exponential to prevent steep falloff artifacts).
  66584. */
  66585. /**
  66586. * Sets the current filter to filtered "close ESM" (using the inverse of the
  66587. * exponential to prevent steep falloff artifacts).
  66588. */
  66589. useBlurCloseExponentialShadowMap: boolean;
  66590. /**
  66591. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  66592. */
  66593. /**
  66594. * Sets the current filter to "PCF" (percentage closer filtering).
  66595. */
  66596. usePercentageCloserFiltering: boolean;
  66597. private _filteringQuality;
  66598. /**
  66599. * Gets the PCF or PCSS Quality.
  66600. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  66601. */
  66602. /**
  66603. * Sets the PCF or PCSS Quality.
  66604. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  66605. */
  66606. filteringQuality: number;
  66607. /**
  66608. * Gets if the current filter is set to "PCSS" (contact hardening).
  66609. */
  66610. /**
  66611. * Sets the current filter to "PCSS" (contact hardening).
  66612. */
  66613. useContactHardeningShadow: boolean;
  66614. private _contactHardeningLightSizeUVRatio;
  66615. /**
  66616. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  66617. * Using a ratio helps keeping shape stability independently of the map size.
  66618. *
  66619. * It does not account for the light projection as it was having too much
  66620. * instability during the light setup or during light position changes.
  66621. *
  66622. * Only valid if useContactHardeningShadow is true.
  66623. */
  66624. /**
  66625. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  66626. * Using a ratio helps keeping shape stability independently of the map size.
  66627. *
  66628. * It does not account for the light projection as it was having too much
  66629. * instability during the light setup or during light position changes.
  66630. *
  66631. * Only valid if useContactHardeningShadow is true.
  66632. */
  66633. contactHardeningLightSizeUVRatio: number;
  66634. private _darkness;
  66635. /**
  66636. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  66637. * 0 means strongest and 1 would means no shadow.
  66638. * @returns the darkness.
  66639. */
  66640. getDarkness(): number;
  66641. /**
  66642. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  66643. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  66644. * @returns the shadow generator allowing fluent coding.
  66645. */
  66646. setDarkness(darkness: number): ShadowGenerator;
  66647. private _transparencyShadow;
  66648. /**
  66649. * Sets the ability to have transparent shadow (boolean).
  66650. * @param transparent True if transparent else False
  66651. * @returns the shadow generator allowing fluent coding
  66652. */
  66653. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  66654. private _shadowMap;
  66655. private _shadowMap2;
  66656. /**
  66657. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  66658. * @returns The render target texture if present otherwise, null
  66659. */
  66660. getShadowMap(): Nullable<RenderTargetTexture>;
  66661. /**
  66662. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  66663. * @returns The render target texture if the shadow map is present otherwise, null
  66664. */
  66665. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  66666. /**
  66667. * Helper function to add a mesh and its descendants to the list of shadow casters.
  66668. * @param mesh Mesh to add
  66669. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  66670. * @returns the Shadow Generator itself
  66671. */
  66672. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  66673. /**
  66674. * Helper function to remove a mesh and its descendants from the list of shadow casters
  66675. * @param mesh Mesh to remove
  66676. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  66677. * @returns the Shadow Generator itself
  66678. */
  66679. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  66680. /**
  66681. * Controls the extent to which the shadows fade out at the edge of the frustum
  66682. * Used only by directionals and spots
  66683. */
  66684. frustumEdgeFalloff: number;
  66685. private _light;
  66686. /**
  66687. * Returns the associated light object.
  66688. * @returns the light generating the shadow
  66689. */
  66690. getLight(): IShadowLight;
  66691. /**
  66692. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  66693. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  66694. * It might on the other hand introduce peter panning.
  66695. */
  66696. forceBackFacesOnly: boolean;
  66697. private _scene;
  66698. private _lightDirection;
  66699. private _effect;
  66700. private _viewMatrix;
  66701. private _projectionMatrix;
  66702. private _transformMatrix;
  66703. private _cachedPosition;
  66704. private _cachedDirection;
  66705. private _cachedDefines;
  66706. private _currentRenderID;
  66707. private _boxBlurPostprocess;
  66708. private _kernelBlurXPostprocess;
  66709. private _kernelBlurYPostprocess;
  66710. private _blurPostProcesses;
  66711. private _mapSize;
  66712. private _currentFaceIndex;
  66713. private _currentFaceIndexCache;
  66714. private _textureType;
  66715. private _defaultTextureMatrix;
  66716. /** @hidden */
  66717. static _SceneComponentInitialization: (scene: Scene) => void;
  66718. /**
  66719. * Creates a ShadowGenerator object.
  66720. * A ShadowGenerator is the required tool to use the shadows.
  66721. * Each light casting shadows needs to use its own ShadowGenerator.
  66722. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  66723. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  66724. * @param light The light object generating the shadows.
  66725. * @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.
  66726. */
  66727. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  66728. private _initializeGenerator;
  66729. private _initializeShadowMap;
  66730. private _initializeBlurRTTAndPostProcesses;
  66731. private _renderForShadowMap;
  66732. private _renderSubMeshForShadowMap;
  66733. private _applyFilterValues;
  66734. /**
  66735. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  66736. * @param onCompiled Callback triggered at the and of the effects compilation
  66737. * @param options Sets of optional options forcing the compilation with different modes
  66738. */
  66739. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  66740. useInstances: boolean;
  66741. }>): void;
  66742. /**
  66743. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  66744. * @param options Sets of optional options forcing the compilation with different modes
  66745. * @returns A promise that resolves when the compilation completes
  66746. */
  66747. forceCompilationAsync(options?: Partial<{
  66748. useInstances: boolean;
  66749. }>): Promise<void>;
  66750. /**
  66751. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  66752. * @param subMesh The submesh we want to render in the shadow map
  66753. * @param useInstances Defines wether will draw in the map using instances
  66754. * @returns true if ready otherwise, false
  66755. */
  66756. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66757. /**
  66758. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  66759. * @param defines Defines of the material we want to update
  66760. * @param lightIndex Index of the light in the enabled light list of the material
  66761. */
  66762. prepareDefines(defines: any, lightIndex: number): void;
  66763. /**
  66764. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  66765. * defined in the generator but impacting the effect).
  66766. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  66767. * @param effect The effect we are binfing the information for
  66768. */
  66769. bindShadowLight(lightIndex: string, effect: Effect): void;
  66770. /**
  66771. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  66772. * (eq to shadow prjection matrix * light transform matrix)
  66773. * @returns The transform matrix used to create the shadow map
  66774. */
  66775. getTransformMatrix(): Matrix;
  66776. /**
  66777. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  66778. * Cube and 2D textures for instance.
  66779. */
  66780. recreateShadowMap(): void;
  66781. private _disposeBlurPostProcesses;
  66782. private _disposeRTTandPostProcesses;
  66783. /**
  66784. * Disposes the ShadowGenerator.
  66785. * Returns nothing.
  66786. */
  66787. dispose(): void;
  66788. /**
  66789. * Serializes the shadow generator setup to a json object.
  66790. * @returns The serialized JSON object
  66791. */
  66792. serialize(): any;
  66793. /**
  66794. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  66795. * @param parsedShadowGenerator The JSON object to parse
  66796. * @param scene The scene to create the shadow map for
  66797. * @returns The parsed shadow generator
  66798. */
  66799. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  66800. }
  66801. }
  66802. declare module BABYLON {
  66803. /**
  66804. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  66805. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  66806. * 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.
  66807. */
  66808. export abstract class Light extends Node {
  66809. /**
  66810. * Falloff Default: light is falling off following the material specification:
  66811. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  66812. */
  66813. static readonly FALLOFF_DEFAULT: number;
  66814. /**
  66815. * Falloff Physical: light is falling off following the inverse squared distance law.
  66816. */
  66817. static readonly FALLOFF_PHYSICAL: number;
  66818. /**
  66819. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  66820. * to enhance interoperability with other engines.
  66821. */
  66822. static readonly FALLOFF_GLTF: number;
  66823. /**
  66824. * Falloff Standard: light is falling off like in the standard material
  66825. * to enhance interoperability with other materials.
  66826. */
  66827. static readonly FALLOFF_STANDARD: number;
  66828. /**
  66829. * If every light affecting the material is in this lightmapMode,
  66830. * material.lightmapTexture adds or multiplies
  66831. * (depends on material.useLightmapAsShadowmap)
  66832. * after every other light calculations.
  66833. */
  66834. static readonly LIGHTMAP_DEFAULT: number;
  66835. /**
  66836. * material.lightmapTexture as only diffuse lighting from this light
  66837. * adds only specular lighting from this light
  66838. * adds dynamic shadows
  66839. */
  66840. static readonly LIGHTMAP_SPECULAR: number;
  66841. /**
  66842. * material.lightmapTexture as only lighting
  66843. * no light calculation from this light
  66844. * only adds dynamic shadows from this light
  66845. */
  66846. static readonly LIGHTMAP_SHADOWSONLY: number;
  66847. /**
  66848. * Each light type uses the default quantity according to its type:
  66849. * point/spot lights use luminous intensity
  66850. * directional lights use illuminance
  66851. */
  66852. static readonly INTENSITYMODE_AUTOMATIC: number;
  66853. /**
  66854. * lumen (lm)
  66855. */
  66856. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  66857. /**
  66858. * candela (lm/sr)
  66859. */
  66860. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  66861. /**
  66862. * lux (lm/m^2)
  66863. */
  66864. static readonly INTENSITYMODE_ILLUMINANCE: number;
  66865. /**
  66866. * nit (cd/m^2)
  66867. */
  66868. static readonly INTENSITYMODE_LUMINANCE: number;
  66869. /**
  66870. * Light type const id of the point light.
  66871. */
  66872. static readonly LIGHTTYPEID_POINTLIGHT: number;
  66873. /**
  66874. * Light type const id of the directional light.
  66875. */
  66876. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  66877. /**
  66878. * Light type const id of the spot light.
  66879. */
  66880. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  66881. /**
  66882. * Light type const id of the hemispheric light.
  66883. */
  66884. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  66885. /**
  66886. * Diffuse gives the basic color to an object.
  66887. */
  66888. diffuse: Color3;
  66889. /**
  66890. * Specular produces a highlight color on an object.
  66891. * Note: This is note affecting PBR materials.
  66892. */
  66893. specular: Color3;
  66894. /**
  66895. * Defines the falloff type for this light. This lets overrriding how punctual light are
  66896. * falling off base on range or angle.
  66897. * This can be set to any values in Light.FALLOFF_x.
  66898. *
  66899. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  66900. * other types of materials.
  66901. */
  66902. falloffType: number;
  66903. /**
  66904. * Strength of the light.
  66905. * Note: By default it is define in the framework own unit.
  66906. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  66907. */
  66908. intensity: number;
  66909. private _range;
  66910. protected _inverseSquaredRange: number;
  66911. /**
  66912. * Defines how far from the source the light is impacting in scene units.
  66913. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  66914. */
  66915. /**
  66916. * Defines how far from the source the light is impacting in scene units.
  66917. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  66918. */
  66919. range: number;
  66920. /**
  66921. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  66922. * of light.
  66923. */
  66924. private _photometricScale;
  66925. private _intensityMode;
  66926. /**
  66927. * Gets the photometric scale used to interpret the intensity.
  66928. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  66929. */
  66930. /**
  66931. * Sets the photometric scale used to interpret the intensity.
  66932. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  66933. */
  66934. intensityMode: number;
  66935. private _radius;
  66936. /**
  66937. * Gets the light radius used by PBR Materials to simulate soft area lights.
  66938. */
  66939. /**
  66940. * sets the light radius used by PBR Materials to simulate soft area lights.
  66941. */
  66942. radius: number;
  66943. private _renderPriority;
  66944. /**
  66945. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  66946. * exceeding the number allowed of the materials.
  66947. */
  66948. renderPriority: number;
  66949. private _shadowEnabled;
  66950. /**
  66951. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  66952. * the current shadow generator.
  66953. */
  66954. /**
  66955. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  66956. * the current shadow generator.
  66957. */
  66958. shadowEnabled: boolean;
  66959. private _includedOnlyMeshes;
  66960. /**
  66961. * Gets the only meshes impacted by this light.
  66962. */
  66963. /**
  66964. * Sets the only meshes impacted by this light.
  66965. */
  66966. includedOnlyMeshes: AbstractMesh[];
  66967. private _excludedMeshes;
  66968. /**
  66969. * Gets the meshes not impacted by this light.
  66970. */
  66971. /**
  66972. * Sets the meshes not impacted by this light.
  66973. */
  66974. excludedMeshes: AbstractMesh[];
  66975. private _excludeWithLayerMask;
  66976. /**
  66977. * Gets the layer id use to find what meshes are not impacted by the light.
  66978. * Inactive if 0
  66979. */
  66980. /**
  66981. * Sets the layer id use to find what meshes are not impacted by the light.
  66982. * Inactive if 0
  66983. */
  66984. excludeWithLayerMask: number;
  66985. private _includeOnlyWithLayerMask;
  66986. /**
  66987. * Gets the layer id use to find what meshes are impacted by the light.
  66988. * Inactive if 0
  66989. */
  66990. /**
  66991. * Sets the layer id use to find what meshes are impacted by the light.
  66992. * Inactive if 0
  66993. */
  66994. includeOnlyWithLayerMask: number;
  66995. private _lightmapMode;
  66996. /**
  66997. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  66998. */
  66999. /**
  67000. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  67001. */
  67002. lightmapMode: number;
  67003. /**
  67004. * Shadow generator associted to the light.
  67005. * @hidden Internal use only.
  67006. */
  67007. _shadowGenerator: Nullable<IShadowGenerator>;
  67008. /**
  67009. * @hidden Internal use only.
  67010. */
  67011. _excludedMeshesIds: string[];
  67012. /**
  67013. * @hidden Internal use only.
  67014. */
  67015. _includedOnlyMeshesIds: string[];
  67016. /**
  67017. * The current light unifom buffer.
  67018. * @hidden Internal use only.
  67019. */
  67020. _uniformBuffer: UniformBuffer;
  67021. /**
  67022. * Creates a Light object in the scene.
  67023. * Documentation : https://doc.babylonjs.com/babylon101/lights
  67024. * @param name The firendly name of the light
  67025. * @param scene The scene the light belongs too
  67026. */
  67027. constructor(name: string, scene: Scene);
  67028. protected abstract _buildUniformLayout(): void;
  67029. /**
  67030. * Sets the passed Effect "effect" with the Light information.
  67031. * @param effect The effect to update
  67032. * @param lightIndex The index of the light in the effect to update
  67033. * @returns The light
  67034. */
  67035. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  67036. /**
  67037. * Returns the string "Light".
  67038. * @returns the class name
  67039. */
  67040. getClassName(): string;
  67041. /** @hidden */
  67042. readonly _isLight: boolean;
  67043. /**
  67044. * Converts the light information to a readable string for debug purpose.
  67045. * @param fullDetails Supports for multiple levels of logging within scene loading
  67046. * @returns the human readable light info
  67047. */
  67048. toString(fullDetails?: boolean): string;
  67049. /** @hidden */
  67050. protected _syncParentEnabledState(): void;
  67051. /**
  67052. * Set the enabled state of this node.
  67053. * @param value - the new enabled state
  67054. */
  67055. setEnabled(value: boolean): void;
  67056. /**
  67057. * Returns the Light associated shadow generator if any.
  67058. * @return the associated shadow generator.
  67059. */
  67060. getShadowGenerator(): Nullable<IShadowGenerator>;
  67061. /**
  67062. * Returns a Vector3, the absolute light position in the World.
  67063. * @returns the world space position of the light
  67064. */
  67065. getAbsolutePosition(): Vector3;
  67066. /**
  67067. * Specifies if the light will affect the passed mesh.
  67068. * @param mesh The mesh to test against the light
  67069. * @return true the mesh is affected otherwise, false.
  67070. */
  67071. canAffectMesh(mesh: AbstractMesh): boolean;
  67072. /**
  67073. * Sort function to order lights for rendering.
  67074. * @param a First Light object to compare to second.
  67075. * @param b Second Light object to compare first.
  67076. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  67077. */
  67078. static CompareLightsPriority(a: Light, b: Light): number;
  67079. /**
  67080. * Releases resources associated with this node.
  67081. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  67082. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  67083. */
  67084. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  67085. /**
  67086. * Returns the light type ID (integer).
  67087. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  67088. */
  67089. getTypeID(): number;
  67090. /**
  67091. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  67092. * @returns the scaled intensity in intensity mode unit
  67093. */
  67094. getScaledIntensity(): number;
  67095. /**
  67096. * Returns a new Light object, named "name", from the current one.
  67097. * @param name The name of the cloned light
  67098. * @returns the new created light
  67099. */
  67100. clone(name: string): Nullable<Light>;
  67101. /**
  67102. * Serializes the current light into a Serialization object.
  67103. * @returns the serialized object.
  67104. */
  67105. serialize(): any;
  67106. /**
  67107. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  67108. * This new light is named "name" and added to the passed scene.
  67109. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  67110. * @param name The friendly name of the light
  67111. * @param scene The scene the new light will belong to
  67112. * @returns the constructor function
  67113. */
  67114. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  67115. /**
  67116. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  67117. * @param parsedLight The JSON representation of the light
  67118. * @param scene The scene to create the parsed light in
  67119. * @returns the created light after parsing
  67120. */
  67121. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  67122. private _hookArrayForExcluded;
  67123. private _hookArrayForIncludedOnly;
  67124. private _resyncMeshes;
  67125. /**
  67126. * Forces the meshes to update their light related information in their rendering used effects
  67127. * @hidden Internal Use Only
  67128. */
  67129. _markMeshesAsLightDirty(): void;
  67130. /**
  67131. * Recomputes the cached photometric scale if needed.
  67132. */
  67133. private _computePhotometricScale;
  67134. /**
  67135. * Returns the Photometric Scale according to the light type and intensity mode.
  67136. */
  67137. private _getPhotometricScale;
  67138. /**
  67139. * Reorder the light in the scene according to their defined priority.
  67140. * @hidden Internal Use Only
  67141. */
  67142. _reorderLightsInScene(): void;
  67143. /**
  67144. * Prepares the list of defines specific to the light type.
  67145. * @param defines the list of defines
  67146. * @param lightIndex defines the index of the light for the effect
  67147. */
  67148. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  67149. }
  67150. }
  67151. declare module BABYLON {
  67152. /**
  67153. * Interface used to define Action
  67154. */
  67155. export interface IAction {
  67156. /**
  67157. * Trigger for the action
  67158. */
  67159. trigger: number;
  67160. /** Options of the trigger */
  67161. triggerOptions: any;
  67162. /**
  67163. * Gets the trigger parameters
  67164. * @returns the trigger parameters
  67165. */
  67166. getTriggerParameter(): any;
  67167. /**
  67168. * Internal only - executes current action event
  67169. * @hidden
  67170. */
  67171. _executeCurrent(evt?: ActionEvent): void;
  67172. /**
  67173. * Serialize placeholder for child classes
  67174. * @param parent of child
  67175. * @returns the serialized object
  67176. */
  67177. serialize(parent: any): any;
  67178. }
  67179. /**
  67180. * The action to be carried out following a trigger
  67181. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  67182. */
  67183. export class Action implements IAction {
  67184. /** the trigger, with or without parameters, for the action */
  67185. triggerOptions: any;
  67186. /**
  67187. * Trigger for the action
  67188. */
  67189. trigger: number;
  67190. /**
  67191. * Internal only - manager for action
  67192. * @hidden
  67193. */
  67194. _actionManager: ActionManager;
  67195. private _nextActiveAction;
  67196. private _child;
  67197. private _condition?;
  67198. private _triggerParameter;
  67199. /**
  67200. * An event triggered prior to action being executed.
  67201. */
  67202. onBeforeExecuteObservable: Observable<Action>;
  67203. /**
  67204. * Creates a new Action
  67205. * @param triggerOptions the trigger, with or without parameters, for the action
  67206. * @param condition an optional determinant of action
  67207. */
  67208. constructor(
  67209. /** the trigger, with or without parameters, for the action */
  67210. triggerOptions: any, condition?: Condition);
  67211. /**
  67212. * Internal only
  67213. * @hidden
  67214. */
  67215. _prepare(): void;
  67216. /**
  67217. * Gets the trigger parameters
  67218. * @returns the trigger parameters
  67219. */
  67220. getTriggerParameter(): any;
  67221. /**
  67222. * Internal only - executes current action event
  67223. * @hidden
  67224. */
  67225. _executeCurrent(evt?: ActionEvent): void;
  67226. /**
  67227. * Execute placeholder for child classes
  67228. * @param evt optional action event
  67229. */
  67230. execute(evt?: ActionEvent): void;
  67231. /**
  67232. * Skips to next active action
  67233. */
  67234. skipToNextActiveAction(): void;
  67235. /**
  67236. * Adds action to chain of actions, may be a DoNothingAction
  67237. * @param action defines the next action to execute
  67238. * @returns The action passed in
  67239. * @see https://www.babylonjs-playground.com/#1T30HR#0
  67240. */
  67241. then(action: Action): Action;
  67242. /**
  67243. * Internal only
  67244. * @hidden
  67245. */
  67246. _getProperty(propertyPath: string): string;
  67247. /**
  67248. * Internal only
  67249. * @hidden
  67250. */
  67251. _getEffectiveTarget(target: any, propertyPath: string): any;
  67252. /**
  67253. * Serialize placeholder for child classes
  67254. * @param parent of child
  67255. * @returns the serialized object
  67256. */
  67257. serialize(parent: any): any;
  67258. /**
  67259. * Internal only called by serialize
  67260. * @hidden
  67261. */
  67262. protected _serialize(serializedAction: any, parent?: any): any;
  67263. /**
  67264. * Internal only
  67265. * @hidden
  67266. */
  67267. static _SerializeValueAsString: (value: any) => string;
  67268. /**
  67269. * Internal only
  67270. * @hidden
  67271. */
  67272. static _GetTargetProperty: (target: Scene | Node) => {
  67273. name: string;
  67274. targetType: string;
  67275. value: string;
  67276. };
  67277. }
  67278. }
  67279. declare module BABYLON {
  67280. /**
  67281. * A Condition applied to an Action
  67282. */
  67283. export class Condition {
  67284. /**
  67285. * Internal only - manager for action
  67286. * @hidden
  67287. */
  67288. _actionManager: ActionManager;
  67289. /**
  67290. * Internal only
  67291. * @hidden
  67292. */
  67293. _evaluationId: number;
  67294. /**
  67295. * Internal only
  67296. * @hidden
  67297. */
  67298. _currentResult: boolean;
  67299. /**
  67300. * Creates a new Condition
  67301. * @param actionManager the manager of the action the condition is applied to
  67302. */
  67303. constructor(actionManager: ActionManager);
  67304. /**
  67305. * Check if the current condition is valid
  67306. * @returns a boolean
  67307. */
  67308. isValid(): boolean;
  67309. /**
  67310. * Internal only
  67311. * @hidden
  67312. */
  67313. _getProperty(propertyPath: string): string;
  67314. /**
  67315. * Internal only
  67316. * @hidden
  67317. */
  67318. _getEffectiveTarget(target: any, propertyPath: string): any;
  67319. /**
  67320. * Serialize placeholder for child classes
  67321. * @returns the serialized object
  67322. */
  67323. serialize(): any;
  67324. /**
  67325. * Internal only
  67326. * @hidden
  67327. */
  67328. protected _serialize(serializedCondition: any): any;
  67329. }
  67330. /**
  67331. * Defines specific conditional operators as extensions of Condition
  67332. */
  67333. export class ValueCondition extends Condition {
  67334. /** path to specify the property of the target the conditional operator uses */
  67335. propertyPath: string;
  67336. /** the value compared by the conditional operator against the current value of the property */
  67337. value: any;
  67338. /** the conditional operator, default ValueCondition.IsEqual */
  67339. operator: number;
  67340. /**
  67341. * Internal only
  67342. * @hidden
  67343. */
  67344. private static _IsEqual;
  67345. /**
  67346. * Internal only
  67347. * @hidden
  67348. */
  67349. private static _IsDifferent;
  67350. /**
  67351. * Internal only
  67352. * @hidden
  67353. */
  67354. private static _IsGreater;
  67355. /**
  67356. * Internal only
  67357. * @hidden
  67358. */
  67359. private static _IsLesser;
  67360. /**
  67361. * returns the number for IsEqual
  67362. */
  67363. static readonly IsEqual: number;
  67364. /**
  67365. * Returns the number for IsDifferent
  67366. */
  67367. static readonly IsDifferent: number;
  67368. /**
  67369. * Returns the number for IsGreater
  67370. */
  67371. static readonly IsGreater: number;
  67372. /**
  67373. * Returns the number for IsLesser
  67374. */
  67375. static readonly IsLesser: number;
  67376. /**
  67377. * Internal only The action manager for the condition
  67378. * @hidden
  67379. */
  67380. _actionManager: ActionManager;
  67381. /**
  67382. * Internal only
  67383. * @hidden
  67384. */
  67385. private _target;
  67386. /**
  67387. * Internal only
  67388. * @hidden
  67389. */
  67390. private _effectiveTarget;
  67391. /**
  67392. * Internal only
  67393. * @hidden
  67394. */
  67395. private _property;
  67396. /**
  67397. * Creates a new ValueCondition
  67398. * @param actionManager manager for the action the condition applies to
  67399. * @param target for the action
  67400. * @param propertyPath path to specify the property of the target the conditional operator uses
  67401. * @param value the value compared by the conditional operator against the current value of the property
  67402. * @param operator the conditional operator, default ValueCondition.IsEqual
  67403. */
  67404. constructor(actionManager: ActionManager, target: any,
  67405. /** path to specify the property of the target the conditional operator uses */
  67406. propertyPath: string,
  67407. /** the value compared by the conditional operator against the current value of the property */
  67408. value: any,
  67409. /** the conditional operator, default ValueCondition.IsEqual */
  67410. operator?: number);
  67411. /**
  67412. * Compares the given value with the property value for the specified conditional operator
  67413. * @returns the result of the comparison
  67414. */
  67415. isValid(): boolean;
  67416. /**
  67417. * Serialize the ValueCondition into a JSON compatible object
  67418. * @returns serialization object
  67419. */
  67420. serialize(): any;
  67421. /**
  67422. * Gets the name of the conditional operator for the ValueCondition
  67423. * @param operator the conditional operator
  67424. * @returns the name
  67425. */
  67426. static GetOperatorName(operator: number): string;
  67427. }
  67428. /**
  67429. * Defines a predicate condition as an extension of Condition
  67430. */
  67431. export class PredicateCondition extends Condition {
  67432. /** defines the predicate function used to validate the condition */
  67433. predicate: () => boolean;
  67434. /**
  67435. * Internal only - manager for action
  67436. * @hidden
  67437. */
  67438. _actionManager: ActionManager;
  67439. /**
  67440. * Creates a new PredicateCondition
  67441. * @param actionManager manager for the action the condition applies to
  67442. * @param predicate defines the predicate function used to validate the condition
  67443. */
  67444. constructor(actionManager: ActionManager,
  67445. /** defines the predicate function used to validate the condition */
  67446. predicate: () => boolean);
  67447. /**
  67448. * @returns the validity of the predicate condition
  67449. */
  67450. isValid(): boolean;
  67451. }
  67452. /**
  67453. * Defines a state condition as an extension of Condition
  67454. */
  67455. export class StateCondition extends Condition {
  67456. /** Value to compare with target state */
  67457. value: string;
  67458. /**
  67459. * Internal only - manager for action
  67460. * @hidden
  67461. */
  67462. _actionManager: ActionManager;
  67463. /**
  67464. * Internal only
  67465. * @hidden
  67466. */
  67467. private _target;
  67468. /**
  67469. * Creates a new StateCondition
  67470. * @param actionManager manager for the action the condition applies to
  67471. * @param target of the condition
  67472. * @param value to compare with target state
  67473. */
  67474. constructor(actionManager: ActionManager, target: any,
  67475. /** Value to compare with target state */
  67476. value: string);
  67477. /**
  67478. * Gets a boolean indicating if the current condition is met
  67479. * @returns the validity of the state
  67480. */
  67481. isValid(): boolean;
  67482. /**
  67483. * Serialize the StateCondition into a JSON compatible object
  67484. * @returns serialization object
  67485. */
  67486. serialize(): any;
  67487. }
  67488. }
  67489. declare module BABYLON {
  67490. /**
  67491. * This defines an action responsible to toggle a boolean once triggered.
  67492. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67493. */
  67494. export class SwitchBooleanAction extends Action {
  67495. /**
  67496. * The path to the boolean property in the target object
  67497. */
  67498. propertyPath: string;
  67499. private _target;
  67500. private _effectiveTarget;
  67501. private _property;
  67502. /**
  67503. * Instantiate the action
  67504. * @param triggerOptions defines the trigger options
  67505. * @param target defines the object containing the boolean
  67506. * @param propertyPath defines the path to the boolean property in the target object
  67507. * @param condition defines the trigger related conditions
  67508. */
  67509. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  67510. /** @hidden */
  67511. _prepare(): void;
  67512. /**
  67513. * Execute the action toggle the boolean value.
  67514. */
  67515. execute(): void;
  67516. /**
  67517. * Serializes the actions and its related information.
  67518. * @param parent defines the object to serialize in
  67519. * @returns the serialized object
  67520. */
  67521. serialize(parent: any): any;
  67522. }
  67523. /**
  67524. * This defines an action responsible to set a the state field of the target
  67525. * to a desired value once triggered.
  67526. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67527. */
  67528. export class SetStateAction extends Action {
  67529. /**
  67530. * The value to store in the state field.
  67531. */
  67532. value: string;
  67533. private _target;
  67534. /**
  67535. * Instantiate the action
  67536. * @param triggerOptions defines the trigger options
  67537. * @param target defines the object containing the state property
  67538. * @param value defines the value to store in the state field
  67539. * @param condition defines the trigger related conditions
  67540. */
  67541. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  67542. /**
  67543. * Execute the action and store the value on the target state property.
  67544. */
  67545. execute(): void;
  67546. /**
  67547. * Serializes the actions and its related information.
  67548. * @param parent defines the object to serialize in
  67549. * @returns the serialized object
  67550. */
  67551. serialize(parent: any): any;
  67552. }
  67553. /**
  67554. * This defines an action responsible to set a property of the target
  67555. * to a desired value once triggered.
  67556. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67557. */
  67558. export class SetValueAction extends Action {
  67559. /**
  67560. * The path of the property to set in the target.
  67561. */
  67562. propertyPath: string;
  67563. /**
  67564. * The value to set in the property
  67565. */
  67566. value: any;
  67567. private _target;
  67568. private _effectiveTarget;
  67569. private _property;
  67570. /**
  67571. * Instantiate the action
  67572. * @param triggerOptions defines the trigger options
  67573. * @param target defines the object containing the property
  67574. * @param propertyPath defines the path of the property to set in the target
  67575. * @param value defines the value to set in the property
  67576. * @param condition defines the trigger related conditions
  67577. */
  67578. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  67579. /** @hidden */
  67580. _prepare(): void;
  67581. /**
  67582. * Execute the action and set the targetted property to the desired value.
  67583. */
  67584. execute(): void;
  67585. /**
  67586. * Serializes the actions and its related information.
  67587. * @param parent defines the object to serialize in
  67588. * @returns the serialized object
  67589. */
  67590. serialize(parent: any): any;
  67591. }
  67592. /**
  67593. * This defines an action responsible to increment the target value
  67594. * to a desired value once triggered.
  67595. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67596. */
  67597. export class IncrementValueAction extends Action {
  67598. /**
  67599. * The path of the property to increment in the target.
  67600. */
  67601. propertyPath: string;
  67602. /**
  67603. * The value we should increment the property by.
  67604. */
  67605. value: any;
  67606. private _target;
  67607. private _effectiveTarget;
  67608. private _property;
  67609. /**
  67610. * Instantiate the action
  67611. * @param triggerOptions defines the trigger options
  67612. * @param target defines the object containing the property
  67613. * @param propertyPath defines the path of the property to increment in the target
  67614. * @param value defines the value value we should increment the property by
  67615. * @param condition defines the trigger related conditions
  67616. */
  67617. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  67618. /** @hidden */
  67619. _prepare(): void;
  67620. /**
  67621. * Execute the action and increment the target of the value amount.
  67622. */
  67623. execute(): void;
  67624. /**
  67625. * Serializes the actions and its related information.
  67626. * @param parent defines the object to serialize in
  67627. * @returns the serialized object
  67628. */
  67629. serialize(parent: any): any;
  67630. }
  67631. /**
  67632. * This defines an action responsible to start an animation once triggered.
  67633. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67634. */
  67635. export class PlayAnimationAction extends Action {
  67636. /**
  67637. * Where the animation should start (animation frame)
  67638. */
  67639. from: number;
  67640. /**
  67641. * Where the animation should stop (animation frame)
  67642. */
  67643. to: number;
  67644. /**
  67645. * Define if the animation should loop or stop after the first play.
  67646. */
  67647. loop?: boolean;
  67648. private _target;
  67649. /**
  67650. * Instantiate the action
  67651. * @param triggerOptions defines the trigger options
  67652. * @param target defines the target animation or animation name
  67653. * @param from defines from where the animation should start (animation frame)
  67654. * @param end defines where the animation should stop (animation frame)
  67655. * @param loop defines if the animation should loop or stop after the first play
  67656. * @param condition defines the trigger related conditions
  67657. */
  67658. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  67659. /** @hidden */
  67660. _prepare(): void;
  67661. /**
  67662. * Execute the action and play the animation.
  67663. */
  67664. execute(): void;
  67665. /**
  67666. * Serializes the actions and its related information.
  67667. * @param parent defines the object to serialize in
  67668. * @returns the serialized object
  67669. */
  67670. serialize(parent: any): any;
  67671. }
  67672. /**
  67673. * This defines an action responsible to stop an animation once triggered.
  67674. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67675. */
  67676. export class StopAnimationAction extends Action {
  67677. private _target;
  67678. /**
  67679. * Instantiate the action
  67680. * @param triggerOptions defines the trigger options
  67681. * @param target defines the target animation or animation name
  67682. * @param condition defines the trigger related conditions
  67683. */
  67684. constructor(triggerOptions: any, target: any, condition?: Condition);
  67685. /** @hidden */
  67686. _prepare(): void;
  67687. /**
  67688. * Execute the action and stop the animation.
  67689. */
  67690. execute(): void;
  67691. /**
  67692. * Serializes the actions and its related information.
  67693. * @param parent defines the object to serialize in
  67694. * @returns the serialized object
  67695. */
  67696. serialize(parent: any): any;
  67697. }
  67698. /**
  67699. * This defines an action responsible that does nothing once triggered.
  67700. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67701. */
  67702. export class DoNothingAction extends Action {
  67703. /**
  67704. * Instantiate the action
  67705. * @param triggerOptions defines the trigger options
  67706. * @param condition defines the trigger related conditions
  67707. */
  67708. constructor(triggerOptions?: any, condition?: Condition);
  67709. /**
  67710. * Execute the action and do nothing.
  67711. */
  67712. execute(): void;
  67713. /**
  67714. * Serializes the actions and its related information.
  67715. * @param parent defines the object to serialize in
  67716. * @returns the serialized object
  67717. */
  67718. serialize(parent: any): any;
  67719. }
  67720. /**
  67721. * This defines an action responsible to trigger several actions once triggered.
  67722. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67723. */
  67724. export class CombineAction extends Action {
  67725. /**
  67726. * The list of aggregated animations to run.
  67727. */
  67728. children: Action[];
  67729. /**
  67730. * Instantiate the action
  67731. * @param triggerOptions defines the trigger options
  67732. * @param children defines the list of aggregated animations to run
  67733. * @param condition defines the trigger related conditions
  67734. */
  67735. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  67736. /** @hidden */
  67737. _prepare(): void;
  67738. /**
  67739. * Execute the action and executes all the aggregated actions.
  67740. */
  67741. execute(evt: ActionEvent): void;
  67742. /**
  67743. * Serializes the actions and its related information.
  67744. * @param parent defines the object to serialize in
  67745. * @returns the serialized object
  67746. */
  67747. serialize(parent: any): any;
  67748. }
  67749. /**
  67750. * This defines an action responsible to run code (external event) once triggered.
  67751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67752. */
  67753. export class ExecuteCodeAction extends Action {
  67754. /**
  67755. * The callback function to run.
  67756. */
  67757. func: (evt: ActionEvent) => void;
  67758. /**
  67759. * Instantiate the action
  67760. * @param triggerOptions defines the trigger options
  67761. * @param func defines the callback function to run
  67762. * @param condition defines the trigger related conditions
  67763. */
  67764. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  67765. /**
  67766. * Execute the action and run the attached code.
  67767. */
  67768. execute(evt: ActionEvent): void;
  67769. }
  67770. /**
  67771. * This defines an action responsible to set the parent property of the target once triggered.
  67772. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67773. */
  67774. export class SetParentAction extends Action {
  67775. private _parent;
  67776. private _target;
  67777. /**
  67778. * Instantiate the action
  67779. * @param triggerOptions defines the trigger options
  67780. * @param target defines the target containing the parent property
  67781. * @param parent defines from where the animation should start (animation frame)
  67782. * @param condition defines the trigger related conditions
  67783. */
  67784. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  67785. /** @hidden */
  67786. _prepare(): void;
  67787. /**
  67788. * Execute the action and set the parent property.
  67789. */
  67790. execute(): void;
  67791. /**
  67792. * Serializes the actions and its related information.
  67793. * @param parent defines the object to serialize in
  67794. * @returns the serialized object
  67795. */
  67796. serialize(parent: any): any;
  67797. }
  67798. }
  67799. declare module BABYLON {
  67800. /**
  67801. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  67802. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  67803. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  67804. */
  67805. export class ActionManager extends AbstractActionManager {
  67806. /**
  67807. * Nothing
  67808. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67809. */
  67810. static readonly NothingTrigger: number;
  67811. /**
  67812. * On pick
  67813. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67814. */
  67815. static readonly OnPickTrigger: number;
  67816. /**
  67817. * On left pick
  67818. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67819. */
  67820. static readonly OnLeftPickTrigger: number;
  67821. /**
  67822. * On right pick
  67823. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67824. */
  67825. static readonly OnRightPickTrigger: number;
  67826. /**
  67827. * On center pick
  67828. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67829. */
  67830. static readonly OnCenterPickTrigger: number;
  67831. /**
  67832. * On pick down
  67833. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67834. */
  67835. static readonly OnPickDownTrigger: number;
  67836. /**
  67837. * On double pick
  67838. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67839. */
  67840. static readonly OnDoublePickTrigger: number;
  67841. /**
  67842. * On pick up
  67843. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67844. */
  67845. static readonly OnPickUpTrigger: number;
  67846. /**
  67847. * On pick out.
  67848. * This trigger will only be raised if you also declared a OnPickDown
  67849. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67850. */
  67851. static readonly OnPickOutTrigger: number;
  67852. /**
  67853. * On long press
  67854. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67855. */
  67856. static readonly OnLongPressTrigger: number;
  67857. /**
  67858. * On pointer over
  67859. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67860. */
  67861. static readonly OnPointerOverTrigger: number;
  67862. /**
  67863. * On pointer out
  67864. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67865. */
  67866. static readonly OnPointerOutTrigger: number;
  67867. /**
  67868. * On every frame
  67869. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67870. */
  67871. static readonly OnEveryFrameTrigger: number;
  67872. /**
  67873. * On intersection enter
  67874. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67875. */
  67876. static readonly OnIntersectionEnterTrigger: number;
  67877. /**
  67878. * On intersection exit
  67879. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67880. */
  67881. static readonly OnIntersectionExitTrigger: number;
  67882. /**
  67883. * On key down
  67884. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67885. */
  67886. static readonly OnKeyDownTrigger: number;
  67887. /**
  67888. * On key up
  67889. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67890. */
  67891. static readonly OnKeyUpTrigger: number;
  67892. private _scene;
  67893. /**
  67894. * Creates a new action manager
  67895. * @param scene defines the hosting scene
  67896. */
  67897. constructor(scene: Scene);
  67898. /**
  67899. * Releases all associated resources
  67900. */
  67901. dispose(): void;
  67902. /**
  67903. * Gets hosting scene
  67904. * @returns the hosting scene
  67905. */
  67906. getScene(): Scene;
  67907. /**
  67908. * Does this action manager handles actions of any of the given triggers
  67909. * @param triggers defines the triggers to be tested
  67910. * @return a boolean indicating whether one (or more) of the triggers is handled
  67911. */
  67912. hasSpecificTriggers(triggers: number[]): boolean;
  67913. /**
  67914. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  67915. * speed.
  67916. * @param triggerA defines the trigger to be tested
  67917. * @param triggerB defines the trigger to be tested
  67918. * @return a boolean indicating whether one (or more) of the triggers is handled
  67919. */
  67920. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  67921. /**
  67922. * Does this action manager handles actions of a given trigger
  67923. * @param trigger defines the trigger to be tested
  67924. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  67925. * @return whether the trigger is handled
  67926. */
  67927. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  67928. /**
  67929. * Does this action manager has pointer triggers
  67930. */
  67931. readonly hasPointerTriggers: boolean;
  67932. /**
  67933. * Does this action manager has pick triggers
  67934. */
  67935. readonly hasPickTriggers: boolean;
  67936. /**
  67937. * Registers an action to this action manager
  67938. * @param action defines the action to be registered
  67939. * @return the action amended (prepared) after registration
  67940. */
  67941. registerAction(action: Action): Nullable<Action>;
  67942. /**
  67943. * Unregisters an action to this action manager
  67944. * @param action defines the action to be unregistered
  67945. * @return a boolean indicating whether the action has been unregistered
  67946. */
  67947. unregisterAction(action: Action): Boolean;
  67948. /**
  67949. * Process a specific trigger
  67950. * @param trigger defines the trigger to process
  67951. * @param evt defines the event details to be processed
  67952. */
  67953. processTrigger(trigger: number, evt?: IActionEvent): void;
  67954. /** @hidden */
  67955. _getEffectiveTarget(target: any, propertyPath: string): any;
  67956. /** @hidden */
  67957. _getProperty(propertyPath: string): string;
  67958. /**
  67959. * Serialize this manager to a JSON object
  67960. * @param name defines the property name to store this manager
  67961. * @returns a JSON representation of this manager
  67962. */
  67963. serialize(name: string): any;
  67964. /**
  67965. * Creates a new ActionManager from a JSON data
  67966. * @param parsedActions defines the JSON data to read from
  67967. * @param object defines the hosting mesh
  67968. * @param scene defines the hosting scene
  67969. */
  67970. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  67971. /**
  67972. * Get a trigger name by index
  67973. * @param trigger defines the trigger index
  67974. * @returns a trigger name
  67975. */
  67976. static GetTriggerName(trigger: number): string;
  67977. }
  67978. }
  67979. declare module BABYLON {
  67980. /**
  67981. * Class representing a ray with position and direction
  67982. */
  67983. export class Ray {
  67984. /** origin point */
  67985. origin: Vector3;
  67986. /** direction */
  67987. direction: Vector3;
  67988. /** length of the ray */
  67989. length: number;
  67990. private static readonly TmpVector3;
  67991. private _tmpRay;
  67992. /**
  67993. * Creates a new ray
  67994. * @param origin origin point
  67995. * @param direction direction
  67996. * @param length length of the ray
  67997. */
  67998. constructor(
  67999. /** origin point */
  68000. origin: Vector3,
  68001. /** direction */
  68002. direction: Vector3,
  68003. /** length of the ray */
  68004. length?: number);
  68005. /**
  68006. * Checks if the ray intersects a box
  68007. * @param minimum bound of the box
  68008. * @param maximum bound of the box
  68009. * @param intersectionTreshold extra extend to be added to the box in all direction
  68010. * @returns if the box was hit
  68011. */
  68012. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  68013. /**
  68014. * Checks if the ray intersects a box
  68015. * @param box the bounding box to check
  68016. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  68017. * @returns if the box was hit
  68018. */
  68019. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  68020. /**
  68021. * If the ray hits a sphere
  68022. * @param sphere the bounding sphere to check
  68023. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  68024. * @returns true if it hits the sphere
  68025. */
  68026. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  68027. /**
  68028. * If the ray hits a triange
  68029. * @param vertex0 triangle vertex
  68030. * @param vertex1 triangle vertex
  68031. * @param vertex2 triangle vertex
  68032. * @returns intersection information if hit
  68033. */
  68034. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  68035. /**
  68036. * Checks if ray intersects a plane
  68037. * @param plane the plane to check
  68038. * @returns the distance away it was hit
  68039. */
  68040. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  68041. /**
  68042. * Checks if ray intersects a mesh
  68043. * @param mesh the mesh to check
  68044. * @param fastCheck if only the bounding box should checked
  68045. * @returns picking info of the intersecton
  68046. */
  68047. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  68048. /**
  68049. * Checks if ray intersects a mesh
  68050. * @param meshes the meshes to check
  68051. * @param fastCheck if only the bounding box should checked
  68052. * @param results array to store result in
  68053. * @returns Array of picking infos
  68054. */
  68055. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  68056. private _comparePickingInfo;
  68057. private static smallnum;
  68058. private static rayl;
  68059. /**
  68060. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  68061. * @param sega the first point of the segment to test the intersection against
  68062. * @param segb the second point of the segment to test the intersection against
  68063. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  68064. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  68065. */
  68066. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  68067. /**
  68068. * Update the ray from viewport position
  68069. * @param x position
  68070. * @param y y position
  68071. * @param viewportWidth viewport width
  68072. * @param viewportHeight viewport height
  68073. * @param world world matrix
  68074. * @param view view matrix
  68075. * @param projection projection matrix
  68076. * @returns this ray updated
  68077. */
  68078. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  68079. /**
  68080. * Creates a ray with origin and direction of 0,0,0
  68081. * @returns the new ray
  68082. */
  68083. static Zero(): Ray;
  68084. /**
  68085. * Creates a new ray from screen space and viewport
  68086. * @param x position
  68087. * @param y y position
  68088. * @param viewportWidth viewport width
  68089. * @param viewportHeight viewport height
  68090. * @param world world matrix
  68091. * @param view view matrix
  68092. * @param projection projection matrix
  68093. * @returns new ray
  68094. */
  68095. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  68096. /**
  68097. * 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
  68098. * transformed to the given world matrix.
  68099. * @param origin The origin point
  68100. * @param end The end point
  68101. * @param world a matrix to transform the ray to. Default is the identity matrix.
  68102. * @returns the new ray
  68103. */
  68104. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  68105. /**
  68106. * Transforms a ray by a matrix
  68107. * @param ray ray to transform
  68108. * @param matrix matrix to apply
  68109. * @returns the resulting new ray
  68110. */
  68111. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  68112. /**
  68113. * Transforms a ray by a matrix
  68114. * @param ray ray to transform
  68115. * @param matrix matrix to apply
  68116. * @param result ray to store result in
  68117. */
  68118. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  68119. /**
  68120. * Unproject a ray from screen space to object space
  68121. * @param sourceX defines the screen space x coordinate to use
  68122. * @param sourceY defines the screen space y coordinate to use
  68123. * @param viewportWidth defines the current width of the viewport
  68124. * @param viewportHeight defines the current height of the viewport
  68125. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68126. * @param view defines the view matrix to use
  68127. * @param projection defines the projection matrix to use
  68128. */
  68129. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  68130. }
  68131. interface Scene {
  68132. /** @hidden */
  68133. _tempPickingRay: Nullable<Ray>;
  68134. /** @hidden */
  68135. _cachedRayForTransform: Ray;
  68136. /** @hidden */
  68137. _pickWithRayInverseMatrix: Matrix;
  68138. /** @hidden */
  68139. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  68140. /** @hidden */
  68141. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  68142. }
  68143. }
  68144. declare module BABYLON {
  68145. /**
  68146. * Groups all the scene component constants in one place to ease maintenance.
  68147. * @hidden
  68148. */
  68149. export class SceneComponentConstants {
  68150. static readonly NAME_EFFECTLAYER: string;
  68151. static readonly NAME_LAYER: string;
  68152. static readonly NAME_LENSFLARESYSTEM: string;
  68153. static readonly NAME_BOUNDINGBOXRENDERER: string;
  68154. static readonly NAME_PARTICLESYSTEM: string;
  68155. static readonly NAME_GAMEPAD: string;
  68156. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  68157. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  68158. static readonly NAME_DEPTHRENDERER: string;
  68159. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  68160. static readonly NAME_SPRITE: string;
  68161. static readonly NAME_OUTLINERENDERER: string;
  68162. static readonly NAME_PROCEDURALTEXTURE: string;
  68163. static readonly NAME_SHADOWGENERATOR: string;
  68164. static readonly NAME_OCTREE: string;
  68165. static readonly NAME_PHYSICSENGINE: string;
  68166. static readonly NAME_AUDIO: string;
  68167. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  68168. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  68169. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  68170. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  68171. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  68172. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  68173. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  68174. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  68175. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  68176. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  68177. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  68178. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  68179. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  68180. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  68181. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  68182. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  68183. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  68184. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  68185. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  68186. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  68187. static readonly STEP_AFTERRENDER_AUDIO: number;
  68188. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  68189. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  68190. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  68191. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  68192. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  68193. static readonly STEP_POINTERMOVE_SPRITE: number;
  68194. static readonly STEP_POINTERDOWN_SPRITE: number;
  68195. static readonly STEP_POINTERUP_SPRITE: number;
  68196. }
  68197. /**
  68198. * This represents a scene component.
  68199. *
  68200. * This is used to decouple the dependency the scene is having on the different workloads like
  68201. * layers, post processes...
  68202. */
  68203. export interface ISceneComponent {
  68204. /**
  68205. * The name of the component. Each component must have a unique name.
  68206. */
  68207. name: string;
  68208. /**
  68209. * The scene the component belongs to.
  68210. */
  68211. scene: Scene;
  68212. /**
  68213. * Register the component to one instance of a scene.
  68214. */
  68215. register(): void;
  68216. /**
  68217. * Rebuilds the elements related to this component in case of
  68218. * context lost for instance.
  68219. */
  68220. rebuild(): void;
  68221. /**
  68222. * Disposes the component and the associated ressources.
  68223. */
  68224. dispose(): void;
  68225. }
  68226. /**
  68227. * This represents a SERIALIZABLE scene component.
  68228. *
  68229. * This extends Scene Component to add Serialization methods on top.
  68230. */
  68231. export interface ISceneSerializableComponent extends ISceneComponent {
  68232. /**
  68233. * Adds all the element from the container to the scene
  68234. * @param container the container holding the elements
  68235. */
  68236. addFromContainer(container: AbstractScene): void;
  68237. /**
  68238. * Removes all the elements in the container from the scene
  68239. * @param container contains the elements to remove
  68240. */
  68241. removeFromContainer(container: AbstractScene): void;
  68242. /**
  68243. * Serializes the component data to the specified json object
  68244. * @param serializationObject The object to serialize to
  68245. */
  68246. serialize(serializationObject: any): void;
  68247. }
  68248. /**
  68249. * Strong typing of a Mesh related stage step action
  68250. */
  68251. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  68252. /**
  68253. * Strong typing of a Evaluate Sub Mesh related stage step action
  68254. */
  68255. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  68256. /**
  68257. * Strong typing of a Active Mesh related stage step action
  68258. */
  68259. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  68260. /**
  68261. * Strong typing of a Camera related stage step action
  68262. */
  68263. export type CameraStageAction = (camera: Camera) => void;
  68264. /**
  68265. * Strong typing of a Render Target related stage step action
  68266. */
  68267. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  68268. /**
  68269. * Strong typing of a RenderingGroup related stage step action
  68270. */
  68271. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  68272. /**
  68273. * Strong typing of a Mesh Render related stage step action
  68274. */
  68275. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  68276. /**
  68277. * Strong typing of a simple stage step action
  68278. */
  68279. export type SimpleStageAction = () => void;
  68280. /**
  68281. * Strong typing of a render target action.
  68282. */
  68283. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  68284. /**
  68285. * Strong typing of a pointer move action.
  68286. */
  68287. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  68288. /**
  68289. * Strong typing of a pointer up/down action.
  68290. */
  68291. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  68292. /**
  68293. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  68294. * @hidden
  68295. */
  68296. export class Stage<T extends Function> extends Array<{
  68297. index: number;
  68298. component: ISceneComponent;
  68299. action: T;
  68300. }> {
  68301. /**
  68302. * Hide ctor from the rest of the world.
  68303. * @param items The items to add.
  68304. */
  68305. private constructor();
  68306. /**
  68307. * Creates a new Stage.
  68308. * @returns A new instance of a Stage
  68309. */
  68310. static Create<T extends Function>(): Stage<T>;
  68311. /**
  68312. * Registers a step in an ordered way in the targeted stage.
  68313. * @param index Defines the position to register the step in
  68314. * @param component Defines the component attached to the step
  68315. * @param action Defines the action to launch during the step
  68316. */
  68317. registerStep(index: number, component: ISceneComponent, action: T): void;
  68318. /**
  68319. * Clears all the steps from the stage.
  68320. */
  68321. clear(): void;
  68322. }
  68323. }
  68324. declare module BABYLON {
  68325. interface Scene {
  68326. /** @hidden */
  68327. _pointerOverSprite: Nullable<Sprite>;
  68328. /** @hidden */
  68329. _pickedDownSprite: Nullable<Sprite>;
  68330. /** @hidden */
  68331. _tempSpritePickingRay: Nullable<Ray>;
  68332. /**
  68333. * All of the sprite managers added to this scene
  68334. * @see http://doc.babylonjs.com/babylon101/sprites
  68335. */
  68336. spriteManagers: Array<ISpriteManager>;
  68337. /**
  68338. * An event triggered when sprites rendering is about to start
  68339. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  68340. */
  68341. onBeforeSpritesRenderingObservable: Observable<Scene>;
  68342. /**
  68343. * An event triggered when sprites rendering is done
  68344. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  68345. */
  68346. onAfterSpritesRenderingObservable: Observable<Scene>;
  68347. /** @hidden */
  68348. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  68349. /** Launch a ray to try to pick a sprite in the scene
  68350. * @param x position on screen
  68351. * @param y position on screen
  68352. * @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
  68353. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  68354. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  68355. * @returns a PickingInfo
  68356. */
  68357. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  68358. /** Use the given ray to pick a sprite in the scene
  68359. * @param ray The ray (in world space) to use to pick meshes
  68360. * @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
  68361. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  68362. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  68363. * @returns a PickingInfo
  68364. */
  68365. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  68366. /**
  68367. * Force the sprite under the pointer
  68368. * @param sprite defines the sprite to use
  68369. */
  68370. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  68371. /**
  68372. * Gets the sprite under the pointer
  68373. * @returns a Sprite or null if no sprite is under the pointer
  68374. */
  68375. getPointerOverSprite(): Nullable<Sprite>;
  68376. }
  68377. /**
  68378. * Defines the sprite scene component responsible to manage sprites
  68379. * in a given scene.
  68380. */
  68381. export class SpriteSceneComponent implements ISceneComponent {
  68382. /**
  68383. * The component name helpfull to identify the component in the list of scene components.
  68384. */
  68385. readonly name: string;
  68386. /**
  68387. * The scene the component belongs to.
  68388. */
  68389. scene: Scene;
  68390. /** @hidden */
  68391. private _spritePredicate;
  68392. /**
  68393. * Creates a new instance of the component for the given scene
  68394. * @param scene Defines the scene to register the component in
  68395. */
  68396. constructor(scene: Scene);
  68397. /**
  68398. * Registers the component in a given scene
  68399. */
  68400. register(): void;
  68401. /**
  68402. * Rebuilds the elements related to this component in case of
  68403. * context lost for instance.
  68404. */
  68405. rebuild(): void;
  68406. /**
  68407. * Disposes the component and the associated ressources.
  68408. */
  68409. dispose(): void;
  68410. private _pickSpriteButKeepRay;
  68411. private _pointerMove;
  68412. private _pointerDown;
  68413. private _pointerUp;
  68414. }
  68415. }
  68416. declare module BABYLON {
  68417. /** @hidden */
  68418. export var fogFragmentDeclaration: {
  68419. name: string;
  68420. shader: string;
  68421. };
  68422. }
  68423. declare module BABYLON {
  68424. /** @hidden */
  68425. export var fogFragment: {
  68426. name: string;
  68427. shader: string;
  68428. };
  68429. }
  68430. declare module BABYLON {
  68431. /** @hidden */
  68432. export var spritesPixelShader: {
  68433. name: string;
  68434. shader: string;
  68435. };
  68436. }
  68437. declare module BABYLON {
  68438. /** @hidden */
  68439. export var fogVertexDeclaration: {
  68440. name: string;
  68441. shader: string;
  68442. };
  68443. }
  68444. declare module BABYLON {
  68445. /** @hidden */
  68446. export var spritesVertexShader: {
  68447. name: string;
  68448. shader: string;
  68449. };
  68450. }
  68451. declare module BABYLON {
  68452. /**
  68453. * Defines the minimum interface to fullfil in order to be a sprite manager.
  68454. */
  68455. export interface ISpriteManager extends IDisposable {
  68456. /**
  68457. * Restricts the camera to viewing objects with the same layerMask.
  68458. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  68459. */
  68460. layerMask: number;
  68461. /**
  68462. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  68463. */
  68464. isPickable: boolean;
  68465. /**
  68466. * Specifies the rendering group id for this mesh (0 by default)
  68467. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  68468. */
  68469. renderingGroupId: number;
  68470. /**
  68471. * Defines the list of sprites managed by the manager.
  68472. */
  68473. sprites: Array<Sprite>;
  68474. /**
  68475. * Tests the intersection of a sprite with a specific ray.
  68476. * @param ray The ray we are sending to test the collision
  68477. * @param camera The camera space we are sending rays in
  68478. * @param predicate A predicate allowing excluding sprites from the list of object to test
  68479. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  68480. * @returns picking info or null.
  68481. */
  68482. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  68483. /**
  68484. * Renders the list of sprites on screen.
  68485. */
  68486. render(): void;
  68487. }
  68488. /**
  68489. * Class used to manage multiple sprites on the same spritesheet
  68490. * @see http://doc.babylonjs.com/babylon101/sprites
  68491. */
  68492. export class SpriteManager implements ISpriteManager {
  68493. /** defines the manager's name */
  68494. name: string;
  68495. /** Gets the list of sprites */
  68496. sprites: Sprite[];
  68497. /** Gets or sets the rendering group id (0 by default) */
  68498. renderingGroupId: number;
  68499. /** Gets or sets camera layer mask */
  68500. layerMask: number;
  68501. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  68502. fogEnabled: boolean;
  68503. /** Gets or sets a boolean indicating if the sprites are pickable */
  68504. isPickable: boolean;
  68505. /** Defines the default width of a cell in the spritesheet */
  68506. cellWidth: number;
  68507. /** Defines the default height of a cell in the spritesheet */
  68508. cellHeight: number;
  68509. /**
  68510. * An event triggered when the manager is disposed.
  68511. */
  68512. onDisposeObservable: Observable<SpriteManager>;
  68513. private _onDisposeObserver;
  68514. /**
  68515. * Callback called when the manager is disposed
  68516. */
  68517. onDispose: () => void;
  68518. private _capacity;
  68519. private _spriteTexture;
  68520. private _epsilon;
  68521. private _scene;
  68522. private _vertexData;
  68523. private _buffer;
  68524. private _vertexBuffers;
  68525. private _indexBuffer;
  68526. private _effectBase;
  68527. private _effectFog;
  68528. /**
  68529. * Gets or sets the spritesheet texture
  68530. */
  68531. texture: Texture;
  68532. /**
  68533. * Creates a new sprite manager
  68534. * @param name defines the manager's name
  68535. * @param imgUrl defines the sprite sheet url
  68536. * @param capacity defines the maximum allowed number of sprites
  68537. * @param cellSize defines the size of a sprite cell
  68538. * @param scene defines the hosting scene
  68539. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  68540. * @param samplingMode defines the smapling mode to use with spritesheet
  68541. */
  68542. constructor(
  68543. /** defines the manager's name */
  68544. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  68545. private _appendSpriteVertex;
  68546. /**
  68547. * Intersects the sprites with a ray
  68548. * @param ray defines the ray to intersect with
  68549. * @param camera defines the current active camera
  68550. * @param predicate defines a predicate used to select candidate sprites
  68551. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  68552. * @returns null if no hit or a PickingInfo
  68553. */
  68554. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  68555. /**
  68556. * Render all child sprites
  68557. */
  68558. render(): void;
  68559. /**
  68560. * Release associated resources
  68561. */
  68562. dispose(): void;
  68563. }
  68564. }
  68565. declare module BABYLON {
  68566. /**
  68567. * Class used to represent a sprite
  68568. * @see http://doc.babylonjs.com/babylon101/sprites
  68569. */
  68570. export class Sprite {
  68571. /** defines the name */
  68572. name: string;
  68573. /** Gets or sets the current world position */
  68574. position: Vector3;
  68575. /** Gets or sets the main color */
  68576. color: Color4;
  68577. /** Gets or sets the width */
  68578. width: number;
  68579. /** Gets or sets the height */
  68580. height: number;
  68581. /** Gets or sets rotation angle */
  68582. angle: number;
  68583. /** Gets or sets the cell index in the sprite sheet */
  68584. cellIndex: number;
  68585. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  68586. invertU: number;
  68587. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  68588. invertV: number;
  68589. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  68590. disposeWhenFinishedAnimating: boolean;
  68591. /** Gets the list of attached animations */
  68592. animations: Animation[];
  68593. /** Gets or sets a boolean indicating if the sprite can be picked */
  68594. isPickable: boolean;
  68595. /**
  68596. * Gets or sets the associated action manager
  68597. */
  68598. actionManager: Nullable<ActionManager>;
  68599. private _animationStarted;
  68600. private _loopAnimation;
  68601. private _fromIndex;
  68602. private _toIndex;
  68603. private _delay;
  68604. private _direction;
  68605. private _manager;
  68606. private _time;
  68607. private _onAnimationEnd;
  68608. /**
  68609. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  68610. */
  68611. isVisible: boolean;
  68612. /**
  68613. * Gets or sets the sprite size
  68614. */
  68615. size: number;
  68616. /**
  68617. * Creates a new Sprite
  68618. * @param name defines the name
  68619. * @param manager defines the manager
  68620. */
  68621. constructor(
  68622. /** defines the name */
  68623. name: string, manager: ISpriteManager);
  68624. /**
  68625. * Starts an animation
  68626. * @param from defines the initial key
  68627. * @param to defines the end key
  68628. * @param loop defines if the animation must loop
  68629. * @param delay defines the start delay (in ms)
  68630. * @param onAnimationEnd defines a callback to call when animation ends
  68631. */
  68632. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  68633. /** Stops current animation (if any) */
  68634. stopAnimation(): void;
  68635. /** @hidden */
  68636. _animate(deltaTime: number): void;
  68637. /** Release associated resources */
  68638. dispose(): void;
  68639. }
  68640. }
  68641. declare module BABYLON {
  68642. /**
  68643. * Information about the result of picking within a scene
  68644. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  68645. */
  68646. export class PickingInfo {
  68647. /** @hidden */
  68648. _pickingUnavailable: boolean;
  68649. /**
  68650. * If the pick collided with an object
  68651. */
  68652. hit: boolean;
  68653. /**
  68654. * Distance away where the pick collided
  68655. */
  68656. distance: number;
  68657. /**
  68658. * The location of pick collision
  68659. */
  68660. pickedPoint: Nullable<Vector3>;
  68661. /**
  68662. * The mesh corresponding the the pick collision
  68663. */
  68664. pickedMesh: Nullable<AbstractMesh>;
  68665. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  68666. bu: number;
  68667. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  68668. bv: number;
  68669. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  68670. faceId: number;
  68671. /** Id of the the submesh that was picked */
  68672. subMeshId: number;
  68673. /** If a sprite was picked, this will be the sprite the pick collided with */
  68674. pickedSprite: Nullable<Sprite>;
  68675. /**
  68676. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  68677. */
  68678. originMesh: Nullable<AbstractMesh>;
  68679. /**
  68680. * The ray that was used to perform the picking.
  68681. */
  68682. ray: Nullable<Ray>;
  68683. /**
  68684. * Gets the normal correspodning to the face the pick collided with
  68685. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  68686. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  68687. * @returns The normal correspodning to the face the pick collided with
  68688. */
  68689. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  68690. /**
  68691. * Gets the texture coordinates of where the pick occured
  68692. * @returns the vector containing the coordnates of the texture
  68693. */
  68694. getTextureCoordinates(): Nullable<Vector2>;
  68695. }
  68696. }
  68697. declare module BABYLON {
  68698. /**
  68699. * Gather the list of pointer event types as constants.
  68700. */
  68701. export class PointerEventTypes {
  68702. /**
  68703. * 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.
  68704. */
  68705. static readonly POINTERDOWN: number;
  68706. /**
  68707. * The pointerup event is fired when a pointer is no longer active.
  68708. */
  68709. static readonly POINTERUP: number;
  68710. /**
  68711. * The pointermove event is fired when a pointer changes coordinates.
  68712. */
  68713. static readonly POINTERMOVE: number;
  68714. /**
  68715. * The pointerwheel event is fired when a mouse wheel has been rotated.
  68716. */
  68717. static readonly POINTERWHEEL: number;
  68718. /**
  68719. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  68720. */
  68721. static readonly POINTERPICK: number;
  68722. /**
  68723. * The pointertap event is fired when a the object has been touched and released without drag.
  68724. */
  68725. static readonly POINTERTAP: number;
  68726. /**
  68727. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  68728. */
  68729. static readonly POINTERDOUBLETAP: number;
  68730. }
  68731. /**
  68732. * Base class of pointer info types.
  68733. */
  68734. export class PointerInfoBase {
  68735. /**
  68736. * Defines the type of event (PointerEventTypes)
  68737. */
  68738. type: number;
  68739. /**
  68740. * Defines the related dom event
  68741. */
  68742. event: PointerEvent | MouseWheelEvent;
  68743. /**
  68744. * Instantiates the base class of pointers info.
  68745. * @param type Defines the type of event (PointerEventTypes)
  68746. * @param event Defines the related dom event
  68747. */
  68748. constructor(
  68749. /**
  68750. * Defines the type of event (PointerEventTypes)
  68751. */
  68752. type: number,
  68753. /**
  68754. * Defines the related dom event
  68755. */
  68756. event: PointerEvent | MouseWheelEvent);
  68757. }
  68758. /**
  68759. * This class is used to store pointer related info for the onPrePointerObservable event.
  68760. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  68761. */
  68762. export class PointerInfoPre extends PointerInfoBase {
  68763. /**
  68764. * Ray from a pointer if availible (eg. 6dof controller)
  68765. */
  68766. ray: Nullable<Ray>;
  68767. /**
  68768. * Defines the local position of the pointer on the canvas.
  68769. */
  68770. localPosition: Vector2;
  68771. /**
  68772. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  68773. */
  68774. skipOnPointerObservable: boolean;
  68775. /**
  68776. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  68777. * @param type Defines the type of event (PointerEventTypes)
  68778. * @param event Defines the related dom event
  68779. * @param localX Defines the local x coordinates of the pointer when the event occured
  68780. * @param localY Defines the local y coordinates of the pointer when the event occured
  68781. */
  68782. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  68783. }
  68784. /**
  68785. * This type contains all the data related to a pointer event in Babylon.js.
  68786. * 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.
  68787. */
  68788. export class PointerInfo extends PointerInfoBase {
  68789. /**
  68790. * Defines the picking info associated to the info (if any)\
  68791. */
  68792. pickInfo: Nullable<PickingInfo>;
  68793. /**
  68794. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  68795. * @param type Defines the type of event (PointerEventTypes)
  68796. * @param event Defines the related dom event
  68797. * @param pickInfo Defines the picking info associated to the info (if any)\
  68798. */
  68799. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  68800. /**
  68801. * Defines the picking info associated to the info (if any)\
  68802. */
  68803. pickInfo: Nullable<PickingInfo>);
  68804. }
  68805. }
  68806. declare module BABYLON {
  68807. /**
  68808. * Manage the mouse inputs to control the movement of a free camera.
  68809. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68810. */
  68811. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  68812. /**
  68813. * Define if touch is enabled in the mouse input
  68814. */
  68815. touchEnabled: boolean;
  68816. /**
  68817. * Defines the camera the input is attached to.
  68818. */
  68819. camera: FreeCamera;
  68820. /**
  68821. * Defines the buttons associated with the input to handle camera move.
  68822. */
  68823. buttons: number[];
  68824. /**
  68825. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  68826. */
  68827. angularSensibility: number;
  68828. private _pointerInput;
  68829. private _onMouseMove;
  68830. private _observer;
  68831. private previousPosition;
  68832. /**
  68833. * Manage the mouse inputs to control the movement of a free camera.
  68834. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68835. * @param touchEnabled Defines if touch is enabled or not
  68836. */
  68837. constructor(
  68838. /**
  68839. * Define if touch is enabled in the mouse input
  68840. */
  68841. touchEnabled?: boolean);
  68842. /**
  68843. * Attach the input controls to a specific dom element to get the input from.
  68844. * @param element Defines the element the controls should be listened from
  68845. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68846. */
  68847. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68848. /**
  68849. * Detach the current controls from the specified dom element.
  68850. * @param element Defines the element to stop listening the inputs from
  68851. */
  68852. detachControl(element: Nullable<HTMLElement>): void;
  68853. /**
  68854. * Gets the class name of the current intput.
  68855. * @returns the class name
  68856. */
  68857. getClassName(): string;
  68858. /**
  68859. * Get the friendly name associated with the input class.
  68860. * @returns the input friendly name
  68861. */
  68862. getSimpleName(): string;
  68863. }
  68864. }
  68865. declare module BABYLON {
  68866. /**
  68867. * Manage the touch inputs to control the movement of a free camera.
  68868. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68869. */
  68870. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  68871. /**
  68872. * Defines the camera the input is attached to.
  68873. */
  68874. camera: FreeCamera;
  68875. /**
  68876. * Defines the touch sensibility for rotation.
  68877. * The higher the faster.
  68878. */
  68879. touchAngularSensibility: number;
  68880. /**
  68881. * Defines the touch sensibility for move.
  68882. * The higher the faster.
  68883. */
  68884. touchMoveSensibility: number;
  68885. private _offsetX;
  68886. private _offsetY;
  68887. private _pointerPressed;
  68888. private _pointerInput;
  68889. private _observer;
  68890. private _onLostFocus;
  68891. /**
  68892. * Attach the input controls to a specific dom element to get the input from.
  68893. * @param element Defines the element the controls should be listened from
  68894. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68895. */
  68896. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68897. /**
  68898. * Detach the current controls from the specified dom element.
  68899. * @param element Defines the element to stop listening the inputs from
  68900. */
  68901. detachControl(element: Nullable<HTMLElement>): void;
  68902. /**
  68903. * Update the current camera state depending on the inputs that have been used this frame.
  68904. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68905. */
  68906. checkInputs(): void;
  68907. /**
  68908. * Gets the class name of the current intput.
  68909. * @returns the class name
  68910. */
  68911. getClassName(): string;
  68912. /**
  68913. * Get the friendly name associated with the input class.
  68914. * @returns the input friendly name
  68915. */
  68916. getSimpleName(): string;
  68917. }
  68918. }
  68919. declare module BABYLON {
  68920. /**
  68921. * Default Inputs manager for the FreeCamera.
  68922. * It groups all the default supported inputs for ease of use.
  68923. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68924. */
  68925. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  68926. /**
  68927. * Instantiates a new FreeCameraInputsManager.
  68928. * @param camera Defines the camera the inputs belong to
  68929. */
  68930. constructor(camera: FreeCamera);
  68931. /**
  68932. * Add keyboard input support to the input manager.
  68933. * @returns the current input manager
  68934. */
  68935. addKeyboard(): FreeCameraInputsManager;
  68936. /**
  68937. * Add mouse input support to the input manager.
  68938. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  68939. * @returns the current input manager
  68940. */
  68941. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  68942. /**
  68943. * Add touch input support to the input manager.
  68944. * @returns the current input manager
  68945. */
  68946. addTouch(): FreeCameraInputsManager;
  68947. }
  68948. }
  68949. declare module BABYLON {
  68950. /**
  68951. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  68952. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  68953. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  68954. */
  68955. export class FreeCamera extends TargetCamera {
  68956. /**
  68957. * Define the collision ellipsoid of the camera.
  68958. * This is helpful to simulate a camera body like the player body around the camera
  68959. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  68960. */
  68961. ellipsoid: Vector3;
  68962. /**
  68963. * Define an offset for the position of the ellipsoid around the camera.
  68964. * This can be helpful to determine the center of the body near the gravity center of the body
  68965. * instead of its head.
  68966. */
  68967. ellipsoidOffset: Vector3;
  68968. /**
  68969. * Enable or disable collisions of the camera with the rest of the scene objects.
  68970. */
  68971. checkCollisions: boolean;
  68972. /**
  68973. * Enable or disable gravity on the camera.
  68974. */
  68975. applyGravity: boolean;
  68976. /**
  68977. * Define the input manager associated to the camera.
  68978. */
  68979. inputs: FreeCameraInputsManager;
  68980. /**
  68981. * Gets the input sensibility for a mouse input. (default is 2000.0)
  68982. * Higher values reduce sensitivity.
  68983. */
  68984. /**
  68985. * Sets the input sensibility for a mouse input. (default is 2000.0)
  68986. * Higher values reduce sensitivity.
  68987. */
  68988. angularSensibility: number;
  68989. /**
  68990. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  68991. */
  68992. keysUp: number[];
  68993. /**
  68994. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  68995. */
  68996. keysDown: number[];
  68997. /**
  68998. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  68999. */
  69000. keysLeft: number[];
  69001. /**
  69002. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  69003. */
  69004. keysRight: number[];
  69005. /**
  69006. * Event raised when the camera collide with a mesh in the scene.
  69007. */
  69008. onCollide: (collidedMesh: AbstractMesh) => void;
  69009. private _collider;
  69010. private _needMoveForGravity;
  69011. private _oldPosition;
  69012. private _diffPosition;
  69013. private _newPosition;
  69014. /** @hidden */
  69015. _localDirection: Vector3;
  69016. /** @hidden */
  69017. _transformedDirection: Vector3;
  69018. /**
  69019. * Instantiates a Free Camera.
  69020. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  69021. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  69022. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  69023. * @param name Define the name of the camera in the scene
  69024. * @param position Define the start position of the camera in the scene
  69025. * @param scene Define the scene the camera belongs to
  69026. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  69027. */
  69028. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  69029. /**
  69030. * Attached controls to the current camera.
  69031. * @param element Defines the element the controls should be listened from
  69032. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  69033. */
  69034. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  69035. /**
  69036. * Detach the current controls from the camera.
  69037. * The camera will stop reacting to inputs.
  69038. * @param element Defines the element to stop listening the inputs from
  69039. */
  69040. detachControl(element: HTMLElement): void;
  69041. private _collisionMask;
  69042. /**
  69043. * Define a collision mask to limit the list of object the camera can collide with
  69044. */
  69045. collisionMask: number;
  69046. /** @hidden */
  69047. _collideWithWorld(displacement: Vector3): void;
  69048. private _onCollisionPositionChange;
  69049. /** @hidden */
  69050. _checkInputs(): void;
  69051. /** @hidden */
  69052. _decideIfNeedsToMove(): boolean;
  69053. /** @hidden */
  69054. _updatePosition(): void;
  69055. /**
  69056. * Destroy the camera and release the current resources hold by it.
  69057. */
  69058. dispose(): void;
  69059. /**
  69060. * Gets the current object class name.
  69061. * @return the class name
  69062. */
  69063. getClassName(): string;
  69064. }
  69065. }
  69066. declare module BABYLON {
  69067. /**
  69068. * Represents a gamepad control stick position
  69069. */
  69070. export class StickValues {
  69071. /**
  69072. * The x component of the control stick
  69073. */
  69074. x: number;
  69075. /**
  69076. * The y component of the control stick
  69077. */
  69078. y: number;
  69079. /**
  69080. * Initializes the gamepad x and y control stick values
  69081. * @param x The x component of the gamepad control stick value
  69082. * @param y The y component of the gamepad control stick value
  69083. */
  69084. constructor(
  69085. /**
  69086. * The x component of the control stick
  69087. */
  69088. x: number,
  69089. /**
  69090. * The y component of the control stick
  69091. */
  69092. y: number);
  69093. }
  69094. /**
  69095. * An interface which manages callbacks for gamepad button changes
  69096. */
  69097. export interface GamepadButtonChanges {
  69098. /**
  69099. * Called when a gamepad has been changed
  69100. */
  69101. changed: boolean;
  69102. /**
  69103. * Called when a gamepad press event has been triggered
  69104. */
  69105. pressChanged: boolean;
  69106. /**
  69107. * Called when a touch event has been triggered
  69108. */
  69109. touchChanged: boolean;
  69110. /**
  69111. * Called when a value has changed
  69112. */
  69113. valueChanged: boolean;
  69114. }
  69115. /**
  69116. * Represents a gamepad
  69117. */
  69118. export class Gamepad {
  69119. /**
  69120. * The id of the gamepad
  69121. */
  69122. id: string;
  69123. /**
  69124. * The index of the gamepad
  69125. */
  69126. index: number;
  69127. /**
  69128. * The browser gamepad
  69129. */
  69130. browserGamepad: any;
  69131. /**
  69132. * Specifies what type of gamepad this represents
  69133. */
  69134. type: number;
  69135. private _leftStick;
  69136. private _rightStick;
  69137. /** @hidden */
  69138. _isConnected: boolean;
  69139. private _leftStickAxisX;
  69140. private _leftStickAxisY;
  69141. private _rightStickAxisX;
  69142. private _rightStickAxisY;
  69143. /**
  69144. * Triggered when the left control stick has been changed
  69145. */
  69146. private _onleftstickchanged;
  69147. /**
  69148. * Triggered when the right control stick has been changed
  69149. */
  69150. private _onrightstickchanged;
  69151. /**
  69152. * Represents a gamepad controller
  69153. */
  69154. static GAMEPAD: number;
  69155. /**
  69156. * Represents a generic controller
  69157. */
  69158. static GENERIC: number;
  69159. /**
  69160. * Represents an XBox controller
  69161. */
  69162. static XBOX: number;
  69163. /**
  69164. * Represents a pose-enabled controller
  69165. */
  69166. static POSE_ENABLED: number;
  69167. /**
  69168. * Specifies whether the left control stick should be Y-inverted
  69169. */
  69170. protected _invertLeftStickY: boolean;
  69171. /**
  69172. * Specifies if the gamepad has been connected
  69173. */
  69174. readonly isConnected: boolean;
  69175. /**
  69176. * Initializes the gamepad
  69177. * @param id The id of the gamepad
  69178. * @param index The index of the gamepad
  69179. * @param browserGamepad The browser gamepad
  69180. * @param leftStickX The x component of the left joystick
  69181. * @param leftStickY The y component of the left joystick
  69182. * @param rightStickX The x component of the right joystick
  69183. * @param rightStickY The y component of the right joystick
  69184. */
  69185. constructor(
  69186. /**
  69187. * The id of the gamepad
  69188. */
  69189. id: string,
  69190. /**
  69191. * The index of the gamepad
  69192. */
  69193. index: number,
  69194. /**
  69195. * The browser gamepad
  69196. */
  69197. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  69198. /**
  69199. * Callback triggered when the left joystick has changed
  69200. * @param callback
  69201. */
  69202. onleftstickchanged(callback: (values: StickValues) => void): void;
  69203. /**
  69204. * Callback triggered when the right joystick has changed
  69205. * @param callback
  69206. */
  69207. onrightstickchanged(callback: (values: StickValues) => void): void;
  69208. /**
  69209. * Gets the left joystick
  69210. */
  69211. /**
  69212. * Sets the left joystick values
  69213. */
  69214. leftStick: StickValues;
  69215. /**
  69216. * Gets the right joystick
  69217. */
  69218. /**
  69219. * Sets the right joystick value
  69220. */
  69221. rightStick: StickValues;
  69222. /**
  69223. * Updates the gamepad joystick positions
  69224. */
  69225. update(): void;
  69226. /**
  69227. * Disposes the gamepad
  69228. */
  69229. dispose(): void;
  69230. }
  69231. /**
  69232. * Represents a generic gamepad
  69233. */
  69234. export class GenericPad extends Gamepad {
  69235. private _buttons;
  69236. private _onbuttondown;
  69237. private _onbuttonup;
  69238. /**
  69239. * Observable triggered when a button has been pressed
  69240. */
  69241. onButtonDownObservable: Observable<number>;
  69242. /**
  69243. * Observable triggered when a button has been released
  69244. */
  69245. onButtonUpObservable: Observable<number>;
  69246. /**
  69247. * Callback triggered when a button has been pressed
  69248. * @param callback Called when a button has been pressed
  69249. */
  69250. onbuttondown(callback: (buttonPressed: number) => void): void;
  69251. /**
  69252. * Callback triggered when a button has been released
  69253. * @param callback Called when a button has been released
  69254. */
  69255. onbuttonup(callback: (buttonReleased: number) => void): void;
  69256. /**
  69257. * Initializes the generic gamepad
  69258. * @param id The id of the generic gamepad
  69259. * @param index The index of the generic gamepad
  69260. * @param browserGamepad The browser gamepad
  69261. */
  69262. constructor(id: string, index: number, browserGamepad: any);
  69263. private _setButtonValue;
  69264. /**
  69265. * Updates the generic gamepad
  69266. */
  69267. update(): void;
  69268. /**
  69269. * Disposes the generic gamepad
  69270. */
  69271. dispose(): void;
  69272. }
  69273. }
  69274. declare module BABYLON {
  69275. /**
  69276. * Defines the types of pose enabled controllers that are supported
  69277. */
  69278. export enum PoseEnabledControllerType {
  69279. /**
  69280. * HTC Vive
  69281. */
  69282. VIVE = 0,
  69283. /**
  69284. * Oculus Rift
  69285. */
  69286. OCULUS = 1,
  69287. /**
  69288. * Windows mixed reality
  69289. */
  69290. WINDOWS = 2,
  69291. /**
  69292. * Samsung gear VR
  69293. */
  69294. GEAR_VR = 3,
  69295. /**
  69296. * Google Daydream
  69297. */
  69298. DAYDREAM = 4,
  69299. /**
  69300. * Generic
  69301. */
  69302. GENERIC = 5
  69303. }
  69304. /**
  69305. * Defines the MutableGamepadButton interface for the state of a gamepad button
  69306. */
  69307. export interface MutableGamepadButton {
  69308. /**
  69309. * Value of the button/trigger
  69310. */
  69311. value: number;
  69312. /**
  69313. * If the button/trigger is currently touched
  69314. */
  69315. touched: boolean;
  69316. /**
  69317. * If the button/trigger is currently pressed
  69318. */
  69319. pressed: boolean;
  69320. }
  69321. /**
  69322. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  69323. * @hidden
  69324. */
  69325. export interface ExtendedGamepadButton extends GamepadButton {
  69326. /**
  69327. * If the button/trigger is currently pressed
  69328. */
  69329. readonly pressed: boolean;
  69330. /**
  69331. * If the button/trigger is currently touched
  69332. */
  69333. readonly touched: boolean;
  69334. /**
  69335. * Value of the button/trigger
  69336. */
  69337. readonly value: number;
  69338. }
  69339. /** @hidden */
  69340. export interface _GamePadFactory {
  69341. /**
  69342. * Returns wether or not the current gamepad can be created for this type of controller.
  69343. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  69344. * @returns true if it can be created, otherwise false
  69345. */
  69346. canCreate(gamepadInfo: any): boolean;
  69347. /**
  69348. * Creates a new instance of the Gamepad.
  69349. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  69350. * @returns the new gamepad instance
  69351. */
  69352. create(gamepadInfo: any): Gamepad;
  69353. }
  69354. /**
  69355. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  69356. */
  69357. export class PoseEnabledControllerHelper {
  69358. /** @hidden */
  69359. static _ControllerFactories: _GamePadFactory[];
  69360. /** @hidden */
  69361. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  69362. /**
  69363. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  69364. * @param vrGamepad the gamepad to initialized
  69365. * @returns a vr controller of the type the gamepad identified as
  69366. */
  69367. static InitiateController(vrGamepad: any): Gamepad;
  69368. }
  69369. /**
  69370. * Defines the PoseEnabledController object that contains state of a vr capable controller
  69371. */
  69372. export class PoseEnabledController extends Gamepad implements PoseControlled {
  69373. private _deviceRoomPosition;
  69374. private _deviceRoomRotationQuaternion;
  69375. /**
  69376. * The device position in babylon space
  69377. */
  69378. devicePosition: Vector3;
  69379. /**
  69380. * The device rotation in babylon space
  69381. */
  69382. deviceRotationQuaternion: Quaternion;
  69383. /**
  69384. * The scale factor of the device in babylon space
  69385. */
  69386. deviceScaleFactor: number;
  69387. /**
  69388. * (Likely devicePosition should be used instead) The device position in its room space
  69389. */
  69390. position: Vector3;
  69391. /**
  69392. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  69393. */
  69394. rotationQuaternion: Quaternion;
  69395. /**
  69396. * The type of controller (Eg. Windows mixed reality)
  69397. */
  69398. controllerType: PoseEnabledControllerType;
  69399. protected _calculatedPosition: Vector3;
  69400. private _calculatedRotation;
  69401. /**
  69402. * The raw pose from the device
  69403. */
  69404. rawPose: DevicePose;
  69405. private _trackPosition;
  69406. private _maxRotationDistFromHeadset;
  69407. private _draggedRoomRotation;
  69408. /**
  69409. * @hidden
  69410. */
  69411. _disableTrackPosition(fixedPosition: Vector3): void;
  69412. /**
  69413. * Internal, the mesh attached to the controller
  69414. * @hidden
  69415. */
  69416. _mesh: Nullable<AbstractMesh>;
  69417. private _poseControlledCamera;
  69418. private _leftHandSystemQuaternion;
  69419. /**
  69420. * Internal, matrix used to convert room space to babylon space
  69421. * @hidden
  69422. */
  69423. _deviceToWorld: Matrix;
  69424. /**
  69425. * Node to be used when casting a ray from the controller
  69426. * @hidden
  69427. */
  69428. _pointingPoseNode: Nullable<TransformNode>;
  69429. /**
  69430. * Name of the child mesh that can be used to cast a ray from the controller
  69431. */
  69432. static readonly POINTING_POSE: string;
  69433. /**
  69434. * Creates a new PoseEnabledController from a gamepad
  69435. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  69436. */
  69437. constructor(browserGamepad: any);
  69438. private _workingMatrix;
  69439. /**
  69440. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  69441. */
  69442. update(): void;
  69443. /**
  69444. * Updates only the pose device and mesh without doing any button event checking
  69445. */
  69446. protected _updatePoseAndMesh(): void;
  69447. /**
  69448. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  69449. * @param poseData raw pose fromthe device
  69450. */
  69451. updateFromDevice(poseData: DevicePose): void;
  69452. /**
  69453. * @hidden
  69454. */
  69455. _meshAttachedObservable: Observable<AbstractMesh>;
  69456. /**
  69457. * Attaches a mesh to the controller
  69458. * @param mesh the mesh to be attached
  69459. */
  69460. attachToMesh(mesh: AbstractMesh): void;
  69461. /**
  69462. * Attaches the controllers mesh to a camera
  69463. * @param camera the camera the mesh should be attached to
  69464. */
  69465. attachToPoseControlledCamera(camera: TargetCamera): void;
  69466. /**
  69467. * Disposes of the controller
  69468. */
  69469. dispose(): void;
  69470. /**
  69471. * The mesh that is attached to the controller
  69472. */
  69473. readonly mesh: Nullable<AbstractMesh>;
  69474. /**
  69475. * Gets the ray of the controller in the direction the controller is pointing
  69476. * @param length the length the resulting ray should be
  69477. * @returns a ray in the direction the controller is pointing
  69478. */
  69479. getForwardRay(length?: number): Ray;
  69480. }
  69481. }
  69482. declare module BABYLON {
  69483. /**
  69484. * Defines the WebVRController object that represents controllers tracked in 3D space
  69485. */
  69486. export abstract class WebVRController extends PoseEnabledController {
  69487. /**
  69488. * Internal, the default controller model for the controller
  69489. */
  69490. protected _defaultModel: AbstractMesh;
  69491. /**
  69492. * Fired when the trigger state has changed
  69493. */
  69494. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  69495. /**
  69496. * Fired when the main button state has changed
  69497. */
  69498. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  69499. /**
  69500. * Fired when the secondary button state has changed
  69501. */
  69502. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  69503. /**
  69504. * Fired when the pad state has changed
  69505. */
  69506. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  69507. /**
  69508. * Fired when controllers stick values have changed
  69509. */
  69510. onPadValuesChangedObservable: Observable<StickValues>;
  69511. /**
  69512. * Array of button availible on the controller
  69513. */
  69514. protected _buttons: Array<MutableGamepadButton>;
  69515. private _onButtonStateChange;
  69516. /**
  69517. * Fired when a controller button's state has changed
  69518. * @param callback the callback containing the button that was modified
  69519. */
  69520. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  69521. /**
  69522. * X and Y axis corrisponding to the controllers joystick
  69523. */
  69524. pad: StickValues;
  69525. /**
  69526. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  69527. */
  69528. hand: string;
  69529. /**
  69530. * The default controller model for the controller
  69531. */
  69532. readonly defaultModel: AbstractMesh;
  69533. /**
  69534. * Creates a new WebVRController from a gamepad
  69535. * @param vrGamepad the gamepad that the WebVRController should be created from
  69536. */
  69537. constructor(vrGamepad: any);
  69538. /**
  69539. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  69540. */
  69541. update(): void;
  69542. /**
  69543. * Function to be called when a button is modified
  69544. */
  69545. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  69546. /**
  69547. * Loads a mesh and attaches it to the controller
  69548. * @param scene the scene the mesh should be added to
  69549. * @param meshLoaded callback for when the mesh has been loaded
  69550. */
  69551. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  69552. private _setButtonValue;
  69553. private _changes;
  69554. private _checkChanges;
  69555. /**
  69556. * Disposes of th webVRCOntroller
  69557. */
  69558. dispose(): void;
  69559. }
  69560. }
  69561. declare module BABYLON {
  69562. /**
  69563. * The HemisphericLight simulates the ambient environment light,
  69564. * so the passed direction is the light reflection direction, not the incoming direction.
  69565. */
  69566. export class HemisphericLight extends Light {
  69567. /**
  69568. * The groundColor is the light in the opposite direction to the one specified during creation.
  69569. * 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.
  69570. */
  69571. groundColor: Color3;
  69572. /**
  69573. * The light reflection direction, not the incoming direction.
  69574. */
  69575. direction: Vector3;
  69576. /**
  69577. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  69578. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  69579. * The HemisphericLight can't cast shadows.
  69580. * Documentation : https://doc.babylonjs.com/babylon101/lights
  69581. * @param name The friendly name of the light
  69582. * @param direction The direction of the light reflection
  69583. * @param scene The scene the light belongs to
  69584. */
  69585. constructor(name: string, direction: Vector3, scene: Scene);
  69586. protected _buildUniformLayout(): void;
  69587. /**
  69588. * Returns the string "HemisphericLight".
  69589. * @return The class name
  69590. */
  69591. getClassName(): string;
  69592. /**
  69593. * Sets the HemisphericLight direction towards the passed target (Vector3).
  69594. * Returns the updated direction.
  69595. * @param target The target the direction should point to
  69596. * @return The computed direction
  69597. */
  69598. setDirectionToTarget(target: Vector3): Vector3;
  69599. /**
  69600. * Returns the shadow generator associated to the light.
  69601. * @returns Always null for hemispheric lights because it does not support shadows.
  69602. */
  69603. getShadowGenerator(): Nullable<IShadowGenerator>;
  69604. /**
  69605. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  69606. * @param effect The effect to update
  69607. * @param lightIndex The index of the light in the effect to update
  69608. * @returns The hemispheric light
  69609. */
  69610. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  69611. /**
  69612. * Computes the world matrix of the node
  69613. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  69614. * @param useWasUpdatedFlag defines a reserved property
  69615. * @returns the world matrix
  69616. */
  69617. computeWorldMatrix(): Matrix;
  69618. /**
  69619. * Returns the integer 3.
  69620. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  69621. */
  69622. getTypeID(): number;
  69623. /**
  69624. * Prepares the list of defines specific to the light type.
  69625. * @param defines the list of defines
  69626. * @param lightIndex defines the index of the light for the effect
  69627. */
  69628. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  69629. }
  69630. }
  69631. declare module BABYLON {
  69632. /**
  69633. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  69634. * IMPORTANT!! The data is right-hand data.
  69635. * @export
  69636. * @interface DevicePose
  69637. */
  69638. export interface DevicePose {
  69639. /**
  69640. * The position of the device, values in array are [x,y,z].
  69641. */
  69642. readonly position: Nullable<Float32Array>;
  69643. /**
  69644. * The linearVelocity of the device, values in array are [x,y,z].
  69645. */
  69646. readonly linearVelocity: Nullable<Float32Array>;
  69647. /**
  69648. * The linearAcceleration of the device, values in array are [x,y,z].
  69649. */
  69650. readonly linearAcceleration: Nullable<Float32Array>;
  69651. /**
  69652. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  69653. */
  69654. readonly orientation: Nullable<Float32Array>;
  69655. /**
  69656. * The angularVelocity of the device, values in array are [x,y,z].
  69657. */
  69658. readonly angularVelocity: Nullable<Float32Array>;
  69659. /**
  69660. * The angularAcceleration of the device, values in array are [x,y,z].
  69661. */
  69662. readonly angularAcceleration: Nullable<Float32Array>;
  69663. }
  69664. /**
  69665. * Interface representing a pose controlled object in Babylon.
  69666. * A pose controlled object has both regular pose values as well as pose values
  69667. * from an external device such as a VR head mounted display
  69668. */
  69669. export interface PoseControlled {
  69670. /**
  69671. * The position of the object in babylon space.
  69672. */
  69673. position: Vector3;
  69674. /**
  69675. * The rotation quaternion of the object in babylon space.
  69676. */
  69677. rotationQuaternion: Quaternion;
  69678. /**
  69679. * The position of the device in babylon space.
  69680. */
  69681. devicePosition?: Vector3;
  69682. /**
  69683. * The rotation quaternion of the device in babylon space.
  69684. */
  69685. deviceRotationQuaternion: Quaternion;
  69686. /**
  69687. * The raw pose coming from the device.
  69688. */
  69689. rawPose: Nullable<DevicePose>;
  69690. /**
  69691. * The scale of the device to be used when translating from device space to babylon space.
  69692. */
  69693. deviceScaleFactor: number;
  69694. /**
  69695. * Updates the poseControlled values based on the input device pose.
  69696. * @param poseData the pose data to update the object with
  69697. */
  69698. updateFromDevice(poseData: DevicePose): void;
  69699. }
  69700. /**
  69701. * Set of options to customize the webVRCamera
  69702. */
  69703. export interface WebVROptions {
  69704. /**
  69705. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  69706. */
  69707. trackPosition?: boolean;
  69708. /**
  69709. * Sets the scale of the vrDevice in babylon space. (default: 1)
  69710. */
  69711. positionScale?: number;
  69712. /**
  69713. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  69714. */
  69715. displayName?: string;
  69716. /**
  69717. * Should the native controller meshes be initialized. (default: true)
  69718. */
  69719. controllerMeshes?: boolean;
  69720. /**
  69721. * Creating a default HemiLight only on controllers. (default: true)
  69722. */
  69723. defaultLightingOnControllers?: boolean;
  69724. /**
  69725. * If you don't want to use the default VR button of the helper. (default: false)
  69726. */
  69727. useCustomVRButton?: boolean;
  69728. /**
  69729. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  69730. */
  69731. customVRButton?: HTMLButtonElement;
  69732. /**
  69733. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  69734. */
  69735. rayLength?: number;
  69736. /**
  69737. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  69738. */
  69739. defaultHeight?: number;
  69740. }
  69741. /**
  69742. * This represents a WebVR camera.
  69743. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  69744. * @example http://doc.babylonjs.com/how_to/webvr_camera
  69745. */
  69746. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  69747. private webVROptions;
  69748. /**
  69749. * @hidden
  69750. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  69751. */
  69752. _vrDevice: any;
  69753. /**
  69754. * The rawPose of the vrDevice.
  69755. */
  69756. rawPose: Nullable<DevicePose>;
  69757. private _onVREnabled;
  69758. private _specsVersion;
  69759. private _attached;
  69760. private _frameData;
  69761. protected _descendants: Array<Node>;
  69762. private _deviceRoomPosition;
  69763. /** @hidden */
  69764. _deviceRoomRotationQuaternion: Quaternion;
  69765. private _standingMatrix;
  69766. /**
  69767. * Represents device position in babylon space.
  69768. */
  69769. devicePosition: Vector3;
  69770. /**
  69771. * Represents device rotation in babylon space.
  69772. */
  69773. deviceRotationQuaternion: Quaternion;
  69774. /**
  69775. * The scale of the device to be used when translating from device space to babylon space.
  69776. */
  69777. deviceScaleFactor: number;
  69778. private _deviceToWorld;
  69779. private _worldToDevice;
  69780. /**
  69781. * References to the webVR controllers for the vrDevice.
  69782. */
  69783. controllers: Array<WebVRController>;
  69784. /**
  69785. * Emits an event when a controller is attached.
  69786. */
  69787. onControllersAttachedObservable: Observable<WebVRController[]>;
  69788. /**
  69789. * Emits an event when a controller's mesh has been loaded;
  69790. */
  69791. onControllerMeshLoadedObservable: Observable<WebVRController>;
  69792. /**
  69793. * Emits an event when the HMD's pose has been updated.
  69794. */
  69795. onPoseUpdatedFromDeviceObservable: Observable<any>;
  69796. private _poseSet;
  69797. /**
  69798. * If the rig cameras be used as parent instead of this camera.
  69799. */
  69800. rigParenting: boolean;
  69801. private _lightOnControllers;
  69802. private _defaultHeight?;
  69803. /**
  69804. * Instantiates a WebVRFreeCamera.
  69805. * @param name The name of the WebVRFreeCamera
  69806. * @param position The starting anchor position for the camera
  69807. * @param scene The scene the camera belongs to
  69808. * @param webVROptions a set of customizable options for the webVRCamera
  69809. */
  69810. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  69811. /**
  69812. * Gets the device distance from the ground in meters.
  69813. * @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.
  69814. */
  69815. deviceDistanceToRoomGround(): number;
  69816. /**
  69817. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  69818. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  69819. */
  69820. useStandingMatrix(callback?: (bool: boolean) => void): void;
  69821. /**
  69822. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  69823. * @returns A promise with a boolean set to if the standing matrix is supported.
  69824. */
  69825. useStandingMatrixAsync(): Promise<boolean>;
  69826. /**
  69827. * Disposes the camera
  69828. */
  69829. dispose(): void;
  69830. /**
  69831. * Gets a vrController by name.
  69832. * @param name The name of the controller to retreive
  69833. * @returns the controller matching the name specified or null if not found
  69834. */
  69835. getControllerByName(name: string): Nullable<WebVRController>;
  69836. private _leftController;
  69837. /**
  69838. * The controller corrisponding to the users left hand.
  69839. */
  69840. readonly leftController: Nullable<WebVRController>;
  69841. private _rightController;
  69842. /**
  69843. * The controller corrisponding to the users right hand.
  69844. */
  69845. readonly rightController: Nullable<WebVRController>;
  69846. /**
  69847. * Casts a ray forward from the vrCamera's gaze.
  69848. * @param length Length of the ray (default: 100)
  69849. * @returns the ray corrisponding to the gaze
  69850. */
  69851. getForwardRay(length?: number): Ray;
  69852. /**
  69853. * @hidden
  69854. * Updates the camera based on device's frame data
  69855. */
  69856. _checkInputs(): void;
  69857. /**
  69858. * Updates the poseControlled values based on the input device pose.
  69859. * @param poseData Pose coming from the device
  69860. */
  69861. updateFromDevice(poseData: DevicePose): void;
  69862. private _htmlElementAttached;
  69863. private _detachIfAttached;
  69864. /**
  69865. * WebVR's attach control will start broadcasting frames to the device.
  69866. * Note that in certain browsers (chrome for example) this function must be called
  69867. * within a user-interaction callback. Example:
  69868. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  69869. *
  69870. * @param element html element to attach the vrDevice to
  69871. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  69872. */
  69873. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  69874. /**
  69875. * Detaches the camera from the html element and disables VR
  69876. *
  69877. * @param element html element to detach from
  69878. */
  69879. detachControl(element: HTMLElement): void;
  69880. /**
  69881. * @returns the name of this class
  69882. */
  69883. getClassName(): string;
  69884. /**
  69885. * Calls resetPose on the vrDisplay
  69886. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  69887. */
  69888. resetToCurrentRotation(): void;
  69889. /**
  69890. * @hidden
  69891. * Updates the rig cameras (left and right eye)
  69892. */
  69893. _updateRigCameras(): void;
  69894. private _workingVector;
  69895. private _oneVector;
  69896. private _workingMatrix;
  69897. private updateCacheCalled;
  69898. private _correctPositionIfNotTrackPosition;
  69899. /**
  69900. * @hidden
  69901. * Updates the cached values of the camera
  69902. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  69903. */
  69904. _updateCache(ignoreParentClass?: boolean): void;
  69905. /**
  69906. * @hidden
  69907. * Get current device position in babylon world
  69908. */
  69909. _computeDevicePosition(): void;
  69910. /**
  69911. * Updates the current device position and rotation in the babylon world
  69912. */
  69913. update(): void;
  69914. /**
  69915. * @hidden
  69916. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  69917. * @returns an identity matrix
  69918. */
  69919. _getViewMatrix(): Matrix;
  69920. private _tmpMatrix;
  69921. /**
  69922. * This function is called by the two RIG cameras.
  69923. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  69924. * @hidden
  69925. */
  69926. _getWebVRViewMatrix(): Matrix;
  69927. /** @hidden */
  69928. _getWebVRProjectionMatrix(): Matrix;
  69929. private _onGamepadConnectedObserver;
  69930. private _onGamepadDisconnectedObserver;
  69931. private _updateCacheWhenTrackingDisabledObserver;
  69932. /**
  69933. * Initializes the controllers and their meshes
  69934. */
  69935. initControllers(): void;
  69936. }
  69937. }
  69938. declare module BABYLON {
  69939. /**
  69940. * Size options for a post process
  69941. */
  69942. export type PostProcessOptions = {
  69943. width: number;
  69944. height: number;
  69945. };
  69946. /**
  69947. * PostProcess can be used to apply a shader to a texture after it has been rendered
  69948. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69949. */
  69950. export class PostProcess {
  69951. /** Name of the PostProcess. */
  69952. name: string;
  69953. /**
  69954. * Gets or sets the unique id of the post process
  69955. */
  69956. uniqueId: number;
  69957. /**
  69958. * Width of the texture to apply the post process on
  69959. */
  69960. width: number;
  69961. /**
  69962. * Height of the texture to apply the post process on
  69963. */
  69964. height: number;
  69965. /**
  69966. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  69967. * @hidden
  69968. */
  69969. _outputTexture: Nullable<InternalTexture>;
  69970. /**
  69971. * Sampling mode used by the shader
  69972. * See https://doc.babylonjs.com/classes/3.1/texture
  69973. */
  69974. renderTargetSamplingMode: number;
  69975. /**
  69976. * Clear color to use when screen clearing
  69977. */
  69978. clearColor: Color4;
  69979. /**
  69980. * If the buffer needs to be cleared before applying the post process. (default: true)
  69981. * Should be set to false if shader will overwrite all previous pixels.
  69982. */
  69983. autoClear: boolean;
  69984. /**
  69985. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  69986. */
  69987. alphaMode: number;
  69988. /**
  69989. * Sets the setAlphaBlendConstants of the babylon engine
  69990. */
  69991. alphaConstants: Color4;
  69992. /**
  69993. * Animations to be used for the post processing
  69994. */
  69995. animations: Animation[];
  69996. /**
  69997. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  69998. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  69999. */
  70000. enablePixelPerfectMode: boolean;
  70001. /**
  70002. * Force the postprocess to be applied without taking in account viewport
  70003. */
  70004. forceFullscreenViewport: boolean;
  70005. /**
  70006. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  70007. *
  70008. * | Value | Type | Description |
  70009. * | ----- | ----------------------------------- | ----------- |
  70010. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  70011. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  70012. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  70013. *
  70014. */
  70015. scaleMode: number;
  70016. /**
  70017. * Force textures to be a power of two (default: false)
  70018. */
  70019. alwaysForcePOT: boolean;
  70020. private _samples;
  70021. /**
  70022. * Number of sample textures (default: 1)
  70023. */
  70024. samples: number;
  70025. /**
  70026. * Modify the scale of the post process to be the same as the viewport (default: false)
  70027. */
  70028. adaptScaleToCurrentViewport: boolean;
  70029. private _camera;
  70030. private _scene;
  70031. private _engine;
  70032. private _options;
  70033. private _reusable;
  70034. private _textureType;
  70035. /**
  70036. * Smart array of input and output textures for the post process.
  70037. * @hidden
  70038. */
  70039. _textures: SmartArray<InternalTexture>;
  70040. /**
  70041. * The index in _textures that corresponds to the output texture.
  70042. * @hidden
  70043. */
  70044. _currentRenderTextureInd: number;
  70045. private _effect;
  70046. private _samplers;
  70047. private _fragmentUrl;
  70048. private _vertexUrl;
  70049. private _parameters;
  70050. private _scaleRatio;
  70051. protected _indexParameters: any;
  70052. private _shareOutputWithPostProcess;
  70053. private _texelSize;
  70054. private _forcedOutputTexture;
  70055. /**
  70056. * Returns the fragment url or shader name used in the post process.
  70057. * @returns the fragment url or name in the shader store.
  70058. */
  70059. getEffectName(): string;
  70060. /**
  70061. * An event triggered when the postprocess is activated.
  70062. */
  70063. onActivateObservable: Observable<Camera>;
  70064. private _onActivateObserver;
  70065. /**
  70066. * A function that is added to the onActivateObservable
  70067. */
  70068. onActivate: Nullable<(camera: Camera) => void>;
  70069. /**
  70070. * An event triggered when the postprocess changes its size.
  70071. */
  70072. onSizeChangedObservable: Observable<PostProcess>;
  70073. private _onSizeChangedObserver;
  70074. /**
  70075. * A function that is added to the onSizeChangedObservable
  70076. */
  70077. onSizeChanged: (postProcess: PostProcess) => void;
  70078. /**
  70079. * An event triggered when the postprocess applies its effect.
  70080. */
  70081. onApplyObservable: Observable<Effect>;
  70082. private _onApplyObserver;
  70083. /**
  70084. * A function that is added to the onApplyObservable
  70085. */
  70086. onApply: (effect: Effect) => void;
  70087. /**
  70088. * An event triggered before rendering the postprocess
  70089. */
  70090. onBeforeRenderObservable: Observable<Effect>;
  70091. private _onBeforeRenderObserver;
  70092. /**
  70093. * A function that is added to the onBeforeRenderObservable
  70094. */
  70095. onBeforeRender: (effect: Effect) => void;
  70096. /**
  70097. * An event triggered after rendering the postprocess
  70098. */
  70099. onAfterRenderObservable: Observable<Effect>;
  70100. private _onAfterRenderObserver;
  70101. /**
  70102. * A function that is added to the onAfterRenderObservable
  70103. */
  70104. onAfterRender: (efect: Effect) => void;
  70105. /**
  70106. * 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
  70107. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  70108. */
  70109. inputTexture: InternalTexture;
  70110. /**
  70111. * Gets the camera which post process is applied to.
  70112. * @returns The camera the post process is applied to.
  70113. */
  70114. getCamera(): Camera;
  70115. /**
  70116. * Gets the texel size of the postprocess.
  70117. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  70118. */
  70119. readonly texelSize: Vector2;
  70120. /**
  70121. * Creates a new instance PostProcess
  70122. * @param name The name of the PostProcess.
  70123. * @param fragmentUrl The url of the fragment shader to be used.
  70124. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  70125. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  70126. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  70127. * @param camera The camera to apply the render pass to.
  70128. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70129. * @param engine The engine which the post process will be applied. (default: current engine)
  70130. * @param reusable If the post process can be reused on the same frame. (default: false)
  70131. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  70132. * @param textureType Type of textures used when performing the post process. (default: 0)
  70133. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  70134. * @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
  70135. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  70136. */
  70137. constructor(
  70138. /** Name of the PostProcess. */
  70139. 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);
  70140. /**
  70141. * Gets a string idenfifying the name of the class
  70142. * @returns "PostProcess" string
  70143. */
  70144. getClassName(): string;
  70145. /**
  70146. * Gets the engine which this post process belongs to.
  70147. * @returns The engine the post process was enabled with.
  70148. */
  70149. getEngine(): Engine;
  70150. /**
  70151. * The effect that is created when initializing the post process.
  70152. * @returns The created effect corrisponding the the postprocess.
  70153. */
  70154. getEffect(): Effect;
  70155. /**
  70156. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  70157. * @param postProcess The post process to share the output with.
  70158. * @returns This post process.
  70159. */
  70160. shareOutputWith(postProcess: PostProcess): PostProcess;
  70161. /**
  70162. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  70163. * This should be called if the post process that shares output with this post process is disabled/disposed.
  70164. */
  70165. useOwnOutput(): void;
  70166. /**
  70167. * Updates the effect with the current post process compile time values and recompiles the shader.
  70168. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  70169. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  70170. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  70171. * @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
  70172. * @param onCompiled Called when the shader has been compiled.
  70173. * @param onError Called if there is an error when compiling a shader.
  70174. */
  70175. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  70176. /**
  70177. * The post process is reusable if it can be used multiple times within one frame.
  70178. * @returns If the post process is reusable
  70179. */
  70180. isReusable(): boolean;
  70181. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  70182. markTextureDirty(): void;
  70183. /**
  70184. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  70185. * 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.
  70186. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  70187. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  70188. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  70189. * @returns The target texture that was bound to be written to.
  70190. */
  70191. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  70192. /**
  70193. * If the post process is supported.
  70194. */
  70195. readonly isSupported: boolean;
  70196. /**
  70197. * The aspect ratio of the output texture.
  70198. */
  70199. readonly aspectRatio: number;
  70200. /**
  70201. * Get a value indicating if the post-process is ready to be used
  70202. * @returns true if the post-process is ready (shader is compiled)
  70203. */
  70204. isReady(): boolean;
  70205. /**
  70206. * Binds all textures and uniforms to the shader, this will be run on every pass.
  70207. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  70208. */
  70209. apply(): Nullable<Effect>;
  70210. private _disposeTextures;
  70211. /**
  70212. * Disposes the post process.
  70213. * @param camera The camera to dispose the post process on.
  70214. */
  70215. dispose(camera?: Camera): void;
  70216. }
  70217. }
  70218. declare module BABYLON {
  70219. /**
  70220. * PostProcessManager is used to manage one or more post processes or post process pipelines
  70221. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70222. */
  70223. export class PostProcessManager {
  70224. private _scene;
  70225. private _indexBuffer;
  70226. private _vertexBuffers;
  70227. /**
  70228. * Creates a new instance PostProcess
  70229. * @param scene The scene that the post process is associated with.
  70230. */
  70231. constructor(scene: Scene);
  70232. private _prepareBuffers;
  70233. private _buildIndexBuffer;
  70234. /**
  70235. * Rebuilds the vertex buffers of the manager.
  70236. * @hidden
  70237. */
  70238. _rebuild(): void;
  70239. /**
  70240. * Prepares a frame to be run through a post process.
  70241. * @param sourceTexture The input texture to the post procesess. (default: null)
  70242. * @param postProcesses An array of post processes to be run. (default: null)
  70243. * @returns True if the post processes were able to be run.
  70244. * @hidden
  70245. */
  70246. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  70247. /**
  70248. * Manually render a set of post processes to a texture.
  70249. * @param postProcesses An array of post processes to be run.
  70250. * @param targetTexture The target texture to render to.
  70251. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  70252. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  70253. * @param lodLevel defines which lod of the texture to render to
  70254. */
  70255. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  70256. /**
  70257. * Finalize the result of the output of the postprocesses.
  70258. * @param doNotPresent If true the result will not be displayed to the screen.
  70259. * @param targetTexture The target texture to render to.
  70260. * @param faceIndex The index of the face to bind the target texture to.
  70261. * @param postProcesses The array of post processes to render.
  70262. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  70263. * @hidden
  70264. */
  70265. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  70266. /**
  70267. * Disposes of the post process manager.
  70268. */
  70269. dispose(): void;
  70270. }
  70271. }
  70272. declare module BABYLON {
  70273. interface AbstractScene {
  70274. /**
  70275. * The list of layers (background and foreground) of the scene
  70276. */
  70277. layers: Array<Layer>;
  70278. }
  70279. /**
  70280. * Defines the layer scene component responsible to manage any layers
  70281. * in a given scene.
  70282. */
  70283. export class LayerSceneComponent implements ISceneComponent {
  70284. /**
  70285. * The component name helpfull to identify the component in the list of scene components.
  70286. */
  70287. readonly name: string;
  70288. /**
  70289. * The scene the component belongs to.
  70290. */
  70291. scene: Scene;
  70292. private _engine;
  70293. /**
  70294. * Creates a new instance of the component for the given scene
  70295. * @param scene Defines the scene to register the component in
  70296. */
  70297. constructor(scene: Scene);
  70298. /**
  70299. * Registers the component in a given scene
  70300. */
  70301. register(): void;
  70302. /**
  70303. * Rebuilds the elements related to this component in case of
  70304. * context lost for instance.
  70305. */
  70306. rebuild(): void;
  70307. /**
  70308. * Disposes the component and the associated ressources.
  70309. */
  70310. dispose(): void;
  70311. private _draw;
  70312. private _drawCameraPredicate;
  70313. private _drawCameraBackground;
  70314. private _drawCameraForeground;
  70315. private _drawRenderTargetPredicate;
  70316. private _drawRenderTargetBackground;
  70317. private _drawRenderTargetForeground;
  70318. }
  70319. }
  70320. declare module BABYLON {
  70321. /** @hidden */
  70322. export var layerPixelShader: {
  70323. name: string;
  70324. shader: string;
  70325. };
  70326. }
  70327. declare module BABYLON {
  70328. /** @hidden */
  70329. export var layerVertexShader: {
  70330. name: string;
  70331. shader: string;
  70332. };
  70333. }
  70334. declare module BABYLON {
  70335. /**
  70336. * This represents a full screen 2d layer.
  70337. * This can be useful to display a picture in the background of your scene for instance.
  70338. * @see https://www.babylonjs-playground.com/#08A2BS#1
  70339. */
  70340. export class Layer {
  70341. /**
  70342. * Define the name of the layer.
  70343. */
  70344. name: string;
  70345. /**
  70346. * Define the texture the layer should display.
  70347. */
  70348. texture: Nullable<Texture>;
  70349. /**
  70350. * Is the layer in background or foreground.
  70351. */
  70352. isBackground: boolean;
  70353. /**
  70354. * Define the color of the layer (instead of texture).
  70355. */
  70356. color: Color4;
  70357. /**
  70358. * Define the scale of the layer in order to zoom in out of the texture.
  70359. */
  70360. scale: Vector2;
  70361. /**
  70362. * Define an offset for the layer in order to shift the texture.
  70363. */
  70364. offset: Vector2;
  70365. /**
  70366. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  70367. */
  70368. alphaBlendingMode: number;
  70369. /**
  70370. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  70371. * Alpha test will not mix with the background color in case of transparency.
  70372. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  70373. */
  70374. alphaTest: boolean;
  70375. /**
  70376. * Define a mask to restrict the layer to only some of the scene cameras.
  70377. */
  70378. layerMask: number;
  70379. /**
  70380. * Define the list of render target the layer is visible into.
  70381. */
  70382. renderTargetTextures: RenderTargetTexture[];
  70383. /**
  70384. * Define if the layer is only used in renderTarget or if it also
  70385. * renders in the main frame buffer of the canvas.
  70386. */
  70387. renderOnlyInRenderTargetTextures: boolean;
  70388. private _scene;
  70389. private _vertexBuffers;
  70390. private _indexBuffer;
  70391. private _effect;
  70392. private _alphaTestEffect;
  70393. /**
  70394. * An event triggered when the layer is disposed.
  70395. */
  70396. onDisposeObservable: Observable<Layer>;
  70397. private _onDisposeObserver;
  70398. /**
  70399. * Back compatibility with callback before the onDisposeObservable existed.
  70400. * The set callback will be triggered when the layer has been disposed.
  70401. */
  70402. onDispose: () => void;
  70403. /**
  70404. * An event triggered before rendering the scene
  70405. */
  70406. onBeforeRenderObservable: Observable<Layer>;
  70407. private _onBeforeRenderObserver;
  70408. /**
  70409. * Back compatibility with callback before the onBeforeRenderObservable existed.
  70410. * The set callback will be triggered just before rendering the layer.
  70411. */
  70412. onBeforeRender: () => void;
  70413. /**
  70414. * An event triggered after rendering the scene
  70415. */
  70416. onAfterRenderObservable: Observable<Layer>;
  70417. private _onAfterRenderObserver;
  70418. /**
  70419. * Back compatibility with callback before the onAfterRenderObservable existed.
  70420. * The set callback will be triggered just after rendering the layer.
  70421. */
  70422. onAfterRender: () => void;
  70423. /**
  70424. * Instantiates a new layer.
  70425. * This represents a full screen 2d layer.
  70426. * This can be useful to display a picture in the background of your scene for instance.
  70427. * @see https://www.babylonjs-playground.com/#08A2BS#1
  70428. * @param name Define the name of the layer in the scene
  70429. * @param imgUrl Define the url of the texture to display in the layer
  70430. * @param scene Define the scene the layer belongs to
  70431. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  70432. * @param color Defines a color for the layer
  70433. */
  70434. constructor(
  70435. /**
  70436. * Define the name of the layer.
  70437. */
  70438. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  70439. private _createIndexBuffer;
  70440. /** @hidden */
  70441. _rebuild(): void;
  70442. /**
  70443. * Renders the layer in the scene.
  70444. */
  70445. render(): void;
  70446. /**
  70447. * Disposes and releases the associated ressources.
  70448. */
  70449. dispose(): void;
  70450. }
  70451. }
  70452. declare module BABYLON {
  70453. interface AbstractScene {
  70454. /**
  70455. * The list of procedural textures added to the scene
  70456. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  70457. */
  70458. proceduralTextures: Array<ProceduralTexture>;
  70459. }
  70460. /**
  70461. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  70462. * in a given scene.
  70463. */
  70464. export class ProceduralTextureSceneComponent implements ISceneComponent {
  70465. /**
  70466. * The component name helpfull to identify the component in the list of scene components.
  70467. */
  70468. readonly name: string;
  70469. /**
  70470. * The scene the component belongs to.
  70471. */
  70472. scene: Scene;
  70473. /**
  70474. * Creates a new instance of the component for the given scene
  70475. * @param scene Defines the scene to register the component in
  70476. */
  70477. constructor(scene: Scene);
  70478. /**
  70479. * Registers the component in a given scene
  70480. */
  70481. register(): void;
  70482. /**
  70483. * Rebuilds the elements related to this component in case of
  70484. * context lost for instance.
  70485. */
  70486. rebuild(): void;
  70487. /**
  70488. * Disposes the component and the associated ressources.
  70489. */
  70490. dispose(): void;
  70491. private _beforeClear;
  70492. }
  70493. }
  70494. declare module BABYLON {
  70495. /** @hidden */
  70496. export var proceduralVertexShader: {
  70497. name: string;
  70498. shader: string;
  70499. };
  70500. }
  70501. declare module BABYLON {
  70502. /**
  70503. * 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.
  70504. * This is the base class of any Procedural texture and contains most of the shareable code.
  70505. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  70506. */
  70507. export class ProceduralTexture extends Texture {
  70508. isCube: boolean;
  70509. /**
  70510. * Define if the texture is enabled or not (disabled texture will not render)
  70511. */
  70512. isEnabled: boolean;
  70513. /**
  70514. * Define if the texture must be cleared before rendering (default is true)
  70515. */
  70516. autoClear: boolean;
  70517. /**
  70518. * Callback called when the texture is generated
  70519. */
  70520. onGenerated: () => void;
  70521. /**
  70522. * Event raised when the texture is generated
  70523. */
  70524. onGeneratedObservable: Observable<ProceduralTexture>;
  70525. /** @hidden */
  70526. _generateMipMaps: boolean;
  70527. /** @hidden **/
  70528. _effect: Effect;
  70529. /** @hidden */
  70530. _textures: {
  70531. [key: string]: Texture;
  70532. };
  70533. private _size;
  70534. private _currentRefreshId;
  70535. private _refreshRate;
  70536. private _vertexBuffers;
  70537. private _indexBuffer;
  70538. private _uniforms;
  70539. private _samplers;
  70540. private _fragment;
  70541. private _floats;
  70542. private _ints;
  70543. private _floatsArrays;
  70544. private _colors3;
  70545. private _colors4;
  70546. private _vectors2;
  70547. private _vectors3;
  70548. private _matrices;
  70549. private _fallbackTexture;
  70550. private _fallbackTextureUsed;
  70551. private _engine;
  70552. private _cachedDefines;
  70553. private _contentUpdateId;
  70554. private _contentData;
  70555. /**
  70556. * Instantiates a new procedural texture.
  70557. * 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.
  70558. * This is the base class of any Procedural texture and contains most of the shareable code.
  70559. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  70560. * @param name Define the name of the texture
  70561. * @param size Define the size of the texture to create
  70562. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  70563. * @param scene Define the scene the texture belongs to
  70564. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  70565. * @param generateMipMaps Define if the texture should creates mip maps or not
  70566. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  70567. */
  70568. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  70569. /**
  70570. * The effect that is created when initializing the post process.
  70571. * @returns The created effect corrisponding the the postprocess.
  70572. */
  70573. getEffect(): Effect;
  70574. /**
  70575. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  70576. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  70577. */
  70578. getContent(): Nullable<ArrayBufferView>;
  70579. private _createIndexBuffer;
  70580. /** @hidden */
  70581. _rebuild(): void;
  70582. /**
  70583. * Resets the texture in order to recreate its associated resources.
  70584. * This can be called in case of context loss
  70585. */
  70586. reset(): void;
  70587. protected _getDefines(): string;
  70588. /**
  70589. * Is the texture ready to be used ? (rendered at least once)
  70590. * @returns true if ready, otherwise, false.
  70591. */
  70592. isReady(): boolean;
  70593. /**
  70594. * Resets the refresh counter of the texture and start bak from scratch.
  70595. * Could be useful to regenerate the texture if it is setup to render only once.
  70596. */
  70597. resetRefreshCounter(): void;
  70598. /**
  70599. * Set the fragment shader to use in order to render the texture.
  70600. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  70601. */
  70602. setFragment(fragment: any): void;
  70603. /**
  70604. * Define the refresh rate of the texture or the rendering frequency.
  70605. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  70606. */
  70607. refreshRate: number;
  70608. /** @hidden */
  70609. _shouldRender(): boolean;
  70610. /**
  70611. * Get the size the texture is rendering at.
  70612. * @returns the size (texture is always squared)
  70613. */
  70614. getRenderSize(): number;
  70615. /**
  70616. * Resize the texture to new value.
  70617. * @param size Define the new size the texture should have
  70618. * @param generateMipMaps Define whether the new texture should create mip maps
  70619. */
  70620. resize(size: number, generateMipMaps: boolean): void;
  70621. private _checkUniform;
  70622. /**
  70623. * Set a texture in the shader program used to render.
  70624. * @param name Define the name of the uniform samplers as defined in the shader
  70625. * @param texture Define the texture to bind to this sampler
  70626. * @return the texture itself allowing "fluent" like uniform updates
  70627. */
  70628. setTexture(name: string, texture: Texture): ProceduralTexture;
  70629. /**
  70630. * Set a float in the shader.
  70631. * @param name Define the name of the uniform as defined in the shader
  70632. * @param value Define the value to give to the uniform
  70633. * @return the texture itself allowing "fluent" like uniform updates
  70634. */
  70635. setFloat(name: string, value: number): ProceduralTexture;
  70636. /**
  70637. * Set a int in the shader.
  70638. * @param name Define the name of the uniform as defined in the shader
  70639. * @param value Define the value to give to the uniform
  70640. * @return the texture itself allowing "fluent" like uniform updates
  70641. */
  70642. setInt(name: string, value: number): ProceduralTexture;
  70643. /**
  70644. * Set an array of floats in the shader.
  70645. * @param name Define the name of the uniform as defined in the shader
  70646. * @param value Define the value to give to the uniform
  70647. * @return the texture itself allowing "fluent" like uniform updates
  70648. */
  70649. setFloats(name: string, value: number[]): ProceduralTexture;
  70650. /**
  70651. * Set a vec3 in the shader from a Color3.
  70652. * @param name Define the name of the uniform as defined in the shader
  70653. * @param value Define the value to give to the uniform
  70654. * @return the texture itself allowing "fluent" like uniform updates
  70655. */
  70656. setColor3(name: string, value: Color3): ProceduralTexture;
  70657. /**
  70658. * Set a vec4 in the shader from a Color4.
  70659. * @param name Define the name of the uniform as defined in the shader
  70660. * @param value Define the value to give to the uniform
  70661. * @return the texture itself allowing "fluent" like uniform updates
  70662. */
  70663. setColor4(name: string, value: Color4): ProceduralTexture;
  70664. /**
  70665. * Set a vec2 in the shader from a Vector2.
  70666. * @param name Define the name of the uniform as defined in the shader
  70667. * @param value Define the value to give to the uniform
  70668. * @return the texture itself allowing "fluent" like uniform updates
  70669. */
  70670. setVector2(name: string, value: Vector2): ProceduralTexture;
  70671. /**
  70672. * Set a vec3 in the shader from a Vector3.
  70673. * @param name Define the name of the uniform as defined in the shader
  70674. * @param value Define the value to give to the uniform
  70675. * @return the texture itself allowing "fluent" like uniform updates
  70676. */
  70677. setVector3(name: string, value: Vector3): ProceduralTexture;
  70678. /**
  70679. * Set a mat4 in the shader from a MAtrix.
  70680. * @param name Define the name of the uniform as defined in the shader
  70681. * @param value Define the value to give to the uniform
  70682. * @return the texture itself allowing "fluent" like uniform updates
  70683. */
  70684. setMatrix(name: string, value: Matrix): ProceduralTexture;
  70685. /**
  70686. * Render the texture to its associated render target.
  70687. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  70688. */
  70689. render(useCameraPostProcess?: boolean): void;
  70690. /**
  70691. * Clone the texture.
  70692. * @returns the cloned texture
  70693. */
  70694. clone(): ProceduralTexture;
  70695. /**
  70696. * Dispose the texture and release its asoociated resources.
  70697. */
  70698. dispose(): void;
  70699. }
  70700. }
  70701. declare module BABYLON {
  70702. /**
  70703. * This represents the base class for particle system in Babylon.
  70704. * 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.
  70705. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  70706. * @example https://doc.babylonjs.com/babylon101/particles
  70707. */
  70708. export class BaseParticleSystem {
  70709. /**
  70710. * Source color is added to the destination color without alpha affecting the result
  70711. */
  70712. static BLENDMODE_ONEONE: number;
  70713. /**
  70714. * Blend current color and particle color using particle’s alpha
  70715. */
  70716. static BLENDMODE_STANDARD: number;
  70717. /**
  70718. * Add current color and particle color multiplied by particle’s alpha
  70719. */
  70720. static BLENDMODE_ADD: number;
  70721. /**
  70722. * Multiply current color with particle color
  70723. */
  70724. static BLENDMODE_MULTIPLY: number;
  70725. /**
  70726. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  70727. */
  70728. static BLENDMODE_MULTIPLYADD: number;
  70729. /**
  70730. * List of animations used by the particle system.
  70731. */
  70732. animations: Animation[];
  70733. /**
  70734. * The id of the Particle system.
  70735. */
  70736. id: string;
  70737. /**
  70738. * The friendly name of the Particle system.
  70739. */
  70740. name: string;
  70741. /**
  70742. * The rendering group used by the Particle system to chose when to render.
  70743. */
  70744. renderingGroupId: number;
  70745. /**
  70746. * The emitter represents the Mesh or position we are attaching the particle system to.
  70747. */
  70748. emitter: Nullable<AbstractMesh | Vector3>;
  70749. /**
  70750. * The maximum number of particles to emit per frame
  70751. */
  70752. emitRate: number;
  70753. /**
  70754. * If you want to launch only a few particles at once, that can be done, as well.
  70755. */
  70756. manualEmitCount: number;
  70757. /**
  70758. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  70759. */
  70760. updateSpeed: number;
  70761. /**
  70762. * The amount of time the particle system is running (depends of the overall update speed).
  70763. */
  70764. targetStopDuration: number;
  70765. /**
  70766. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  70767. */
  70768. disposeOnStop: boolean;
  70769. /**
  70770. * Minimum power of emitting particles.
  70771. */
  70772. minEmitPower: number;
  70773. /**
  70774. * Maximum power of emitting particles.
  70775. */
  70776. maxEmitPower: number;
  70777. /**
  70778. * Minimum life time of emitting particles.
  70779. */
  70780. minLifeTime: number;
  70781. /**
  70782. * Maximum life time of emitting particles.
  70783. */
  70784. maxLifeTime: number;
  70785. /**
  70786. * Minimum Size of emitting particles.
  70787. */
  70788. minSize: number;
  70789. /**
  70790. * Maximum Size of emitting particles.
  70791. */
  70792. maxSize: number;
  70793. /**
  70794. * Minimum scale of emitting particles on X axis.
  70795. */
  70796. minScaleX: number;
  70797. /**
  70798. * Maximum scale of emitting particles on X axis.
  70799. */
  70800. maxScaleX: number;
  70801. /**
  70802. * Minimum scale of emitting particles on Y axis.
  70803. */
  70804. minScaleY: number;
  70805. /**
  70806. * Maximum scale of emitting particles on Y axis.
  70807. */
  70808. maxScaleY: number;
  70809. /**
  70810. * Gets or sets the minimal initial rotation in radians.
  70811. */
  70812. minInitialRotation: number;
  70813. /**
  70814. * Gets or sets the maximal initial rotation in radians.
  70815. */
  70816. maxInitialRotation: number;
  70817. /**
  70818. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  70819. */
  70820. minAngularSpeed: number;
  70821. /**
  70822. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  70823. */
  70824. maxAngularSpeed: number;
  70825. /**
  70826. * The texture used to render each particle. (this can be a spritesheet)
  70827. */
  70828. particleTexture: Nullable<Texture>;
  70829. /**
  70830. * The layer mask we are rendering the particles through.
  70831. */
  70832. layerMask: number;
  70833. /**
  70834. * This can help using your own shader to render the particle system.
  70835. * The according effect will be created
  70836. */
  70837. customShader: any;
  70838. /**
  70839. * By default particle system starts as soon as they are created. This prevents the
  70840. * automatic start to happen and let you decide when to start emitting particles.
  70841. */
  70842. preventAutoStart: boolean;
  70843. private _noiseTexture;
  70844. /**
  70845. * Gets or sets a texture used to add random noise to particle positions
  70846. */
  70847. noiseTexture: Nullable<ProceduralTexture>;
  70848. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  70849. noiseStrength: Vector3;
  70850. /**
  70851. * Callback triggered when the particle animation is ending.
  70852. */
  70853. onAnimationEnd: Nullable<() => void>;
  70854. /**
  70855. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  70856. */
  70857. blendMode: number;
  70858. /**
  70859. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  70860. * to override the particles.
  70861. */
  70862. forceDepthWrite: boolean;
  70863. /** 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 */
  70864. preWarmCycles: number;
  70865. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  70866. preWarmStepOffset: number;
  70867. /**
  70868. * 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)
  70869. */
  70870. spriteCellChangeSpeed: number;
  70871. /**
  70872. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  70873. */
  70874. startSpriteCellID: number;
  70875. /**
  70876. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  70877. */
  70878. endSpriteCellID: number;
  70879. /**
  70880. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  70881. */
  70882. spriteCellWidth: number;
  70883. /**
  70884. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  70885. */
  70886. spriteCellHeight: number;
  70887. /**
  70888. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  70889. */
  70890. spriteRandomStartCell: boolean;
  70891. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  70892. translationPivot: Vector2;
  70893. /** @hidden */
  70894. protected _isAnimationSheetEnabled: boolean;
  70895. /**
  70896. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  70897. */
  70898. beginAnimationOnStart: boolean;
  70899. /**
  70900. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  70901. */
  70902. beginAnimationFrom: number;
  70903. /**
  70904. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  70905. */
  70906. beginAnimationTo: number;
  70907. /**
  70908. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  70909. */
  70910. beginAnimationLoop: boolean;
  70911. /**
  70912. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  70913. */
  70914. isAnimationSheetEnabled: boolean;
  70915. /**
  70916. * Get hosting scene
  70917. * @returns the scene
  70918. */
  70919. getScene(): Scene;
  70920. /**
  70921. * You can use gravity if you want to give an orientation to your particles.
  70922. */
  70923. gravity: Vector3;
  70924. protected _colorGradients: Nullable<Array<ColorGradient>>;
  70925. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  70926. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  70927. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  70928. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  70929. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  70930. protected _dragGradients: Nullable<Array<FactorGradient>>;
  70931. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  70932. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  70933. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  70934. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  70935. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  70936. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  70937. /**
  70938. * Defines the delay in milliseconds before starting the system (0 by default)
  70939. */
  70940. startDelay: number;
  70941. /**
  70942. * Gets the current list of drag gradients.
  70943. * You must use addDragGradient and removeDragGradient to udpate this list
  70944. * @returns the list of drag gradients
  70945. */
  70946. getDragGradients(): Nullable<Array<FactorGradient>>;
  70947. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  70948. limitVelocityDamping: number;
  70949. /**
  70950. * Gets the current list of limit velocity gradients.
  70951. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  70952. * @returns the list of limit velocity gradients
  70953. */
  70954. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  70955. /**
  70956. * Gets the current list of color gradients.
  70957. * You must use addColorGradient and removeColorGradient to udpate this list
  70958. * @returns the list of color gradients
  70959. */
  70960. getColorGradients(): Nullable<Array<ColorGradient>>;
  70961. /**
  70962. * Gets the current list of size gradients.
  70963. * You must use addSizeGradient and removeSizeGradient to udpate this list
  70964. * @returns the list of size gradients
  70965. */
  70966. getSizeGradients(): Nullable<Array<FactorGradient>>;
  70967. /**
  70968. * Gets the current list of color remap gradients.
  70969. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  70970. * @returns the list of color remap gradients
  70971. */
  70972. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  70973. /**
  70974. * Gets the current list of alpha remap gradients.
  70975. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  70976. * @returns the list of alpha remap gradients
  70977. */
  70978. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  70979. /**
  70980. * Gets the current list of life time gradients.
  70981. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  70982. * @returns the list of life time gradients
  70983. */
  70984. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  70985. /**
  70986. * Gets the current list of angular speed gradients.
  70987. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  70988. * @returns the list of angular speed gradients
  70989. */
  70990. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  70991. /**
  70992. * Gets the current list of velocity gradients.
  70993. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  70994. * @returns the list of velocity gradients
  70995. */
  70996. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  70997. /**
  70998. * Gets the current list of start size gradients.
  70999. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  71000. * @returns the list of start size gradients
  71001. */
  71002. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  71003. /**
  71004. * Gets the current list of emit rate gradients.
  71005. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  71006. * @returns the list of emit rate gradients
  71007. */
  71008. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  71009. /**
  71010. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  71011. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71012. */
  71013. direction1: Vector3;
  71014. /**
  71015. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  71016. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71017. */
  71018. direction2: Vector3;
  71019. /**
  71020. * 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.
  71021. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71022. */
  71023. minEmitBox: Vector3;
  71024. /**
  71025. * 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.
  71026. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71027. */
  71028. maxEmitBox: Vector3;
  71029. /**
  71030. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  71031. */
  71032. color1: Color4;
  71033. /**
  71034. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  71035. */
  71036. color2: Color4;
  71037. /**
  71038. * Color the particle will have at the end of its lifetime
  71039. */
  71040. colorDead: Color4;
  71041. /**
  71042. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  71043. */
  71044. textureMask: Color4;
  71045. /**
  71046. * The particle emitter type defines the emitter used by the particle system.
  71047. * It can be for example box, sphere, or cone...
  71048. */
  71049. particleEmitterType: IParticleEmitterType;
  71050. /** @hidden */
  71051. _isSubEmitter: boolean;
  71052. /**
  71053. * Gets or sets the billboard mode to use when isBillboardBased = true.
  71054. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  71055. */
  71056. billboardMode: number;
  71057. protected _isBillboardBased: boolean;
  71058. /**
  71059. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  71060. */
  71061. isBillboardBased: boolean;
  71062. /**
  71063. * The scene the particle system belongs to.
  71064. */
  71065. protected _scene: Scene;
  71066. /**
  71067. * Local cache of defines for image processing.
  71068. */
  71069. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  71070. /**
  71071. * Default configuration related to image processing available in the standard Material.
  71072. */
  71073. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  71074. /**
  71075. * Gets the image processing configuration used either in this material.
  71076. */
  71077. /**
  71078. * Sets the Default image processing configuration used either in the this material.
  71079. *
  71080. * If sets to null, the scene one is in use.
  71081. */
  71082. imageProcessingConfiguration: ImageProcessingConfiguration;
  71083. /**
  71084. * Attaches a new image processing configuration to the Standard Material.
  71085. * @param configuration
  71086. */
  71087. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  71088. /** @hidden */
  71089. protected _reset(): void;
  71090. /** @hidden */
  71091. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  71092. /**
  71093. * Instantiates a particle system.
  71094. * 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.
  71095. * @param name The name of the particle system
  71096. */
  71097. constructor(name: string);
  71098. /**
  71099. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  71100. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  71101. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  71102. * @returns the emitter
  71103. */
  71104. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  71105. /**
  71106. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  71107. * @param radius The radius of the hemisphere to emit from
  71108. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  71109. * @returns the emitter
  71110. */
  71111. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  71112. /**
  71113. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  71114. * @param radius The radius of the sphere to emit from
  71115. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  71116. * @returns the emitter
  71117. */
  71118. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  71119. /**
  71120. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  71121. * @param radius The radius of the sphere to emit from
  71122. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  71123. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  71124. * @returns the emitter
  71125. */
  71126. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  71127. /**
  71128. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  71129. * @param radius The radius of the emission cylinder
  71130. * @param height The height of the emission cylinder
  71131. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  71132. * @param directionRandomizer How much to randomize the particle direction [0-1]
  71133. * @returns the emitter
  71134. */
  71135. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  71136. /**
  71137. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  71138. * @param radius The radius of the cylinder to emit from
  71139. * @param height The height of the emission cylinder
  71140. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  71141. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  71142. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  71143. * @returns the emitter
  71144. */
  71145. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  71146. /**
  71147. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  71148. * @param radius The radius of the cone to emit from
  71149. * @param angle The base angle of the cone
  71150. * @returns the emitter
  71151. */
  71152. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  71153. /**
  71154. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  71155. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  71156. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  71157. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  71158. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  71159. * @returns the emitter
  71160. */
  71161. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  71162. }
  71163. }
  71164. declare module BABYLON {
  71165. /**
  71166. * Type of sub emitter
  71167. */
  71168. export enum SubEmitterType {
  71169. /**
  71170. * Attached to the particle over it's lifetime
  71171. */
  71172. ATTACHED = 0,
  71173. /**
  71174. * Created when the particle dies
  71175. */
  71176. END = 1
  71177. }
  71178. /**
  71179. * Sub emitter class used to emit particles from an existing particle
  71180. */
  71181. export class SubEmitter {
  71182. /**
  71183. * the particle system to be used by the sub emitter
  71184. */
  71185. particleSystem: ParticleSystem;
  71186. /**
  71187. * Type of the submitter (Default: END)
  71188. */
  71189. type: SubEmitterType;
  71190. /**
  71191. * 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)
  71192. * Note: This only is supported when using an emitter of type Mesh
  71193. */
  71194. inheritDirection: boolean;
  71195. /**
  71196. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  71197. */
  71198. inheritedVelocityAmount: number;
  71199. /**
  71200. * Creates a sub emitter
  71201. * @param particleSystem the particle system to be used by the sub emitter
  71202. */
  71203. constructor(
  71204. /**
  71205. * the particle system to be used by the sub emitter
  71206. */
  71207. particleSystem: ParticleSystem);
  71208. /**
  71209. * Clones the sub emitter
  71210. * @returns the cloned sub emitter
  71211. */
  71212. clone(): SubEmitter;
  71213. /**
  71214. * Serialize current object to a JSON object
  71215. * @returns the serialized object
  71216. */
  71217. serialize(): any;
  71218. /** @hidden */
  71219. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  71220. /**
  71221. * Creates a new SubEmitter from a serialized JSON version
  71222. * @param serializationObject defines the JSON object to read from
  71223. * @param scene defines the hosting scene
  71224. * @param rootUrl defines the rootUrl for data loading
  71225. * @returns a new SubEmitter
  71226. */
  71227. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  71228. /** Release associated resources */
  71229. dispose(): void;
  71230. }
  71231. }
  71232. declare module BABYLON {
  71233. /** @hidden */
  71234. export var clipPlaneFragmentDeclaration: {
  71235. name: string;
  71236. shader: string;
  71237. };
  71238. }
  71239. declare module BABYLON {
  71240. /** @hidden */
  71241. export var imageProcessingDeclaration: {
  71242. name: string;
  71243. shader: string;
  71244. };
  71245. }
  71246. declare module BABYLON {
  71247. /** @hidden */
  71248. export var imageProcessingFunctions: {
  71249. name: string;
  71250. shader: string;
  71251. };
  71252. }
  71253. declare module BABYLON {
  71254. /** @hidden */
  71255. export var clipPlaneFragment: {
  71256. name: string;
  71257. shader: string;
  71258. };
  71259. }
  71260. declare module BABYLON {
  71261. /** @hidden */
  71262. export var particlesPixelShader: {
  71263. name: string;
  71264. shader: string;
  71265. };
  71266. }
  71267. declare module BABYLON {
  71268. /** @hidden */
  71269. export var clipPlaneVertexDeclaration: {
  71270. name: string;
  71271. shader: string;
  71272. };
  71273. }
  71274. declare module BABYLON {
  71275. /** @hidden */
  71276. export var clipPlaneVertex: {
  71277. name: string;
  71278. shader: string;
  71279. };
  71280. }
  71281. declare module BABYLON {
  71282. /** @hidden */
  71283. export var particlesVertexShader: {
  71284. name: string;
  71285. shader: string;
  71286. };
  71287. }
  71288. declare module BABYLON {
  71289. /**
  71290. * This represents a particle system in Babylon.
  71291. * 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.
  71292. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  71293. * @example https://doc.babylonjs.com/babylon101/particles
  71294. */
  71295. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  71296. /**
  71297. * Billboard mode will only apply to Y axis
  71298. */
  71299. static readonly BILLBOARDMODE_Y: number;
  71300. /**
  71301. * Billboard mode will apply to all axes
  71302. */
  71303. static readonly BILLBOARDMODE_ALL: number;
  71304. /**
  71305. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  71306. */
  71307. static readonly BILLBOARDMODE_STRETCHED: number;
  71308. /**
  71309. * This function can be defined to provide custom update for active particles.
  71310. * This function will be called instead of regular update (age, position, color, etc.).
  71311. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  71312. */
  71313. updateFunction: (particles: Particle[]) => void;
  71314. private _emitterWorldMatrix;
  71315. /**
  71316. * This function can be defined to specify initial direction for every new particle.
  71317. * It by default use the emitterType defined function
  71318. */
  71319. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  71320. /**
  71321. * This function can be defined to specify initial position for every new particle.
  71322. * It by default use the emitterType defined function
  71323. */
  71324. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  71325. /**
  71326. * @hidden
  71327. */
  71328. _inheritedVelocityOffset: Vector3;
  71329. /**
  71330. * An event triggered when the system is disposed
  71331. */
  71332. onDisposeObservable: Observable<ParticleSystem>;
  71333. private _onDisposeObserver;
  71334. /**
  71335. * Sets a callback that will be triggered when the system is disposed
  71336. */
  71337. onDispose: () => void;
  71338. private _particles;
  71339. private _epsilon;
  71340. private _capacity;
  71341. private _stockParticles;
  71342. private _newPartsExcess;
  71343. private _vertexData;
  71344. private _vertexBuffer;
  71345. private _vertexBuffers;
  71346. private _spriteBuffer;
  71347. private _indexBuffer;
  71348. private _effect;
  71349. private _customEffect;
  71350. private _cachedDefines;
  71351. private _scaledColorStep;
  71352. private _colorDiff;
  71353. private _scaledDirection;
  71354. private _scaledGravity;
  71355. private _currentRenderId;
  71356. private _alive;
  71357. private _useInstancing;
  71358. private _started;
  71359. private _stopped;
  71360. private _actualFrame;
  71361. private _scaledUpdateSpeed;
  71362. private _vertexBufferSize;
  71363. /** @hidden */
  71364. _currentEmitRateGradient: Nullable<FactorGradient>;
  71365. /** @hidden */
  71366. _currentEmitRate1: number;
  71367. /** @hidden */
  71368. _currentEmitRate2: number;
  71369. /** @hidden */
  71370. _currentStartSizeGradient: Nullable<FactorGradient>;
  71371. /** @hidden */
  71372. _currentStartSize1: number;
  71373. /** @hidden */
  71374. _currentStartSize2: number;
  71375. private readonly _rawTextureWidth;
  71376. private _rampGradientsTexture;
  71377. private _useRampGradients;
  71378. /** Gets or sets a boolean indicating that ramp gradients must be used
  71379. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  71380. */
  71381. useRampGradients: boolean;
  71382. /**
  71383. * 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.
  71384. * 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: [])
  71385. */
  71386. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  71387. private _subEmitters;
  71388. /**
  71389. * @hidden
  71390. * If the particle systems emitter should be disposed when the particle system is disposed
  71391. */
  71392. _disposeEmitterOnDispose: boolean;
  71393. /**
  71394. * The current active Sub-systems, this property is used by the root particle system only.
  71395. */
  71396. activeSubSystems: Array<ParticleSystem>;
  71397. private _rootParticleSystem;
  71398. /**
  71399. * Gets the current list of active particles
  71400. */
  71401. readonly particles: Particle[];
  71402. /**
  71403. * Returns the string "ParticleSystem"
  71404. * @returns a string containing the class name
  71405. */
  71406. getClassName(): string;
  71407. /**
  71408. * Instantiates a particle system.
  71409. * 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.
  71410. * @param name The name of the particle system
  71411. * @param capacity The max number of particles alive at the same time
  71412. * @param scene The scene the particle system belongs to
  71413. * @param customEffect a custom effect used to change the way particles are rendered by default
  71414. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  71415. * @param epsilon Offset used to render the particles
  71416. */
  71417. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  71418. private _addFactorGradient;
  71419. private _removeFactorGradient;
  71420. /**
  71421. * Adds a new life time gradient
  71422. * @param gradient defines the gradient to use (between 0 and 1)
  71423. * @param factor defines the life time factor to affect to the specified gradient
  71424. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71425. * @returns the current particle system
  71426. */
  71427. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71428. /**
  71429. * Remove a specific life time gradient
  71430. * @param gradient defines the gradient to remove
  71431. * @returns the current particle system
  71432. */
  71433. removeLifeTimeGradient(gradient: number): IParticleSystem;
  71434. /**
  71435. * Adds a new size gradient
  71436. * @param gradient defines the gradient to use (between 0 and 1)
  71437. * @param factor defines the size factor to affect to the specified gradient
  71438. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71439. * @returns the current particle system
  71440. */
  71441. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71442. /**
  71443. * Remove a specific size gradient
  71444. * @param gradient defines the gradient to remove
  71445. * @returns the current particle system
  71446. */
  71447. removeSizeGradient(gradient: number): IParticleSystem;
  71448. /**
  71449. * Adds a new color remap gradient
  71450. * @param gradient defines the gradient to use (between 0 and 1)
  71451. * @param min defines the color remap minimal range
  71452. * @param max defines the color remap maximal range
  71453. * @returns the current particle system
  71454. */
  71455. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71456. /**
  71457. * Remove a specific color remap gradient
  71458. * @param gradient defines the gradient to remove
  71459. * @returns the current particle system
  71460. */
  71461. removeColorRemapGradient(gradient: number): IParticleSystem;
  71462. /**
  71463. * Adds a new alpha remap gradient
  71464. * @param gradient defines the gradient to use (between 0 and 1)
  71465. * @param min defines the alpha remap minimal range
  71466. * @param max defines the alpha remap maximal range
  71467. * @returns the current particle system
  71468. */
  71469. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71470. /**
  71471. * Remove a specific alpha remap gradient
  71472. * @param gradient defines the gradient to remove
  71473. * @returns the current particle system
  71474. */
  71475. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  71476. /**
  71477. * Adds a new angular speed gradient
  71478. * @param gradient defines the gradient to use (between 0 and 1)
  71479. * @param factor defines the angular speed to affect to the specified gradient
  71480. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71481. * @returns the current particle system
  71482. */
  71483. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71484. /**
  71485. * Remove a specific angular speed gradient
  71486. * @param gradient defines the gradient to remove
  71487. * @returns the current particle system
  71488. */
  71489. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  71490. /**
  71491. * Adds a new velocity gradient
  71492. * @param gradient defines the gradient to use (between 0 and 1)
  71493. * @param factor defines the velocity to affect to the specified gradient
  71494. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71495. * @returns the current particle system
  71496. */
  71497. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71498. /**
  71499. * Remove a specific velocity gradient
  71500. * @param gradient defines the gradient to remove
  71501. * @returns the current particle system
  71502. */
  71503. removeVelocityGradient(gradient: number): IParticleSystem;
  71504. /**
  71505. * Adds a new limit velocity gradient
  71506. * @param gradient defines the gradient to use (between 0 and 1)
  71507. * @param factor defines the limit velocity value to affect to the specified gradient
  71508. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71509. * @returns the current particle system
  71510. */
  71511. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71512. /**
  71513. * Remove a specific limit velocity gradient
  71514. * @param gradient defines the gradient to remove
  71515. * @returns the current particle system
  71516. */
  71517. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  71518. /**
  71519. * Adds a new drag gradient
  71520. * @param gradient defines the gradient to use (between 0 and 1)
  71521. * @param factor defines the drag value to affect to the specified gradient
  71522. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71523. * @returns the current particle system
  71524. */
  71525. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71526. /**
  71527. * Remove a specific drag gradient
  71528. * @param gradient defines the gradient to remove
  71529. * @returns the current particle system
  71530. */
  71531. removeDragGradient(gradient: number): IParticleSystem;
  71532. /**
  71533. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  71534. * @param gradient defines the gradient to use (between 0 and 1)
  71535. * @param factor defines the emit rate value to affect to the specified gradient
  71536. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71537. * @returns the current particle system
  71538. */
  71539. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71540. /**
  71541. * Remove a specific emit rate gradient
  71542. * @param gradient defines the gradient to remove
  71543. * @returns the current particle system
  71544. */
  71545. removeEmitRateGradient(gradient: number): IParticleSystem;
  71546. /**
  71547. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  71548. * @param gradient defines the gradient to use (between 0 and 1)
  71549. * @param factor defines the start size value to affect to the specified gradient
  71550. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71551. * @returns the current particle system
  71552. */
  71553. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71554. /**
  71555. * Remove a specific start size gradient
  71556. * @param gradient defines the gradient to remove
  71557. * @returns the current particle system
  71558. */
  71559. removeStartSizeGradient(gradient: number): IParticleSystem;
  71560. private _createRampGradientTexture;
  71561. /**
  71562. * Gets the current list of ramp gradients.
  71563. * You must use addRampGradient and removeRampGradient to udpate this list
  71564. * @returns the list of ramp gradients
  71565. */
  71566. getRampGradients(): Nullable<Array<Color3Gradient>>;
  71567. /**
  71568. * Adds a new ramp gradient used to remap particle colors
  71569. * @param gradient defines the gradient to use (between 0 and 1)
  71570. * @param color defines the color to affect to the specified gradient
  71571. * @returns the current particle system
  71572. */
  71573. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  71574. /**
  71575. * Remove a specific ramp gradient
  71576. * @param gradient defines the gradient to remove
  71577. * @returns the current particle system
  71578. */
  71579. removeRampGradient(gradient: number): ParticleSystem;
  71580. /**
  71581. * Adds a new color gradient
  71582. * @param gradient defines the gradient to use (between 0 and 1)
  71583. * @param color1 defines the color to affect to the specified gradient
  71584. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  71585. * @returns this particle system
  71586. */
  71587. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  71588. /**
  71589. * Remove a specific color gradient
  71590. * @param gradient defines the gradient to remove
  71591. * @returns this particle system
  71592. */
  71593. removeColorGradient(gradient: number): IParticleSystem;
  71594. private _fetchR;
  71595. protected _reset(): void;
  71596. private _resetEffect;
  71597. private _createVertexBuffers;
  71598. private _createIndexBuffer;
  71599. /**
  71600. * Gets the maximum number of particles active at the same time.
  71601. * @returns The max number of active particles.
  71602. */
  71603. getCapacity(): number;
  71604. /**
  71605. * Gets whether there are still active particles in the system.
  71606. * @returns True if it is alive, otherwise false.
  71607. */
  71608. isAlive(): boolean;
  71609. /**
  71610. * Gets if the system has been started. (Note: this will still be true after stop is called)
  71611. * @returns True if it has been started, otherwise false.
  71612. */
  71613. isStarted(): boolean;
  71614. private _prepareSubEmitterInternalArray;
  71615. /**
  71616. * Starts the particle system and begins to emit
  71617. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  71618. */
  71619. start(delay?: number): void;
  71620. /**
  71621. * Stops the particle system.
  71622. * @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.
  71623. */
  71624. stop(stopSubEmitters?: boolean): void;
  71625. /**
  71626. * Remove all active particles
  71627. */
  71628. reset(): void;
  71629. /**
  71630. * @hidden (for internal use only)
  71631. */
  71632. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  71633. /**
  71634. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  71635. * Its lifetime will start back at 0.
  71636. */
  71637. recycleParticle: (particle: Particle) => void;
  71638. private _stopSubEmitters;
  71639. private _createParticle;
  71640. private _removeFromRoot;
  71641. private _emitFromParticle;
  71642. private _update;
  71643. /** @hidden */
  71644. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  71645. /** @hidden */
  71646. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  71647. /** @hidden */
  71648. private _getEffect;
  71649. /**
  71650. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  71651. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  71652. */
  71653. animate(preWarmOnly?: boolean): void;
  71654. private _appendParticleVertices;
  71655. /**
  71656. * Rebuilds the particle system.
  71657. */
  71658. rebuild(): void;
  71659. /**
  71660. * Is this system ready to be used/rendered
  71661. * @return true if the system is ready
  71662. */
  71663. isReady(): boolean;
  71664. private _render;
  71665. /**
  71666. * Renders the particle system in its current state.
  71667. * @returns the current number of particles
  71668. */
  71669. render(): number;
  71670. /**
  71671. * Disposes the particle system and free the associated resources
  71672. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  71673. */
  71674. dispose(disposeTexture?: boolean): void;
  71675. /**
  71676. * Clones the particle system.
  71677. * @param name The name of the cloned object
  71678. * @param newEmitter The new emitter to use
  71679. * @returns the cloned particle system
  71680. */
  71681. clone(name: string, newEmitter: any): ParticleSystem;
  71682. /**
  71683. * Serializes the particle system to a JSON object.
  71684. * @returns the JSON object
  71685. */
  71686. serialize(): any;
  71687. /** @hidden */
  71688. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  71689. /** @hidden */
  71690. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  71691. /**
  71692. * Parses a JSON object to create a particle system.
  71693. * @param parsedParticleSystem The JSON object to parse
  71694. * @param scene The scene to create the particle system in
  71695. * @param rootUrl The root url to use to load external dependencies like texture
  71696. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  71697. * @returns the Parsed particle system
  71698. */
  71699. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  71700. }
  71701. }
  71702. declare module BABYLON {
  71703. /**
  71704. * A particle represents one of the element emitted by a particle system.
  71705. * This is mainly define by its coordinates, direction, velocity and age.
  71706. */
  71707. export class Particle {
  71708. /**
  71709. * The particle system the particle belongs to.
  71710. */
  71711. particleSystem: ParticleSystem;
  71712. private static _Count;
  71713. /**
  71714. * Unique ID of the particle
  71715. */
  71716. id: number;
  71717. /**
  71718. * The world position of the particle in the scene.
  71719. */
  71720. position: Vector3;
  71721. /**
  71722. * The world direction of the particle in the scene.
  71723. */
  71724. direction: Vector3;
  71725. /**
  71726. * The color of the particle.
  71727. */
  71728. color: Color4;
  71729. /**
  71730. * The color change of the particle per step.
  71731. */
  71732. colorStep: Color4;
  71733. /**
  71734. * Defines how long will the life of the particle be.
  71735. */
  71736. lifeTime: number;
  71737. /**
  71738. * The current age of the particle.
  71739. */
  71740. age: number;
  71741. /**
  71742. * The current size of the particle.
  71743. */
  71744. size: number;
  71745. /**
  71746. * The current scale of the particle.
  71747. */
  71748. scale: Vector2;
  71749. /**
  71750. * The current angle of the particle.
  71751. */
  71752. angle: number;
  71753. /**
  71754. * Defines how fast is the angle changing.
  71755. */
  71756. angularSpeed: number;
  71757. /**
  71758. * Defines the cell index used by the particle to be rendered from a sprite.
  71759. */
  71760. cellIndex: number;
  71761. /**
  71762. * The information required to support color remapping
  71763. */
  71764. remapData: Vector4;
  71765. /** @hidden */
  71766. _randomCellOffset?: number;
  71767. /** @hidden */
  71768. _initialDirection: Nullable<Vector3>;
  71769. /** @hidden */
  71770. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  71771. /** @hidden */
  71772. _initialStartSpriteCellID: number;
  71773. /** @hidden */
  71774. _initialEndSpriteCellID: number;
  71775. /** @hidden */
  71776. _currentColorGradient: Nullable<ColorGradient>;
  71777. /** @hidden */
  71778. _currentColor1: Color4;
  71779. /** @hidden */
  71780. _currentColor2: Color4;
  71781. /** @hidden */
  71782. _currentSizeGradient: Nullable<FactorGradient>;
  71783. /** @hidden */
  71784. _currentSize1: number;
  71785. /** @hidden */
  71786. _currentSize2: number;
  71787. /** @hidden */
  71788. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  71789. /** @hidden */
  71790. _currentAngularSpeed1: number;
  71791. /** @hidden */
  71792. _currentAngularSpeed2: number;
  71793. /** @hidden */
  71794. _currentVelocityGradient: Nullable<FactorGradient>;
  71795. /** @hidden */
  71796. _currentVelocity1: number;
  71797. /** @hidden */
  71798. _currentVelocity2: number;
  71799. /** @hidden */
  71800. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  71801. /** @hidden */
  71802. _currentLimitVelocity1: number;
  71803. /** @hidden */
  71804. _currentLimitVelocity2: number;
  71805. /** @hidden */
  71806. _currentDragGradient: Nullable<FactorGradient>;
  71807. /** @hidden */
  71808. _currentDrag1: number;
  71809. /** @hidden */
  71810. _currentDrag2: number;
  71811. /** @hidden */
  71812. _randomNoiseCoordinates1: Vector3;
  71813. /** @hidden */
  71814. _randomNoiseCoordinates2: Vector3;
  71815. /**
  71816. * Creates a new instance Particle
  71817. * @param particleSystem the particle system the particle belongs to
  71818. */
  71819. constructor(
  71820. /**
  71821. * The particle system the particle belongs to.
  71822. */
  71823. particleSystem: ParticleSystem);
  71824. private updateCellInfoFromSystem;
  71825. /**
  71826. * Defines how the sprite cell index is updated for the particle
  71827. */
  71828. updateCellIndex(): void;
  71829. /** @hidden */
  71830. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  71831. /** @hidden */
  71832. _inheritParticleInfoToSubEmitters(): void;
  71833. /** @hidden */
  71834. _reset(): void;
  71835. /**
  71836. * Copy the properties of particle to another one.
  71837. * @param other the particle to copy the information to.
  71838. */
  71839. copyTo(other: Particle): void;
  71840. }
  71841. }
  71842. declare module BABYLON {
  71843. /**
  71844. * Particle emitter represents a volume emitting particles.
  71845. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  71846. */
  71847. export interface IParticleEmitterType {
  71848. /**
  71849. * Called by the particle System when the direction is computed for the created particle.
  71850. * @param worldMatrix is the world matrix of the particle system
  71851. * @param directionToUpdate is the direction vector to update with the result
  71852. * @param particle is the particle we are computed the direction for
  71853. */
  71854. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  71855. /**
  71856. * Called by the particle System when the position is computed for the created particle.
  71857. * @param worldMatrix is the world matrix of the particle system
  71858. * @param positionToUpdate is the position vector to update with the result
  71859. * @param particle is the particle we are computed the position for
  71860. */
  71861. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  71862. /**
  71863. * Clones the current emitter and returns a copy of it
  71864. * @returns the new emitter
  71865. */
  71866. clone(): IParticleEmitterType;
  71867. /**
  71868. * Called by the GPUParticleSystem to setup the update shader
  71869. * @param effect defines the update shader
  71870. */
  71871. applyToShader(effect: Effect): void;
  71872. /**
  71873. * Returns a string to use to update the GPU particles update shader
  71874. * @returns the effect defines string
  71875. */
  71876. getEffectDefines(): string;
  71877. /**
  71878. * Returns a string representing the class name
  71879. * @returns a string containing the class name
  71880. */
  71881. getClassName(): string;
  71882. /**
  71883. * Serializes the particle system to a JSON object.
  71884. * @returns the JSON object
  71885. */
  71886. serialize(): any;
  71887. /**
  71888. * Parse properties from a JSON object
  71889. * @param serializationObject defines the JSON object
  71890. */
  71891. parse(serializationObject: any): void;
  71892. }
  71893. }
  71894. declare module BABYLON {
  71895. /**
  71896. * Particle emitter emitting particles from the inside of a box.
  71897. * It emits the particles randomly between 2 given directions.
  71898. */
  71899. export class BoxParticleEmitter implements IParticleEmitterType {
  71900. /**
  71901. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  71902. */
  71903. direction1: Vector3;
  71904. /**
  71905. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  71906. */
  71907. direction2: Vector3;
  71908. /**
  71909. * 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.
  71910. */
  71911. minEmitBox: Vector3;
  71912. /**
  71913. * 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.
  71914. */
  71915. maxEmitBox: Vector3;
  71916. /**
  71917. * Creates a new instance BoxParticleEmitter
  71918. */
  71919. constructor();
  71920. /**
  71921. * Called by the particle System when the direction is computed for the created particle.
  71922. * @param worldMatrix is the world matrix of the particle system
  71923. * @param directionToUpdate is the direction vector to update with the result
  71924. * @param particle is the particle we are computed the direction for
  71925. */
  71926. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  71927. /**
  71928. * Called by the particle System when the position is computed for the created particle.
  71929. * @param worldMatrix is the world matrix of the particle system
  71930. * @param positionToUpdate is the position vector to update with the result
  71931. * @param particle is the particle we are computed the position for
  71932. */
  71933. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  71934. /**
  71935. * Clones the current emitter and returns a copy of it
  71936. * @returns the new emitter
  71937. */
  71938. clone(): BoxParticleEmitter;
  71939. /**
  71940. * Called by the GPUParticleSystem to setup the update shader
  71941. * @param effect defines the update shader
  71942. */
  71943. applyToShader(effect: Effect): void;
  71944. /**
  71945. * Returns a string to use to update the GPU particles update shader
  71946. * @returns a string containng the defines string
  71947. */
  71948. getEffectDefines(): string;
  71949. /**
  71950. * Returns the string "BoxParticleEmitter"
  71951. * @returns a string containing the class name
  71952. */
  71953. getClassName(): string;
  71954. /**
  71955. * Serializes the particle system to a JSON object.
  71956. * @returns the JSON object
  71957. */
  71958. serialize(): any;
  71959. /**
  71960. * Parse properties from a JSON object
  71961. * @param serializationObject defines the JSON object
  71962. */
  71963. parse(serializationObject: any): void;
  71964. }
  71965. }
  71966. declare module BABYLON {
  71967. /**
  71968. * Particle emitter emitting particles from the inside of a cone.
  71969. * It emits the particles alongside the cone volume from the base to the particle.
  71970. * The emission direction might be randomized.
  71971. */
  71972. export class ConeParticleEmitter implements IParticleEmitterType {
  71973. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  71974. directionRandomizer: number;
  71975. private _radius;
  71976. private _angle;
  71977. private _height;
  71978. /**
  71979. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  71980. */
  71981. radiusRange: number;
  71982. /**
  71983. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  71984. */
  71985. heightRange: number;
  71986. /**
  71987. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  71988. */
  71989. emitFromSpawnPointOnly: boolean;
  71990. /**
  71991. * Gets or sets the radius of the emission cone
  71992. */
  71993. radius: number;
  71994. /**
  71995. * Gets or sets the angle of the emission cone
  71996. */
  71997. angle: number;
  71998. private _buildHeight;
  71999. /**
  72000. * Creates a new instance ConeParticleEmitter
  72001. * @param radius the radius of the emission cone (1 by default)
  72002. * @param angle the cone base angle (PI by default)
  72003. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  72004. */
  72005. constructor(radius?: number, angle?: number,
  72006. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  72007. directionRandomizer?: number);
  72008. /**
  72009. * Called by the particle System when the direction is computed for the created particle.
  72010. * @param worldMatrix is the world matrix of the particle system
  72011. * @param directionToUpdate is the direction vector to update with the result
  72012. * @param particle is the particle we are computed the direction for
  72013. */
  72014. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72015. /**
  72016. * Called by the particle System when the position is computed for the created particle.
  72017. * @param worldMatrix is the world matrix of the particle system
  72018. * @param positionToUpdate is the position vector to update with the result
  72019. * @param particle is the particle we are computed the position for
  72020. */
  72021. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72022. /**
  72023. * Clones the current emitter and returns a copy of it
  72024. * @returns the new emitter
  72025. */
  72026. clone(): ConeParticleEmitter;
  72027. /**
  72028. * Called by the GPUParticleSystem to setup the update shader
  72029. * @param effect defines the update shader
  72030. */
  72031. applyToShader(effect: Effect): void;
  72032. /**
  72033. * Returns a string to use to update the GPU particles update shader
  72034. * @returns a string containng the defines string
  72035. */
  72036. getEffectDefines(): string;
  72037. /**
  72038. * Returns the string "ConeParticleEmitter"
  72039. * @returns a string containing the class name
  72040. */
  72041. getClassName(): string;
  72042. /**
  72043. * Serializes the particle system to a JSON object.
  72044. * @returns the JSON object
  72045. */
  72046. serialize(): any;
  72047. /**
  72048. * Parse properties from a JSON object
  72049. * @param serializationObject defines the JSON object
  72050. */
  72051. parse(serializationObject: any): void;
  72052. }
  72053. }
  72054. declare module BABYLON {
  72055. /**
  72056. * Particle emitter emitting particles from the inside of a cylinder.
  72057. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  72058. */
  72059. export class CylinderParticleEmitter implements IParticleEmitterType {
  72060. /**
  72061. * The radius of the emission cylinder.
  72062. */
  72063. radius: number;
  72064. /**
  72065. * The height of the emission cylinder.
  72066. */
  72067. height: number;
  72068. /**
  72069. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72070. */
  72071. radiusRange: number;
  72072. /**
  72073. * How much to randomize the particle direction [0-1].
  72074. */
  72075. directionRandomizer: number;
  72076. /**
  72077. * Creates a new instance CylinderParticleEmitter
  72078. * @param radius the radius of the emission cylinder (1 by default)
  72079. * @param height the height of the emission cylinder (1 by default)
  72080. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72081. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  72082. */
  72083. constructor(
  72084. /**
  72085. * The radius of the emission cylinder.
  72086. */
  72087. radius?: number,
  72088. /**
  72089. * The height of the emission cylinder.
  72090. */
  72091. height?: number,
  72092. /**
  72093. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72094. */
  72095. radiusRange?: number,
  72096. /**
  72097. * How much to randomize the particle direction [0-1].
  72098. */
  72099. directionRandomizer?: number);
  72100. /**
  72101. * Called by the particle System when the direction is computed for the created particle.
  72102. * @param worldMatrix is the world matrix of the particle system
  72103. * @param directionToUpdate is the direction vector to update with the result
  72104. * @param particle is the particle we are computed the direction for
  72105. */
  72106. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72107. /**
  72108. * Called by the particle System when the position is computed for the created particle.
  72109. * @param worldMatrix is the world matrix of the particle system
  72110. * @param positionToUpdate is the position vector to update with the result
  72111. * @param particle is the particle we are computed the position for
  72112. */
  72113. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72114. /**
  72115. * Clones the current emitter and returns a copy of it
  72116. * @returns the new emitter
  72117. */
  72118. clone(): CylinderParticleEmitter;
  72119. /**
  72120. * Called by the GPUParticleSystem to setup the update shader
  72121. * @param effect defines the update shader
  72122. */
  72123. applyToShader(effect: Effect): void;
  72124. /**
  72125. * Returns a string to use to update the GPU particles update shader
  72126. * @returns a string containng the defines string
  72127. */
  72128. getEffectDefines(): string;
  72129. /**
  72130. * Returns the string "CylinderParticleEmitter"
  72131. * @returns a string containing the class name
  72132. */
  72133. getClassName(): string;
  72134. /**
  72135. * Serializes the particle system to a JSON object.
  72136. * @returns the JSON object
  72137. */
  72138. serialize(): any;
  72139. /**
  72140. * Parse properties from a JSON object
  72141. * @param serializationObject defines the JSON object
  72142. */
  72143. parse(serializationObject: any): void;
  72144. }
  72145. /**
  72146. * Particle emitter emitting particles from the inside of a cylinder.
  72147. * It emits the particles randomly between two vectors.
  72148. */
  72149. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  72150. /**
  72151. * The min limit of the emission direction.
  72152. */
  72153. direction1: Vector3;
  72154. /**
  72155. * The max limit of the emission direction.
  72156. */
  72157. direction2: Vector3;
  72158. /**
  72159. * Creates a new instance CylinderDirectedParticleEmitter
  72160. * @param radius the radius of the emission cylinder (1 by default)
  72161. * @param height the height of the emission cylinder (1 by default)
  72162. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72163. * @param direction1 the min limit of the emission direction (up vector by default)
  72164. * @param direction2 the max limit of the emission direction (up vector by default)
  72165. */
  72166. constructor(radius?: number, height?: number, radiusRange?: number,
  72167. /**
  72168. * The min limit of the emission direction.
  72169. */
  72170. direction1?: Vector3,
  72171. /**
  72172. * The max limit of the emission direction.
  72173. */
  72174. direction2?: Vector3);
  72175. /**
  72176. * Called by the particle System when the direction is computed for the created particle.
  72177. * @param worldMatrix is the world matrix of the particle system
  72178. * @param directionToUpdate is the direction vector to update with the result
  72179. * @param particle is the particle we are computed the direction for
  72180. */
  72181. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72182. /**
  72183. * Clones the current emitter and returns a copy of it
  72184. * @returns the new emitter
  72185. */
  72186. clone(): CylinderDirectedParticleEmitter;
  72187. /**
  72188. * Called by the GPUParticleSystem to setup the update shader
  72189. * @param effect defines the update shader
  72190. */
  72191. applyToShader(effect: Effect): void;
  72192. /**
  72193. * Returns a string to use to update the GPU particles update shader
  72194. * @returns a string containng the defines string
  72195. */
  72196. getEffectDefines(): string;
  72197. /**
  72198. * Returns the string "CylinderDirectedParticleEmitter"
  72199. * @returns a string containing the class name
  72200. */
  72201. getClassName(): string;
  72202. /**
  72203. * Serializes the particle system to a JSON object.
  72204. * @returns the JSON object
  72205. */
  72206. serialize(): any;
  72207. /**
  72208. * Parse properties from a JSON object
  72209. * @param serializationObject defines the JSON object
  72210. */
  72211. parse(serializationObject: any): void;
  72212. }
  72213. }
  72214. declare module BABYLON {
  72215. /**
  72216. * Particle emitter emitting particles from the inside of a hemisphere.
  72217. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  72218. */
  72219. export class HemisphericParticleEmitter implements IParticleEmitterType {
  72220. /**
  72221. * The radius of the emission hemisphere.
  72222. */
  72223. radius: number;
  72224. /**
  72225. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72226. */
  72227. radiusRange: number;
  72228. /**
  72229. * How much to randomize the particle direction [0-1].
  72230. */
  72231. directionRandomizer: number;
  72232. /**
  72233. * Creates a new instance HemisphericParticleEmitter
  72234. * @param radius the radius of the emission hemisphere (1 by default)
  72235. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72236. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  72237. */
  72238. constructor(
  72239. /**
  72240. * The radius of the emission hemisphere.
  72241. */
  72242. radius?: number,
  72243. /**
  72244. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72245. */
  72246. radiusRange?: number,
  72247. /**
  72248. * How much to randomize the particle direction [0-1].
  72249. */
  72250. directionRandomizer?: number);
  72251. /**
  72252. * Called by the particle System when the direction is computed for the created particle.
  72253. * @param worldMatrix is the world matrix of the particle system
  72254. * @param directionToUpdate is the direction vector to update with the result
  72255. * @param particle is the particle we are computed the direction for
  72256. */
  72257. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72258. /**
  72259. * Called by the particle System when the position is computed for the created particle.
  72260. * @param worldMatrix is the world matrix of the particle system
  72261. * @param positionToUpdate is the position vector to update with the result
  72262. * @param particle is the particle we are computed the position for
  72263. */
  72264. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72265. /**
  72266. * Clones the current emitter and returns a copy of it
  72267. * @returns the new emitter
  72268. */
  72269. clone(): HemisphericParticleEmitter;
  72270. /**
  72271. * Called by the GPUParticleSystem to setup the update shader
  72272. * @param effect defines the update shader
  72273. */
  72274. applyToShader(effect: Effect): void;
  72275. /**
  72276. * Returns a string to use to update the GPU particles update shader
  72277. * @returns a string containng the defines string
  72278. */
  72279. getEffectDefines(): string;
  72280. /**
  72281. * Returns the string "HemisphericParticleEmitter"
  72282. * @returns a string containing the class name
  72283. */
  72284. getClassName(): string;
  72285. /**
  72286. * Serializes the particle system to a JSON object.
  72287. * @returns the JSON object
  72288. */
  72289. serialize(): any;
  72290. /**
  72291. * Parse properties from a JSON object
  72292. * @param serializationObject defines the JSON object
  72293. */
  72294. parse(serializationObject: any): void;
  72295. }
  72296. }
  72297. declare module BABYLON {
  72298. /**
  72299. * Particle emitter emitting particles from a point.
  72300. * It emits the particles randomly between 2 given directions.
  72301. */
  72302. export class PointParticleEmitter implements IParticleEmitterType {
  72303. /**
  72304. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72305. */
  72306. direction1: Vector3;
  72307. /**
  72308. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72309. */
  72310. direction2: Vector3;
  72311. /**
  72312. * Creates a new instance PointParticleEmitter
  72313. */
  72314. constructor();
  72315. /**
  72316. * Called by the particle System when the direction is computed for the created particle.
  72317. * @param worldMatrix is the world matrix of the particle system
  72318. * @param directionToUpdate is the direction vector to update with the result
  72319. * @param particle is the particle we are computed the direction for
  72320. */
  72321. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72322. /**
  72323. * Called by the particle System when the position is computed for the created particle.
  72324. * @param worldMatrix is the world matrix of the particle system
  72325. * @param positionToUpdate is the position vector to update with the result
  72326. * @param particle is the particle we are computed the position for
  72327. */
  72328. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72329. /**
  72330. * Clones the current emitter and returns a copy of it
  72331. * @returns the new emitter
  72332. */
  72333. clone(): PointParticleEmitter;
  72334. /**
  72335. * Called by the GPUParticleSystem to setup the update shader
  72336. * @param effect defines the update shader
  72337. */
  72338. applyToShader(effect: Effect): void;
  72339. /**
  72340. * Returns a string to use to update the GPU particles update shader
  72341. * @returns a string containng the defines string
  72342. */
  72343. getEffectDefines(): string;
  72344. /**
  72345. * Returns the string "PointParticleEmitter"
  72346. * @returns a string containing the class name
  72347. */
  72348. getClassName(): string;
  72349. /**
  72350. * Serializes the particle system to a JSON object.
  72351. * @returns the JSON object
  72352. */
  72353. serialize(): any;
  72354. /**
  72355. * Parse properties from a JSON object
  72356. * @param serializationObject defines the JSON object
  72357. */
  72358. parse(serializationObject: any): void;
  72359. }
  72360. }
  72361. declare module BABYLON {
  72362. /**
  72363. * Particle emitter emitting particles from the inside of a sphere.
  72364. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  72365. */
  72366. export class SphereParticleEmitter implements IParticleEmitterType {
  72367. /**
  72368. * The radius of the emission sphere.
  72369. */
  72370. radius: number;
  72371. /**
  72372. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72373. */
  72374. radiusRange: number;
  72375. /**
  72376. * How much to randomize the particle direction [0-1].
  72377. */
  72378. directionRandomizer: number;
  72379. /**
  72380. * Creates a new instance SphereParticleEmitter
  72381. * @param radius the radius of the emission sphere (1 by default)
  72382. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72383. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  72384. */
  72385. constructor(
  72386. /**
  72387. * The radius of the emission sphere.
  72388. */
  72389. radius?: number,
  72390. /**
  72391. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72392. */
  72393. radiusRange?: number,
  72394. /**
  72395. * How much to randomize the particle direction [0-1].
  72396. */
  72397. directionRandomizer?: number);
  72398. /**
  72399. * Called by the particle System when the direction is computed for the created particle.
  72400. * @param worldMatrix is the world matrix of the particle system
  72401. * @param directionToUpdate is the direction vector to update with the result
  72402. * @param particle is the particle we are computed the direction for
  72403. */
  72404. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72405. /**
  72406. * Called by the particle System when the position is computed for the created particle.
  72407. * @param worldMatrix is the world matrix of the particle system
  72408. * @param positionToUpdate is the position vector to update with the result
  72409. * @param particle is the particle we are computed the position for
  72410. */
  72411. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72412. /**
  72413. * Clones the current emitter and returns a copy of it
  72414. * @returns the new emitter
  72415. */
  72416. clone(): SphereParticleEmitter;
  72417. /**
  72418. * Called by the GPUParticleSystem to setup the update shader
  72419. * @param effect defines the update shader
  72420. */
  72421. applyToShader(effect: Effect): void;
  72422. /**
  72423. * Returns a string to use to update the GPU particles update shader
  72424. * @returns a string containng the defines string
  72425. */
  72426. getEffectDefines(): string;
  72427. /**
  72428. * Returns the string "SphereParticleEmitter"
  72429. * @returns a string containing the class name
  72430. */
  72431. getClassName(): string;
  72432. /**
  72433. * Serializes the particle system to a JSON object.
  72434. * @returns the JSON object
  72435. */
  72436. serialize(): any;
  72437. /**
  72438. * Parse properties from a JSON object
  72439. * @param serializationObject defines the JSON object
  72440. */
  72441. parse(serializationObject: any): void;
  72442. }
  72443. /**
  72444. * Particle emitter emitting particles from the inside of a sphere.
  72445. * It emits the particles randomly between two vectors.
  72446. */
  72447. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  72448. /**
  72449. * The min limit of the emission direction.
  72450. */
  72451. direction1: Vector3;
  72452. /**
  72453. * The max limit of the emission direction.
  72454. */
  72455. direction2: Vector3;
  72456. /**
  72457. * Creates a new instance SphereDirectedParticleEmitter
  72458. * @param radius the radius of the emission sphere (1 by default)
  72459. * @param direction1 the min limit of the emission direction (up vector by default)
  72460. * @param direction2 the max limit of the emission direction (up vector by default)
  72461. */
  72462. constructor(radius?: number,
  72463. /**
  72464. * The min limit of the emission direction.
  72465. */
  72466. direction1?: Vector3,
  72467. /**
  72468. * The max limit of the emission direction.
  72469. */
  72470. direction2?: Vector3);
  72471. /**
  72472. * Called by the particle System when the direction is computed for the created particle.
  72473. * @param worldMatrix is the world matrix of the particle system
  72474. * @param directionToUpdate is the direction vector to update with the result
  72475. * @param particle is the particle we are computed the direction for
  72476. */
  72477. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72478. /**
  72479. * Clones the current emitter and returns a copy of it
  72480. * @returns the new emitter
  72481. */
  72482. clone(): SphereDirectedParticleEmitter;
  72483. /**
  72484. * Called by the GPUParticleSystem to setup the update shader
  72485. * @param effect defines the update shader
  72486. */
  72487. applyToShader(effect: Effect): void;
  72488. /**
  72489. * Returns a string to use to update the GPU particles update shader
  72490. * @returns a string containng the defines string
  72491. */
  72492. getEffectDefines(): string;
  72493. /**
  72494. * Returns the string "SphereDirectedParticleEmitter"
  72495. * @returns a string containing the class name
  72496. */
  72497. getClassName(): string;
  72498. /**
  72499. * Serializes the particle system to a JSON object.
  72500. * @returns the JSON object
  72501. */
  72502. serialize(): any;
  72503. /**
  72504. * Parse properties from a JSON object
  72505. * @param serializationObject defines the JSON object
  72506. */
  72507. parse(serializationObject: any): void;
  72508. }
  72509. }
  72510. declare module BABYLON {
  72511. /**
  72512. * Interface representing a particle system in Babylon.js.
  72513. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  72514. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  72515. */
  72516. export interface IParticleSystem {
  72517. /**
  72518. * List of animations used by the particle system.
  72519. */
  72520. animations: Animation[];
  72521. /**
  72522. * The id of the Particle system.
  72523. */
  72524. id: string;
  72525. /**
  72526. * The name of the Particle system.
  72527. */
  72528. name: string;
  72529. /**
  72530. * The emitter represents the Mesh or position we are attaching the particle system to.
  72531. */
  72532. emitter: Nullable<AbstractMesh | Vector3>;
  72533. /**
  72534. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  72535. */
  72536. isBillboardBased: boolean;
  72537. /**
  72538. * The rendering group used by the Particle system to chose when to render.
  72539. */
  72540. renderingGroupId: number;
  72541. /**
  72542. * The layer mask we are rendering the particles through.
  72543. */
  72544. layerMask: number;
  72545. /**
  72546. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  72547. */
  72548. updateSpeed: number;
  72549. /**
  72550. * The amount of time the particle system is running (depends of the overall update speed).
  72551. */
  72552. targetStopDuration: number;
  72553. /**
  72554. * The texture used to render each particle. (this can be a spritesheet)
  72555. */
  72556. particleTexture: Nullable<Texture>;
  72557. /**
  72558. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  72559. */
  72560. blendMode: number;
  72561. /**
  72562. * Minimum life time of emitting particles.
  72563. */
  72564. minLifeTime: number;
  72565. /**
  72566. * Maximum life time of emitting particles.
  72567. */
  72568. maxLifeTime: number;
  72569. /**
  72570. * Minimum Size of emitting particles.
  72571. */
  72572. minSize: number;
  72573. /**
  72574. * Maximum Size of emitting particles.
  72575. */
  72576. maxSize: number;
  72577. /**
  72578. * Minimum scale of emitting particles on X axis.
  72579. */
  72580. minScaleX: number;
  72581. /**
  72582. * Maximum scale of emitting particles on X axis.
  72583. */
  72584. maxScaleX: number;
  72585. /**
  72586. * Minimum scale of emitting particles on Y axis.
  72587. */
  72588. minScaleY: number;
  72589. /**
  72590. * Maximum scale of emitting particles on Y axis.
  72591. */
  72592. maxScaleY: number;
  72593. /**
  72594. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  72595. */
  72596. color1: Color4;
  72597. /**
  72598. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  72599. */
  72600. color2: Color4;
  72601. /**
  72602. * Color the particle will have at the end of its lifetime.
  72603. */
  72604. colorDead: Color4;
  72605. /**
  72606. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  72607. */
  72608. emitRate: number;
  72609. /**
  72610. * You can use gravity if you want to give an orientation to your particles.
  72611. */
  72612. gravity: Vector3;
  72613. /**
  72614. * Minimum power of emitting particles.
  72615. */
  72616. minEmitPower: number;
  72617. /**
  72618. * Maximum power of emitting particles.
  72619. */
  72620. maxEmitPower: number;
  72621. /**
  72622. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  72623. */
  72624. minAngularSpeed: number;
  72625. /**
  72626. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  72627. */
  72628. maxAngularSpeed: number;
  72629. /**
  72630. * Gets or sets the minimal initial rotation in radians.
  72631. */
  72632. minInitialRotation: number;
  72633. /**
  72634. * Gets or sets the maximal initial rotation in radians.
  72635. */
  72636. maxInitialRotation: number;
  72637. /**
  72638. * The particle emitter type defines the emitter used by the particle system.
  72639. * It can be for example box, sphere, or cone...
  72640. */
  72641. particleEmitterType: Nullable<IParticleEmitterType>;
  72642. /**
  72643. * Defines the delay in milliseconds before starting the system (0 by default)
  72644. */
  72645. startDelay: number;
  72646. /**
  72647. * 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
  72648. */
  72649. preWarmCycles: number;
  72650. /**
  72651. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  72652. */
  72653. preWarmStepOffset: number;
  72654. /**
  72655. * 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)
  72656. */
  72657. spriteCellChangeSpeed: number;
  72658. /**
  72659. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  72660. */
  72661. startSpriteCellID: number;
  72662. /**
  72663. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  72664. */
  72665. endSpriteCellID: number;
  72666. /**
  72667. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  72668. */
  72669. spriteCellWidth: number;
  72670. /**
  72671. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  72672. */
  72673. spriteCellHeight: number;
  72674. /**
  72675. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  72676. */
  72677. spriteRandomStartCell: boolean;
  72678. /**
  72679. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  72680. */
  72681. isAnimationSheetEnabled: boolean;
  72682. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  72683. translationPivot: Vector2;
  72684. /**
  72685. * Gets or sets a texture used to add random noise to particle positions
  72686. */
  72687. noiseTexture: Nullable<BaseTexture>;
  72688. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  72689. noiseStrength: Vector3;
  72690. /**
  72691. * Gets or sets the billboard mode to use when isBillboardBased = true.
  72692. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  72693. */
  72694. billboardMode: number;
  72695. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  72696. limitVelocityDamping: number;
  72697. /**
  72698. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  72699. */
  72700. beginAnimationOnStart: boolean;
  72701. /**
  72702. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  72703. */
  72704. beginAnimationFrom: number;
  72705. /**
  72706. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  72707. */
  72708. beginAnimationTo: number;
  72709. /**
  72710. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  72711. */
  72712. beginAnimationLoop: boolean;
  72713. /**
  72714. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  72715. */
  72716. disposeOnStop: boolean;
  72717. /**
  72718. * Gets the maximum number of particles active at the same time.
  72719. * @returns The max number of active particles.
  72720. */
  72721. getCapacity(): number;
  72722. /**
  72723. * Gets if the system has been started. (Note: this will still be true after stop is called)
  72724. * @returns True if it has been started, otherwise false.
  72725. */
  72726. isStarted(): boolean;
  72727. /**
  72728. * Animates the particle system for this frame.
  72729. */
  72730. animate(): void;
  72731. /**
  72732. * Renders the particle system in its current state.
  72733. * @returns the current number of particles
  72734. */
  72735. render(): number;
  72736. /**
  72737. * Dispose the particle system and frees its associated resources.
  72738. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  72739. */
  72740. dispose(disposeTexture?: boolean): void;
  72741. /**
  72742. * Clones the particle system.
  72743. * @param name The name of the cloned object
  72744. * @param newEmitter The new emitter to use
  72745. * @returns the cloned particle system
  72746. */
  72747. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  72748. /**
  72749. * Serializes the particle system to a JSON object.
  72750. * @returns the JSON object
  72751. */
  72752. serialize(): any;
  72753. /**
  72754. * Rebuild the particle system
  72755. */
  72756. rebuild(): void;
  72757. /**
  72758. * Starts the particle system and begins to emit
  72759. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  72760. */
  72761. start(delay?: number): void;
  72762. /**
  72763. * Stops the particle system.
  72764. */
  72765. stop(): void;
  72766. /**
  72767. * Remove all active particles
  72768. */
  72769. reset(): void;
  72770. /**
  72771. * Is this system ready to be used/rendered
  72772. * @return true if the system is ready
  72773. */
  72774. isReady(): boolean;
  72775. /**
  72776. * Adds a new color gradient
  72777. * @param gradient defines the gradient to use (between 0 and 1)
  72778. * @param color1 defines the color to affect to the specified gradient
  72779. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  72780. * @returns the current particle system
  72781. */
  72782. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  72783. /**
  72784. * Remove a specific color gradient
  72785. * @param gradient defines the gradient to remove
  72786. * @returns the current particle system
  72787. */
  72788. removeColorGradient(gradient: number): IParticleSystem;
  72789. /**
  72790. * Adds a new size gradient
  72791. * @param gradient defines the gradient to use (between 0 and 1)
  72792. * @param factor defines the size factor to affect to the specified gradient
  72793. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72794. * @returns the current particle system
  72795. */
  72796. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72797. /**
  72798. * Remove a specific size gradient
  72799. * @param gradient defines the gradient to remove
  72800. * @returns the current particle system
  72801. */
  72802. removeSizeGradient(gradient: number): IParticleSystem;
  72803. /**
  72804. * Gets the current list of color gradients.
  72805. * You must use addColorGradient and removeColorGradient to udpate this list
  72806. * @returns the list of color gradients
  72807. */
  72808. getColorGradients(): Nullable<Array<ColorGradient>>;
  72809. /**
  72810. * Gets the current list of size gradients.
  72811. * You must use addSizeGradient and removeSizeGradient to udpate this list
  72812. * @returns the list of size gradients
  72813. */
  72814. getSizeGradients(): Nullable<Array<FactorGradient>>;
  72815. /**
  72816. * Gets the current list of angular speed gradients.
  72817. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  72818. * @returns the list of angular speed gradients
  72819. */
  72820. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  72821. /**
  72822. * Adds a new angular speed gradient
  72823. * @param gradient defines the gradient to use (between 0 and 1)
  72824. * @param factor defines the angular speed to affect to the specified gradient
  72825. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72826. * @returns the current particle system
  72827. */
  72828. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72829. /**
  72830. * Remove a specific angular speed gradient
  72831. * @param gradient defines the gradient to remove
  72832. * @returns the current particle system
  72833. */
  72834. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  72835. /**
  72836. * Gets the current list of velocity gradients.
  72837. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  72838. * @returns the list of velocity gradients
  72839. */
  72840. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  72841. /**
  72842. * Adds a new velocity gradient
  72843. * @param gradient defines the gradient to use (between 0 and 1)
  72844. * @param factor defines the velocity to affect to the specified gradient
  72845. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72846. * @returns the current particle system
  72847. */
  72848. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72849. /**
  72850. * Remove a specific velocity gradient
  72851. * @param gradient defines the gradient to remove
  72852. * @returns the current particle system
  72853. */
  72854. removeVelocityGradient(gradient: number): IParticleSystem;
  72855. /**
  72856. * Gets the current list of limit velocity gradients.
  72857. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  72858. * @returns the list of limit velocity gradients
  72859. */
  72860. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  72861. /**
  72862. * Adds a new limit velocity gradient
  72863. * @param gradient defines the gradient to use (between 0 and 1)
  72864. * @param factor defines the limit velocity to affect to the specified gradient
  72865. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72866. * @returns the current particle system
  72867. */
  72868. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72869. /**
  72870. * Remove a specific limit velocity gradient
  72871. * @param gradient defines the gradient to remove
  72872. * @returns the current particle system
  72873. */
  72874. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  72875. /**
  72876. * Adds a new drag gradient
  72877. * @param gradient defines the gradient to use (between 0 and 1)
  72878. * @param factor defines the drag to affect to the specified gradient
  72879. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72880. * @returns the current particle system
  72881. */
  72882. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72883. /**
  72884. * Remove a specific drag gradient
  72885. * @param gradient defines the gradient to remove
  72886. * @returns the current particle system
  72887. */
  72888. removeDragGradient(gradient: number): IParticleSystem;
  72889. /**
  72890. * Gets the current list of drag gradients.
  72891. * You must use addDragGradient and removeDragGradient to udpate this list
  72892. * @returns the list of drag gradients
  72893. */
  72894. getDragGradients(): Nullable<Array<FactorGradient>>;
  72895. /**
  72896. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  72897. * @param gradient defines the gradient to use (between 0 and 1)
  72898. * @param factor defines the emit rate to affect to the specified gradient
  72899. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72900. * @returns the current particle system
  72901. */
  72902. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72903. /**
  72904. * Remove a specific emit rate gradient
  72905. * @param gradient defines the gradient to remove
  72906. * @returns the current particle system
  72907. */
  72908. removeEmitRateGradient(gradient: number): IParticleSystem;
  72909. /**
  72910. * Gets the current list of emit rate gradients.
  72911. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  72912. * @returns the list of emit rate gradients
  72913. */
  72914. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  72915. /**
  72916. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  72917. * @param gradient defines the gradient to use (between 0 and 1)
  72918. * @param factor defines the start size to affect to the specified gradient
  72919. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72920. * @returns the current particle system
  72921. */
  72922. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72923. /**
  72924. * Remove a specific start size gradient
  72925. * @param gradient defines the gradient to remove
  72926. * @returns the current particle system
  72927. */
  72928. removeStartSizeGradient(gradient: number): IParticleSystem;
  72929. /**
  72930. * Gets the current list of start size gradients.
  72931. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  72932. * @returns the list of start size gradients
  72933. */
  72934. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  72935. /**
  72936. * Adds a new life time gradient
  72937. * @param gradient defines the gradient to use (between 0 and 1)
  72938. * @param factor defines the life time factor to affect to the specified gradient
  72939. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72940. * @returns the current particle system
  72941. */
  72942. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72943. /**
  72944. * Remove a specific life time gradient
  72945. * @param gradient defines the gradient to remove
  72946. * @returns the current particle system
  72947. */
  72948. removeLifeTimeGradient(gradient: number): IParticleSystem;
  72949. /**
  72950. * Gets the current list of life time gradients.
  72951. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  72952. * @returns the list of life time gradients
  72953. */
  72954. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  72955. /**
  72956. * Gets the current list of color gradients.
  72957. * You must use addColorGradient and removeColorGradient to udpate this list
  72958. * @returns the list of color gradients
  72959. */
  72960. getColorGradients(): Nullable<Array<ColorGradient>>;
  72961. /**
  72962. * Adds a new ramp gradient used to remap particle colors
  72963. * @param gradient defines the gradient to use (between 0 and 1)
  72964. * @param color defines the color to affect to the specified gradient
  72965. * @returns the current particle system
  72966. */
  72967. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  72968. /**
  72969. * Gets the current list of ramp gradients.
  72970. * You must use addRampGradient and removeRampGradient to udpate this list
  72971. * @returns the list of ramp gradients
  72972. */
  72973. getRampGradients(): Nullable<Array<Color3Gradient>>;
  72974. /** Gets or sets a boolean indicating that ramp gradients must be used
  72975. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  72976. */
  72977. useRampGradients: boolean;
  72978. /**
  72979. * Adds a new color remap gradient
  72980. * @param gradient defines the gradient to use (between 0 and 1)
  72981. * @param min defines the color remap minimal range
  72982. * @param max defines the color remap maximal range
  72983. * @returns the current particle system
  72984. */
  72985. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72986. /**
  72987. * Gets the current list of color remap gradients.
  72988. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  72989. * @returns the list of color remap gradients
  72990. */
  72991. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  72992. /**
  72993. * Adds a new alpha remap gradient
  72994. * @param gradient defines the gradient to use (between 0 and 1)
  72995. * @param min defines the alpha remap minimal range
  72996. * @param max defines the alpha remap maximal range
  72997. * @returns the current particle system
  72998. */
  72999. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  73000. /**
  73001. * Gets the current list of alpha remap gradients.
  73002. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  73003. * @returns the list of alpha remap gradients
  73004. */
  73005. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  73006. /**
  73007. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  73008. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  73009. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  73010. * @returns the emitter
  73011. */
  73012. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  73013. /**
  73014. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  73015. * @param radius The radius of the hemisphere to emit from
  73016. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73017. * @returns the emitter
  73018. */
  73019. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  73020. /**
  73021. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  73022. * @param radius The radius of the sphere to emit from
  73023. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73024. * @returns the emitter
  73025. */
  73026. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  73027. /**
  73028. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  73029. * @param radius The radius of the sphere to emit from
  73030. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  73031. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  73032. * @returns the emitter
  73033. */
  73034. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  73035. /**
  73036. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  73037. * @param radius The radius of the emission cylinder
  73038. * @param height The height of the emission cylinder
  73039. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  73040. * @param directionRandomizer How much to randomize the particle direction [0-1]
  73041. * @returns the emitter
  73042. */
  73043. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  73044. /**
  73045. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  73046. * @param radius The radius of the cylinder to emit from
  73047. * @param height The height of the emission cylinder
  73048. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73049. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  73050. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  73051. * @returns the emitter
  73052. */
  73053. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  73054. /**
  73055. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  73056. * @param radius The radius of the cone to emit from
  73057. * @param angle The base angle of the cone
  73058. * @returns the emitter
  73059. */
  73060. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  73061. /**
  73062. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  73063. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  73064. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  73065. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73066. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73067. * @returns the emitter
  73068. */
  73069. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  73070. /**
  73071. * Get hosting scene
  73072. * @returns the scene
  73073. */
  73074. getScene(): Scene;
  73075. }
  73076. }
  73077. declare module BABYLON {
  73078. /**
  73079. * Creates an instance based on a source mesh.
  73080. */
  73081. export class InstancedMesh extends AbstractMesh {
  73082. private _sourceMesh;
  73083. private _currentLOD;
  73084. /** @hidden */
  73085. _indexInSourceMeshInstanceArray: number;
  73086. constructor(name: string, source: Mesh);
  73087. /**
  73088. * Returns the string "InstancedMesh".
  73089. */
  73090. getClassName(): string;
  73091. /**
  73092. * If the source mesh receives shadows
  73093. */
  73094. readonly receiveShadows: boolean;
  73095. /**
  73096. * The material of the source mesh
  73097. */
  73098. readonly material: Nullable<Material>;
  73099. /**
  73100. * Visibility of the source mesh
  73101. */
  73102. readonly visibility: number;
  73103. /**
  73104. * Skeleton of the source mesh
  73105. */
  73106. readonly skeleton: Nullable<Skeleton>;
  73107. /**
  73108. * Rendering ground id of the source mesh
  73109. */
  73110. renderingGroupId: number;
  73111. /**
  73112. * Returns the total number of vertices (integer).
  73113. */
  73114. getTotalVertices(): number;
  73115. /**
  73116. * Returns a positive integer : the total number of indices in this mesh geometry.
  73117. * @returns the numner of indices or zero if the mesh has no geometry.
  73118. */
  73119. getTotalIndices(): number;
  73120. /**
  73121. * The source mesh of the instance
  73122. */
  73123. readonly sourceMesh: Mesh;
  73124. /**
  73125. * Is this node ready to be used/rendered
  73126. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  73127. * @return {boolean} is it ready
  73128. */
  73129. isReady(completeCheck?: boolean): boolean;
  73130. /**
  73131. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  73132. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  73133. * @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.
  73134. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  73135. */
  73136. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  73137. /**
  73138. * Sets the vertex data of the mesh geometry for the requested `kind`.
  73139. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  73140. * The `data` are either a numeric array either a Float32Array.
  73141. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  73142. * 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).
  73143. * Note that a new underlying VertexBuffer object is created each call.
  73144. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  73145. *
  73146. * Possible `kind` values :
  73147. * - VertexBuffer.PositionKind
  73148. * - VertexBuffer.UVKind
  73149. * - VertexBuffer.UV2Kind
  73150. * - VertexBuffer.UV3Kind
  73151. * - VertexBuffer.UV4Kind
  73152. * - VertexBuffer.UV5Kind
  73153. * - VertexBuffer.UV6Kind
  73154. * - VertexBuffer.ColorKind
  73155. * - VertexBuffer.MatricesIndicesKind
  73156. * - VertexBuffer.MatricesIndicesExtraKind
  73157. * - VertexBuffer.MatricesWeightsKind
  73158. * - VertexBuffer.MatricesWeightsExtraKind
  73159. *
  73160. * Returns the Mesh.
  73161. */
  73162. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  73163. /**
  73164. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  73165. * If the mesh has no geometry, it is simply returned as it is.
  73166. * The `data` are either a numeric array either a Float32Array.
  73167. * No new underlying VertexBuffer object is created.
  73168. * 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.
  73169. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  73170. *
  73171. * Possible `kind` values :
  73172. * - VertexBuffer.PositionKind
  73173. * - VertexBuffer.UVKind
  73174. * - VertexBuffer.UV2Kind
  73175. * - VertexBuffer.UV3Kind
  73176. * - VertexBuffer.UV4Kind
  73177. * - VertexBuffer.UV5Kind
  73178. * - VertexBuffer.UV6Kind
  73179. * - VertexBuffer.ColorKind
  73180. * - VertexBuffer.MatricesIndicesKind
  73181. * - VertexBuffer.MatricesIndicesExtraKind
  73182. * - VertexBuffer.MatricesWeightsKind
  73183. * - VertexBuffer.MatricesWeightsExtraKind
  73184. *
  73185. * Returns the Mesh.
  73186. */
  73187. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  73188. /**
  73189. * Sets the mesh indices.
  73190. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  73191. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  73192. * This method creates a new index buffer each call.
  73193. * Returns the Mesh.
  73194. */
  73195. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  73196. /**
  73197. * Boolean : True if the mesh owns the requested kind of data.
  73198. */
  73199. isVerticesDataPresent(kind: string): boolean;
  73200. /**
  73201. * Returns an array of indices (IndicesArray).
  73202. */
  73203. getIndices(): Nullable<IndicesArray>;
  73204. readonly _positions: Nullable<Vector3[]>;
  73205. /**
  73206. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  73207. * This means the mesh underlying bounding box and sphere are recomputed.
  73208. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  73209. * @returns the current mesh
  73210. */
  73211. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  73212. /** @hidden */
  73213. _preActivate(): InstancedMesh;
  73214. /** @hidden */
  73215. _activate(renderId: number): InstancedMesh;
  73216. /**
  73217. * Returns the current associated LOD AbstractMesh.
  73218. */
  73219. getLOD(camera: Camera): AbstractMesh;
  73220. /** @hidden */
  73221. _syncSubMeshes(): InstancedMesh;
  73222. /** @hidden */
  73223. _generatePointsArray(): boolean;
  73224. /**
  73225. * Creates a new InstancedMesh from the current mesh.
  73226. * - name (string) : the cloned mesh name
  73227. * - newParent (optional Node) : the optional Node to parent the clone to.
  73228. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  73229. *
  73230. * Returns the clone.
  73231. */
  73232. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  73233. /**
  73234. * Disposes the InstancedMesh.
  73235. * Returns nothing.
  73236. */
  73237. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  73238. }
  73239. }
  73240. declare module BABYLON {
  73241. /**
  73242. * Defines the options associated with the creation of a shader material.
  73243. */
  73244. export interface IShaderMaterialOptions {
  73245. /**
  73246. * Does the material work in alpha blend mode
  73247. */
  73248. needAlphaBlending: boolean;
  73249. /**
  73250. * Does the material work in alpha test mode
  73251. */
  73252. needAlphaTesting: boolean;
  73253. /**
  73254. * The list of attribute names used in the shader
  73255. */
  73256. attributes: string[];
  73257. /**
  73258. * The list of unifrom names used in the shader
  73259. */
  73260. uniforms: string[];
  73261. /**
  73262. * The list of UBO names used in the shader
  73263. */
  73264. uniformBuffers: string[];
  73265. /**
  73266. * The list of sampler names used in the shader
  73267. */
  73268. samplers: string[];
  73269. /**
  73270. * The list of defines used in the shader
  73271. */
  73272. defines: string[];
  73273. }
  73274. /**
  73275. * 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.
  73276. *
  73277. * This returned material effects how the mesh will look based on the code in the shaders.
  73278. *
  73279. * @see http://doc.babylonjs.com/how_to/shader_material
  73280. */
  73281. export class ShaderMaterial extends Material {
  73282. private _shaderPath;
  73283. private _options;
  73284. private _textures;
  73285. private _textureArrays;
  73286. private _floats;
  73287. private _ints;
  73288. private _floatsArrays;
  73289. private _colors3;
  73290. private _colors3Arrays;
  73291. private _colors4;
  73292. private _vectors2;
  73293. private _vectors3;
  73294. private _vectors4;
  73295. private _matrices;
  73296. private _matrices3x3;
  73297. private _matrices2x2;
  73298. private _vectors2Arrays;
  73299. private _vectors3Arrays;
  73300. private _cachedWorldViewMatrix;
  73301. private _renderId;
  73302. /**
  73303. * Instantiate a new shader material.
  73304. * 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.
  73305. * This returned material effects how the mesh will look based on the code in the shaders.
  73306. * @see http://doc.babylonjs.com/how_to/shader_material
  73307. * @param name Define the name of the material in the scene
  73308. * @param scene Define the scene the material belongs to
  73309. * @param shaderPath Defines the route to the shader code in one of three ways:
  73310. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  73311. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  73312. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  73313. * @param options Define the options used to create the shader
  73314. */
  73315. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  73316. /**
  73317. * Gets the current class name of the material e.g. "ShaderMaterial"
  73318. * Mainly use in serialization.
  73319. * @returns the class name
  73320. */
  73321. getClassName(): string;
  73322. /**
  73323. * Specifies if the material will require alpha blending
  73324. * @returns a boolean specifying if alpha blending is needed
  73325. */
  73326. needAlphaBlending(): boolean;
  73327. /**
  73328. * Specifies if this material should be rendered in alpha test mode
  73329. * @returns a boolean specifying if an alpha test is needed.
  73330. */
  73331. needAlphaTesting(): boolean;
  73332. private _checkUniform;
  73333. /**
  73334. * Set a texture in the shader.
  73335. * @param name Define the name of the uniform samplers as defined in the shader
  73336. * @param texture Define the texture to bind to this sampler
  73337. * @return the material itself allowing "fluent" like uniform updates
  73338. */
  73339. setTexture(name: string, texture: Texture): ShaderMaterial;
  73340. /**
  73341. * Set a texture array in the shader.
  73342. * @param name Define the name of the uniform sampler array as defined in the shader
  73343. * @param textures Define the list of textures to bind to this sampler
  73344. * @return the material itself allowing "fluent" like uniform updates
  73345. */
  73346. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  73347. /**
  73348. * Set a float in the shader.
  73349. * @param name Define the name of the uniform as defined in the shader
  73350. * @param value Define the value to give to the uniform
  73351. * @return the material itself allowing "fluent" like uniform updates
  73352. */
  73353. setFloat(name: string, value: number): ShaderMaterial;
  73354. /**
  73355. * Set a int in the shader.
  73356. * @param name Define the name of the uniform as defined in the shader
  73357. * @param value Define the value to give to the uniform
  73358. * @return the material itself allowing "fluent" like uniform updates
  73359. */
  73360. setInt(name: string, value: number): ShaderMaterial;
  73361. /**
  73362. * Set an array of floats in the shader.
  73363. * @param name Define the name of the uniform as defined in the shader
  73364. * @param value Define the value to give to the uniform
  73365. * @return the material itself allowing "fluent" like uniform updates
  73366. */
  73367. setFloats(name: string, value: number[]): ShaderMaterial;
  73368. /**
  73369. * Set a vec3 in the shader from a Color3.
  73370. * @param name Define the name of the uniform as defined in the shader
  73371. * @param value Define the value to give to the uniform
  73372. * @return the material itself allowing "fluent" like uniform updates
  73373. */
  73374. setColor3(name: string, value: Color3): ShaderMaterial;
  73375. /**
  73376. * Set a vec3 array in the shader from a Color3 array.
  73377. * @param name Define the name of the uniform as defined in the shader
  73378. * @param value Define the value to give to the uniform
  73379. * @return the material itself allowing "fluent" like uniform updates
  73380. */
  73381. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  73382. /**
  73383. * Set a vec4 in the shader from a Color4.
  73384. * @param name Define the name of the uniform as defined in the shader
  73385. * @param value Define the value to give to the uniform
  73386. * @return the material itself allowing "fluent" like uniform updates
  73387. */
  73388. setColor4(name: string, value: Color4): ShaderMaterial;
  73389. /**
  73390. * Set a vec2 in the shader from a Vector2.
  73391. * @param name Define the name of the uniform as defined in the shader
  73392. * @param value Define the value to give to the uniform
  73393. * @return the material itself allowing "fluent" like uniform updates
  73394. */
  73395. setVector2(name: string, value: Vector2): ShaderMaterial;
  73396. /**
  73397. * Set a vec3 in the shader from a Vector3.
  73398. * @param name Define the name of the uniform as defined in the shader
  73399. * @param value Define the value to give to the uniform
  73400. * @return the material itself allowing "fluent" like uniform updates
  73401. */
  73402. setVector3(name: string, value: Vector3): ShaderMaterial;
  73403. /**
  73404. * Set a vec4 in the shader from a Vector4.
  73405. * @param name Define the name of the uniform as defined in the shader
  73406. * @param value Define the value to give to the uniform
  73407. * @return the material itself allowing "fluent" like uniform updates
  73408. */
  73409. setVector4(name: string, value: Vector4): ShaderMaterial;
  73410. /**
  73411. * Set a mat4 in the shader from a Matrix.
  73412. * @param name Define the name of the uniform as defined in the shader
  73413. * @param value Define the value to give to the uniform
  73414. * @return the material itself allowing "fluent" like uniform updates
  73415. */
  73416. setMatrix(name: string, value: Matrix): ShaderMaterial;
  73417. /**
  73418. * Set a mat3 in the shader from a Float32Array.
  73419. * @param name Define the name of the uniform as defined in the shader
  73420. * @param value Define the value to give to the uniform
  73421. * @return the material itself allowing "fluent" like uniform updates
  73422. */
  73423. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  73424. /**
  73425. * Set a mat2 in the shader from a Float32Array.
  73426. * @param name Define the name of the uniform as defined in the shader
  73427. * @param value Define the value to give to the uniform
  73428. * @return the material itself allowing "fluent" like uniform updates
  73429. */
  73430. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  73431. /**
  73432. * Set a vec2 array in the shader from a number array.
  73433. * @param name Define the name of the uniform as defined in the shader
  73434. * @param value Define the value to give to the uniform
  73435. * @return the material itself allowing "fluent" like uniform updates
  73436. */
  73437. setArray2(name: string, value: number[]): ShaderMaterial;
  73438. /**
  73439. * Set a vec3 array in the shader from a number array.
  73440. * @param name Define the name of the uniform as defined in the shader
  73441. * @param value Define the value to give to the uniform
  73442. * @return the material itself allowing "fluent" like uniform updates
  73443. */
  73444. setArray3(name: string, value: number[]): ShaderMaterial;
  73445. private _checkCache;
  73446. /**
  73447. * Checks if the material is ready to render the requested mesh
  73448. * @param mesh Define the mesh to render
  73449. * @param useInstances Define whether or not the material is used with instances
  73450. * @returns true if ready, otherwise false
  73451. */
  73452. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  73453. /**
  73454. * Binds the world matrix to the material
  73455. * @param world defines the world transformation matrix
  73456. */
  73457. bindOnlyWorldMatrix(world: Matrix): void;
  73458. /**
  73459. * Binds the material to the mesh
  73460. * @param world defines the world transformation matrix
  73461. * @param mesh defines the mesh to bind the material to
  73462. */
  73463. bind(world: Matrix, mesh?: Mesh): void;
  73464. /**
  73465. * Gets the active textures from the material
  73466. * @returns an array of textures
  73467. */
  73468. getActiveTextures(): BaseTexture[];
  73469. /**
  73470. * Specifies if the material uses a texture
  73471. * @param texture defines the texture to check against the material
  73472. * @returns a boolean specifying if the material uses the texture
  73473. */
  73474. hasTexture(texture: BaseTexture): boolean;
  73475. /**
  73476. * Makes a duplicate of the material, and gives it a new name
  73477. * @param name defines the new name for the duplicated material
  73478. * @returns the cloned material
  73479. */
  73480. clone(name: string): ShaderMaterial;
  73481. /**
  73482. * Disposes the material
  73483. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  73484. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  73485. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  73486. */
  73487. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  73488. /**
  73489. * Serializes this material in a JSON representation
  73490. * @returns the serialized material object
  73491. */
  73492. serialize(): any;
  73493. /**
  73494. * Creates a shader material from parsed shader material data
  73495. * @param source defines the JSON represnetation of the material
  73496. * @param scene defines the hosting scene
  73497. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  73498. * @returns a new material
  73499. */
  73500. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  73501. }
  73502. }
  73503. declare module BABYLON {
  73504. /** @hidden */
  73505. export var colorPixelShader: {
  73506. name: string;
  73507. shader: string;
  73508. };
  73509. }
  73510. declare module BABYLON {
  73511. /** @hidden */
  73512. export var colorVertexShader: {
  73513. name: string;
  73514. shader: string;
  73515. };
  73516. }
  73517. declare module BABYLON {
  73518. /**
  73519. * Line mesh
  73520. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  73521. */
  73522. export class LinesMesh extends Mesh {
  73523. /**
  73524. * If vertex color should be applied to the mesh
  73525. */
  73526. useVertexColor?: boolean | undefined;
  73527. /**
  73528. * If vertex alpha should be applied to the mesh
  73529. */
  73530. useVertexAlpha?: boolean | undefined;
  73531. /**
  73532. * Color of the line (Default: White)
  73533. */
  73534. color: Color3;
  73535. /**
  73536. * Alpha of the line (Default: 1)
  73537. */
  73538. alpha: number;
  73539. /**
  73540. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  73541. * This margin is expressed in world space coordinates, so its value may vary.
  73542. * Default value is 0.1
  73543. */
  73544. intersectionThreshold: number;
  73545. private _colorShader;
  73546. /**
  73547. * Creates a new LinesMesh
  73548. * @param name defines the name
  73549. * @param scene defines the hosting scene
  73550. * @param parent defines the parent mesh if any
  73551. * @param source defines the optional source LinesMesh used to clone data from
  73552. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  73553. * When false, achieved by calling a clone(), also passing False.
  73554. * This will make creation of children, recursive.
  73555. * @param useVertexColor defines if this LinesMesh supports vertex color
  73556. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  73557. */
  73558. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  73559. /**
  73560. * If vertex color should be applied to the mesh
  73561. */
  73562. useVertexColor?: boolean | undefined,
  73563. /**
  73564. * If vertex alpha should be applied to the mesh
  73565. */
  73566. useVertexAlpha?: boolean | undefined);
  73567. /**
  73568. * Returns the string "LineMesh"
  73569. */
  73570. getClassName(): string;
  73571. /**
  73572. * @hidden
  73573. */
  73574. /**
  73575. * @hidden
  73576. */
  73577. material: Material;
  73578. /**
  73579. * @hidden
  73580. */
  73581. readonly checkCollisions: boolean;
  73582. /** @hidden */
  73583. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  73584. /** @hidden */
  73585. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  73586. /**
  73587. * Disposes of the line mesh
  73588. * @param doNotRecurse If children should be disposed
  73589. */
  73590. dispose(doNotRecurse?: boolean): void;
  73591. /**
  73592. * Returns a new LineMesh object cloned from the current one.
  73593. */
  73594. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  73595. /**
  73596. * Creates a new InstancedLinesMesh object from the mesh model.
  73597. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  73598. * @param name defines the name of the new instance
  73599. * @returns a new InstancedLinesMesh
  73600. */
  73601. createInstance(name: string): InstancedLinesMesh;
  73602. }
  73603. /**
  73604. * Creates an instance based on a source LinesMesh
  73605. */
  73606. export class InstancedLinesMesh extends InstancedMesh {
  73607. /**
  73608. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  73609. * This margin is expressed in world space coordinates, so its value may vary.
  73610. * Initilized with the intersectionThreshold value of the source LinesMesh
  73611. */
  73612. intersectionThreshold: number;
  73613. constructor(name: string, source: LinesMesh);
  73614. /**
  73615. * Returns the string "InstancedLinesMesh".
  73616. */
  73617. getClassName(): string;
  73618. }
  73619. }
  73620. declare module BABYLON {
  73621. /** @hidden */
  73622. export var linePixelShader: {
  73623. name: string;
  73624. shader: string;
  73625. };
  73626. }
  73627. declare module BABYLON {
  73628. /** @hidden */
  73629. export var lineVertexShader: {
  73630. name: string;
  73631. shader: string;
  73632. };
  73633. }
  73634. declare module BABYLON {
  73635. interface AbstractMesh {
  73636. /**
  73637. * Disables the mesh edge rendering mode
  73638. * @returns the currentAbstractMesh
  73639. */
  73640. disableEdgesRendering(): AbstractMesh;
  73641. /**
  73642. * Enables the edge rendering mode on the mesh.
  73643. * This mode makes the mesh edges visible
  73644. * @param epsilon defines the maximal distance between two angles to detect a face
  73645. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  73646. * @returns the currentAbstractMesh
  73647. * @see https://www.babylonjs-playground.com/#19O9TU#0
  73648. */
  73649. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  73650. /**
  73651. * Gets the edgesRenderer associated with the mesh
  73652. */
  73653. edgesRenderer: Nullable<EdgesRenderer>;
  73654. }
  73655. interface LinesMesh {
  73656. /**
  73657. * Enables the edge rendering mode on the mesh.
  73658. * This mode makes the mesh edges visible
  73659. * @param epsilon defines the maximal distance between two angles to detect a face
  73660. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  73661. * @returns the currentAbstractMesh
  73662. * @see https://www.babylonjs-playground.com/#19O9TU#0
  73663. */
  73664. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  73665. }
  73666. interface InstancedLinesMesh {
  73667. /**
  73668. * Enables the edge rendering mode on the mesh.
  73669. * This mode makes the mesh edges visible
  73670. * @param epsilon defines the maximal distance between two angles to detect a face
  73671. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  73672. * @returns the current InstancedLinesMesh
  73673. * @see https://www.babylonjs-playground.com/#19O9TU#0
  73674. */
  73675. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  73676. }
  73677. /**
  73678. * Defines the minimum contract an Edges renderer should follow.
  73679. */
  73680. export interface IEdgesRenderer extends IDisposable {
  73681. /**
  73682. * Gets or sets a boolean indicating if the edgesRenderer is active
  73683. */
  73684. isEnabled: boolean;
  73685. /**
  73686. * Renders the edges of the attached mesh,
  73687. */
  73688. render(): void;
  73689. /**
  73690. * Checks wether or not the edges renderer is ready to render.
  73691. * @return true if ready, otherwise false.
  73692. */
  73693. isReady(): boolean;
  73694. }
  73695. /**
  73696. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  73697. */
  73698. export class EdgesRenderer implements IEdgesRenderer {
  73699. /**
  73700. * Define the size of the edges with an orthographic camera
  73701. */
  73702. edgesWidthScalerForOrthographic: number;
  73703. /**
  73704. * Define the size of the edges with a perspective camera
  73705. */
  73706. edgesWidthScalerForPerspective: number;
  73707. protected _source: AbstractMesh;
  73708. protected _linesPositions: number[];
  73709. protected _linesNormals: number[];
  73710. protected _linesIndices: number[];
  73711. protected _epsilon: number;
  73712. protected _indicesCount: number;
  73713. protected _lineShader: ShaderMaterial;
  73714. protected _ib: WebGLBuffer;
  73715. protected _buffers: {
  73716. [key: string]: Nullable<VertexBuffer>;
  73717. };
  73718. protected _checkVerticesInsteadOfIndices: boolean;
  73719. private _meshRebuildObserver;
  73720. private _meshDisposeObserver;
  73721. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  73722. isEnabled: boolean;
  73723. /**
  73724. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  73725. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  73726. * @param source Mesh used to create edges
  73727. * @param epsilon sum of angles in adjacency to check for edge
  73728. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  73729. * @param generateEdgesLines - should generate Lines or only prepare resources.
  73730. */
  73731. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  73732. protected _prepareRessources(): void;
  73733. /** @hidden */
  73734. _rebuild(): void;
  73735. /**
  73736. * Releases the required resources for the edges renderer
  73737. */
  73738. dispose(): void;
  73739. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  73740. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  73741. /**
  73742. * Checks if the pair of p0 and p1 is en edge
  73743. * @param faceIndex
  73744. * @param edge
  73745. * @param faceNormals
  73746. * @param p0
  73747. * @param p1
  73748. * @private
  73749. */
  73750. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  73751. /**
  73752. * push line into the position, normal and index buffer
  73753. * @protected
  73754. */
  73755. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  73756. /**
  73757. * Generates lines edges from adjacencjes
  73758. * @private
  73759. */
  73760. _generateEdgesLines(): void;
  73761. /**
  73762. * Checks wether or not the edges renderer is ready to render.
  73763. * @return true if ready, otherwise false.
  73764. */
  73765. isReady(): boolean;
  73766. /**
  73767. * Renders the edges of the attached mesh,
  73768. */
  73769. render(): void;
  73770. }
  73771. /**
  73772. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  73773. */
  73774. export class LineEdgesRenderer extends EdgesRenderer {
  73775. /**
  73776. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  73777. * @param source LineMesh used to generate edges
  73778. * @param epsilon not important (specified angle for edge detection)
  73779. * @param checkVerticesInsteadOfIndices not important for LineMesh
  73780. */
  73781. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  73782. /**
  73783. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  73784. */
  73785. _generateEdgesLines(): void;
  73786. }
  73787. }
  73788. declare module BABYLON {
  73789. /**
  73790. * This represents the object necessary to create a rendering group.
  73791. * This is exclusively used and created by the rendering manager.
  73792. * To modify the behavior, you use the available helpers in your scene or meshes.
  73793. * @hidden
  73794. */
  73795. export class RenderingGroup {
  73796. index: number;
  73797. private _scene;
  73798. private _opaqueSubMeshes;
  73799. private _transparentSubMeshes;
  73800. private _alphaTestSubMeshes;
  73801. private _depthOnlySubMeshes;
  73802. private _particleSystems;
  73803. private _spriteManagers;
  73804. private _opaqueSortCompareFn;
  73805. private _alphaTestSortCompareFn;
  73806. private _transparentSortCompareFn;
  73807. private _renderOpaque;
  73808. private _renderAlphaTest;
  73809. private _renderTransparent;
  73810. private _edgesRenderers;
  73811. onBeforeTransparentRendering: () => void;
  73812. /**
  73813. * Set the opaque sort comparison function.
  73814. * If null the sub meshes will be render in the order they were created
  73815. */
  73816. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  73817. /**
  73818. * Set the alpha test sort comparison function.
  73819. * If null the sub meshes will be render in the order they were created
  73820. */
  73821. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  73822. /**
  73823. * Set the transparent sort comparison function.
  73824. * If null the sub meshes will be render in the order they were created
  73825. */
  73826. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  73827. /**
  73828. * Creates a new rendering group.
  73829. * @param index The rendering group index
  73830. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  73831. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  73832. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  73833. */
  73834. 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>);
  73835. /**
  73836. * Render all the sub meshes contained in the group.
  73837. * @param customRenderFunction Used to override the default render behaviour of the group.
  73838. * @returns true if rendered some submeshes.
  73839. */
  73840. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  73841. /**
  73842. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  73843. * @param subMeshes The submeshes to render
  73844. */
  73845. private renderOpaqueSorted;
  73846. /**
  73847. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  73848. * @param subMeshes The submeshes to render
  73849. */
  73850. private renderAlphaTestSorted;
  73851. /**
  73852. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  73853. * @param subMeshes The submeshes to render
  73854. */
  73855. private renderTransparentSorted;
  73856. /**
  73857. * Renders the submeshes in a specified order.
  73858. * @param subMeshes The submeshes to sort before render
  73859. * @param sortCompareFn The comparison function use to sort
  73860. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  73861. * @param transparent Specifies to activate blending if true
  73862. */
  73863. private static renderSorted;
  73864. /**
  73865. * Renders the submeshes in the order they were dispatched (no sort applied).
  73866. * @param subMeshes The submeshes to render
  73867. */
  73868. private static renderUnsorted;
  73869. /**
  73870. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  73871. * are rendered back to front if in the same alpha index.
  73872. *
  73873. * @param a The first submesh
  73874. * @param b The second submesh
  73875. * @returns The result of the comparison
  73876. */
  73877. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  73878. /**
  73879. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  73880. * are rendered back to front.
  73881. *
  73882. * @param a The first submesh
  73883. * @param b The second submesh
  73884. * @returns The result of the comparison
  73885. */
  73886. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  73887. /**
  73888. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  73889. * are rendered front to back (prevent overdraw).
  73890. *
  73891. * @param a The first submesh
  73892. * @param b The second submesh
  73893. * @returns The result of the comparison
  73894. */
  73895. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  73896. /**
  73897. * Resets the different lists of submeshes to prepare a new frame.
  73898. */
  73899. prepare(): void;
  73900. dispose(): void;
  73901. /**
  73902. * Inserts the submesh in its correct queue depending on its material.
  73903. * @param subMesh The submesh to dispatch
  73904. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  73905. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  73906. */
  73907. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  73908. dispatchSprites(spriteManager: ISpriteManager): void;
  73909. dispatchParticles(particleSystem: IParticleSystem): void;
  73910. private _renderParticles;
  73911. private _renderSprites;
  73912. }
  73913. }
  73914. declare module BABYLON {
  73915. /**
  73916. * Interface describing the different options available in the rendering manager
  73917. * regarding Auto Clear between groups.
  73918. */
  73919. export interface IRenderingManagerAutoClearSetup {
  73920. /**
  73921. * Defines whether or not autoclear is enable.
  73922. */
  73923. autoClear: boolean;
  73924. /**
  73925. * Defines whether or not to autoclear the depth buffer.
  73926. */
  73927. depth: boolean;
  73928. /**
  73929. * Defines whether or not to autoclear the stencil buffer.
  73930. */
  73931. stencil: boolean;
  73932. }
  73933. /**
  73934. * This class is used by the onRenderingGroupObservable
  73935. */
  73936. export class RenderingGroupInfo {
  73937. /**
  73938. * The Scene that being rendered
  73939. */
  73940. scene: Scene;
  73941. /**
  73942. * The camera currently used for the rendering pass
  73943. */
  73944. camera: Nullable<Camera>;
  73945. /**
  73946. * The ID of the renderingGroup being processed
  73947. */
  73948. renderingGroupId: number;
  73949. }
  73950. /**
  73951. * This is the manager responsible of all the rendering for meshes sprites and particles.
  73952. * It is enable to manage the different groups as well as the different necessary sort functions.
  73953. * This should not be used directly aside of the few static configurations
  73954. */
  73955. export class RenderingManager {
  73956. /**
  73957. * The max id used for rendering groups (not included)
  73958. */
  73959. static MAX_RENDERINGGROUPS: number;
  73960. /**
  73961. * The min id used for rendering groups (included)
  73962. */
  73963. static MIN_RENDERINGGROUPS: number;
  73964. /**
  73965. * Used to globally prevent autoclearing scenes.
  73966. */
  73967. static AUTOCLEAR: boolean;
  73968. /**
  73969. * @hidden
  73970. */
  73971. _useSceneAutoClearSetup: boolean;
  73972. private _scene;
  73973. private _renderingGroups;
  73974. private _depthStencilBufferAlreadyCleaned;
  73975. private _autoClearDepthStencil;
  73976. private _customOpaqueSortCompareFn;
  73977. private _customAlphaTestSortCompareFn;
  73978. private _customTransparentSortCompareFn;
  73979. private _renderingGroupInfo;
  73980. /**
  73981. * Instantiates a new rendering group for a particular scene
  73982. * @param scene Defines the scene the groups belongs to
  73983. */
  73984. constructor(scene: Scene);
  73985. private _clearDepthStencilBuffer;
  73986. /**
  73987. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  73988. * @hidden
  73989. */
  73990. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  73991. /**
  73992. * Resets the different information of the group to prepare a new frame
  73993. * @hidden
  73994. */
  73995. reset(): void;
  73996. /**
  73997. * Dispose and release the group and its associated resources.
  73998. * @hidden
  73999. */
  74000. dispose(): void;
  74001. /**
  74002. * Clear the info related to rendering groups preventing retention points during dispose.
  74003. */
  74004. freeRenderingGroups(): void;
  74005. private _prepareRenderingGroup;
  74006. /**
  74007. * Add a sprite manager to the rendering manager in order to render it this frame.
  74008. * @param spriteManager Define the sprite manager to render
  74009. */
  74010. dispatchSprites(spriteManager: ISpriteManager): void;
  74011. /**
  74012. * Add a particle system to the rendering manager in order to render it this frame.
  74013. * @param particleSystem Define the particle system to render
  74014. */
  74015. dispatchParticles(particleSystem: IParticleSystem): void;
  74016. /**
  74017. * Add a submesh to the manager in order to render it this frame
  74018. * @param subMesh The submesh to dispatch
  74019. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  74020. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  74021. */
  74022. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  74023. /**
  74024. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  74025. * This allowed control for front to back rendering or reversly depending of the special needs.
  74026. *
  74027. * @param renderingGroupId The rendering group id corresponding to its index
  74028. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  74029. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  74030. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  74031. */
  74032. 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;
  74033. /**
  74034. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  74035. *
  74036. * @param renderingGroupId The rendering group id corresponding to its index
  74037. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  74038. * @param depth Automatically clears depth between groups if true and autoClear is true.
  74039. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  74040. */
  74041. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  74042. /**
  74043. * Gets the current auto clear configuration for one rendering group of the rendering
  74044. * manager.
  74045. * @param index the rendering group index to get the information for
  74046. * @returns The auto clear setup for the requested rendering group
  74047. */
  74048. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  74049. }
  74050. }
  74051. declare module BABYLON {
  74052. /**
  74053. * This Helps creating a texture that will be created from a camera in your scene.
  74054. * It is basically a dynamic texture that could be used to create special effects for instance.
  74055. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  74056. */
  74057. export class RenderTargetTexture extends Texture {
  74058. isCube: boolean;
  74059. /**
  74060. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  74061. */
  74062. static readonly REFRESHRATE_RENDER_ONCE: number;
  74063. /**
  74064. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  74065. */
  74066. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  74067. /**
  74068. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  74069. * the central point of your effect and can save a lot of performances.
  74070. */
  74071. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  74072. /**
  74073. * Use this predicate to dynamically define the list of mesh you want to render.
  74074. * If set, the renderList property will be overwritten.
  74075. */
  74076. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  74077. private _renderList;
  74078. /**
  74079. * Use this list to define the list of mesh you want to render.
  74080. */
  74081. renderList: Nullable<Array<AbstractMesh>>;
  74082. private _hookArray;
  74083. /**
  74084. * Define if particles should be rendered in your texture.
  74085. */
  74086. renderParticles: boolean;
  74087. /**
  74088. * Define if sprites should be rendered in your texture.
  74089. */
  74090. renderSprites: boolean;
  74091. /**
  74092. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  74093. */
  74094. coordinatesMode: number;
  74095. /**
  74096. * Define the camera used to render the texture.
  74097. */
  74098. activeCamera: Nullable<Camera>;
  74099. /**
  74100. * Override the render function of the texture with your own one.
  74101. */
  74102. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  74103. /**
  74104. * Define if camera post processes should be use while rendering the texture.
  74105. */
  74106. useCameraPostProcesses: boolean;
  74107. /**
  74108. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  74109. */
  74110. ignoreCameraViewport: boolean;
  74111. private _postProcessManager;
  74112. private _postProcesses;
  74113. private _resizeObserver;
  74114. /**
  74115. * An event triggered when the texture is unbind.
  74116. */
  74117. onBeforeBindObservable: Observable<RenderTargetTexture>;
  74118. /**
  74119. * An event triggered when the texture is unbind.
  74120. */
  74121. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  74122. private _onAfterUnbindObserver;
  74123. /**
  74124. * Set a after unbind callback in the texture.
  74125. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  74126. */
  74127. onAfterUnbind: () => void;
  74128. /**
  74129. * An event triggered before rendering the texture
  74130. */
  74131. onBeforeRenderObservable: Observable<number>;
  74132. private _onBeforeRenderObserver;
  74133. /**
  74134. * Set a before render callback in the texture.
  74135. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  74136. */
  74137. onBeforeRender: (faceIndex: number) => void;
  74138. /**
  74139. * An event triggered after rendering the texture
  74140. */
  74141. onAfterRenderObservable: Observable<number>;
  74142. private _onAfterRenderObserver;
  74143. /**
  74144. * Set a after render callback in the texture.
  74145. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  74146. */
  74147. onAfterRender: (faceIndex: number) => void;
  74148. /**
  74149. * An event triggered after the texture clear
  74150. */
  74151. onClearObservable: Observable<Engine>;
  74152. private _onClearObserver;
  74153. /**
  74154. * Set a clear callback in the texture.
  74155. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  74156. */
  74157. onClear: (Engine: Engine) => void;
  74158. /**
  74159. * Define the clear color of the Render Target if it should be different from the scene.
  74160. */
  74161. clearColor: Color4;
  74162. protected _size: number | {
  74163. width: number;
  74164. height: number;
  74165. };
  74166. protected _initialSizeParameter: number | {
  74167. width: number;
  74168. height: number;
  74169. } | {
  74170. ratio: number;
  74171. };
  74172. protected _sizeRatio: Nullable<number>;
  74173. /** @hidden */
  74174. _generateMipMaps: boolean;
  74175. protected _renderingManager: RenderingManager;
  74176. /** @hidden */
  74177. _waitingRenderList: string[];
  74178. protected _doNotChangeAspectRatio: boolean;
  74179. protected _currentRefreshId: number;
  74180. protected _refreshRate: number;
  74181. protected _textureMatrix: Matrix;
  74182. protected _samples: number;
  74183. protected _renderTargetOptions: RenderTargetCreationOptions;
  74184. /**
  74185. * Gets render target creation options that were used.
  74186. */
  74187. readonly renderTargetOptions: RenderTargetCreationOptions;
  74188. protected _engine: Engine;
  74189. protected _onRatioRescale(): void;
  74190. /**
  74191. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  74192. * It must define where the camera used to render the texture is set
  74193. */
  74194. boundingBoxPosition: Vector3;
  74195. private _boundingBoxSize;
  74196. /**
  74197. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  74198. * When defined, the cubemap will switch to local mode
  74199. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  74200. * @example https://www.babylonjs-playground.com/#RNASML
  74201. */
  74202. boundingBoxSize: Vector3;
  74203. /**
  74204. * In case the RTT has been created with a depth texture, get the associated
  74205. * depth texture.
  74206. * Otherwise, return null.
  74207. */
  74208. depthStencilTexture: Nullable<InternalTexture>;
  74209. /**
  74210. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  74211. * or used a shadow, depth texture...
  74212. * @param name The friendly name of the texture
  74213. * @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)
  74214. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  74215. * @param generateMipMaps True if mip maps need to be generated after render.
  74216. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  74217. * @param type The type of the buffer in the RTT (int, half float, float...)
  74218. * @param isCube True if a cube texture needs to be created
  74219. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  74220. * @param generateDepthBuffer True to generate a depth buffer
  74221. * @param generateStencilBuffer True to generate a stencil buffer
  74222. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  74223. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  74224. * @param delayAllocation if the texture allocation should be delayed (default: false)
  74225. */
  74226. constructor(name: string, size: number | {
  74227. width: number;
  74228. height: number;
  74229. } | {
  74230. ratio: number;
  74231. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  74232. /**
  74233. * Creates a depth stencil texture.
  74234. * This is only available in WebGL 2 or with the depth texture extension available.
  74235. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  74236. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  74237. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  74238. */
  74239. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  74240. private _processSizeParameter;
  74241. /**
  74242. * Define the number of samples to use in case of MSAA.
  74243. * It defaults to one meaning no MSAA has been enabled.
  74244. */
  74245. samples: number;
  74246. /**
  74247. * Resets the refresh counter of the texture and start bak from scratch.
  74248. * Could be useful to regenerate the texture if it is setup to render only once.
  74249. */
  74250. resetRefreshCounter(): void;
  74251. /**
  74252. * Define the refresh rate of the texture or the rendering frequency.
  74253. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  74254. */
  74255. refreshRate: number;
  74256. /**
  74257. * Adds a post process to the render target rendering passes.
  74258. * @param postProcess define the post process to add
  74259. */
  74260. addPostProcess(postProcess: PostProcess): void;
  74261. /**
  74262. * Clear all the post processes attached to the render target
  74263. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  74264. */
  74265. clearPostProcesses(dispose?: boolean): void;
  74266. /**
  74267. * Remove one of the post process from the list of attached post processes to the texture
  74268. * @param postProcess define the post process to remove from the list
  74269. */
  74270. removePostProcess(postProcess: PostProcess): void;
  74271. /** @hidden */
  74272. _shouldRender(): boolean;
  74273. /**
  74274. * Gets the actual render size of the texture.
  74275. * @returns the width of the render size
  74276. */
  74277. getRenderSize(): number;
  74278. /**
  74279. * Gets the actual render width of the texture.
  74280. * @returns the width of the render size
  74281. */
  74282. getRenderWidth(): number;
  74283. /**
  74284. * Gets the actual render height of the texture.
  74285. * @returns the height of the render size
  74286. */
  74287. getRenderHeight(): number;
  74288. /**
  74289. * Get if the texture can be rescaled or not.
  74290. */
  74291. readonly canRescale: boolean;
  74292. /**
  74293. * Resize the texture using a ratio.
  74294. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  74295. */
  74296. scale(ratio: number): void;
  74297. /**
  74298. * Get the texture reflection matrix used to rotate/transform the reflection.
  74299. * @returns the reflection matrix
  74300. */
  74301. getReflectionTextureMatrix(): Matrix;
  74302. /**
  74303. * Resize the texture to a new desired size.
  74304. * Be carrefull as it will recreate all the data in the new texture.
  74305. * @param size Define the new size. It can be:
  74306. * - a number for squared texture,
  74307. * - an object containing { width: number, height: number }
  74308. * - or an object containing a ratio { ratio: number }
  74309. */
  74310. resize(size: number | {
  74311. width: number;
  74312. height: number;
  74313. } | {
  74314. ratio: number;
  74315. }): void;
  74316. /**
  74317. * Renders all the objects from the render list into the texture.
  74318. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  74319. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  74320. */
  74321. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  74322. private _bestReflectionRenderTargetDimension;
  74323. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  74324. private renderToTarget;
  74325. /**
  74326. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  74327. * This allowed control for front to back rendering or reversly depending of the special needs.
  74328. *
  74329. * @param renderingGroupId The rendering group id corresponding to its index
  74330. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  74331. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  74332. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  74333. */
  74334. 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;
  74335. /**
  74336. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  74337. *
  74338. * @param renderingGroupId The rendering group id corresponding to its index
  74339. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  74340. */
  74341. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  74342. /**
  74343. * Clones the texture.
  74344. * @returns the cloned texture
  74345. */
  74346. clone(): RenderTargetTexture;
  74347. /**
  74348. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  74349. * @returns The JSON representation of the texture
  74350. */
  74351. serialize(): any;
  74352. /**
  74353. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  74354. */
  74355. disposeFramebufferObjects(): void;
  74356. /**
  74357. * Dispose the texture and release its associated resources.
  74358. */
  74359. dispose(): void;
  74360. /** @hidden */
  74361. _rebuild(): void;
  74362. /**
  74363. * Clear the info related to rendering groups preventing retention point in material dispose.
  74364. */
  74365. freeRenderingGroups(): void;
  74366. }
  74367. }
  74368. declare module BABYLON {
  74369. /**
  74370. * Mirror texture can be used to simulate the view from a mirror in a scene.
  74371. * It will dynamically be rendered every frame to adapt to the camera point of view.
  74372. * You can then easily use it as a reflectionTexture on a flat surface.
  74373. * In case the surface is not a plane, please consider relying on reflection probes.
  74374. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  74375. */
  74376. export class MirrorTexture extends RenderTargetTexture {
  74377. private scene;
  74378. /**
  74379. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  74380. * 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.
  74381. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  74382. */
  74383. mirrorPlane: Plane;
  74384. /**
  74385. * Define the blur ratio used to blur the reflection if needed.
  74386. */
  74387. blurRatio: number;
  74388. /**
  74389. * Define the adaptive blur kernel used to blur the reflection if needed.
  74390. * This will autocompute the closest best match for the `blurKernel`
  74391. */
  74392. adaptiveBlurKernel: number;
  74393. /**
  74394. * Define the blur kernel used to blur the reflection if needed.
  74395. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  74396. */
  74397. blurKernel: number;
  74398. /**
  74399. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  74400. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  74401. */
  74402. blurKernelX: number;
  74403. /**
  74404. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  74405. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  74406. */
  74407. blurKernelY: number;
  74408. private _autoComputeBlurKernel;
  74409. protected _onRatioRescale(): void;
  74410. private _updateGammaSpace;
  74411. private _imageProcessingConfigChangeObserver;
  74412. private _transformMatrix;
  74413. private _mirrorMatrix;
  74414. private _savedViewMatrix;
  74415. private _blurX;
  74416. private _blurY;
  74417. private _adaptiveBlurKernel;
  74418. private _blurKernelX;
  74419. private _blurKernelY;
  74420. private _blurRatio;
  74421. /**
  74422. * Instantiates a Mirror Texture.
  74423. * Mirror texture can be used to simulate the view from a mirror in a scene.
  74424. * It will dynamically be rendered every frame to adapt to the camera point of view.
  74425. * You can then easily use it as a reflectionTexture on a flat surface.
  74426. * In case the surface is not a plane, please consider relying on reflection probes.
  74427. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  74428. * @param name
  74429. * @param size
  74430. * @param scene
  74431. * @param generateMipMaps
  74432. * @param type
  74433. * @param samplingMode
  74434. * @param generateDepthBuffer
  74435. */
  74436. constructor(name: string, size: number | {
  74437. width: number;
  74438. height: number;
  74439. } | {
  74440. ratio: number;
  74441. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  74442. private _preparePostProcesses;
  74443. /**
  74444. * Clone the mirror texture.
  74445. * @returns the cloned texture
  74446. */
  74447. clone(): MirrorTexture;
  74448. /**
  74449. * Serialize the texture to a JSON representation you could use in Parse later on
  74450. * @returns the serialized JSON representation
  74451. */
  74452. serialize(): any;
  74453. /**
  74454. * Dispose the texture and release its associated resources.
  74455. */
  74456. dispose(): void;
  74457. }
  74458. }
  74459. declare module BABYLON {
  74460. /**
  74461. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  74462. * @see http://doc.babylonjs.com/babylon101/materials#texture
  74463. */
  74464. export class Texture extends BaseTexture {
  74465. /** @hidden */
  74466. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  74467. /** @hidden */
  74468. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  74469. /** @hidden */
  74470. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  74471. /** nearest is mag = nearest and min = nearest and mip = linear */
  74472. static readonly NEAREST_SAMPLINGMODE: number;
  74473. /** nearest is mag = nearest and min = nearest and mip = linear */
  74474. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  74475. /** Bilinear is mag = linear and min = linear and mip = nearest */
  74476. static readonly BILINEAR_SAMPLINGMODE: number;
  74477. /** Bilinear is mag = linear and min = linear and mip = nearest */
  74478. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  74479. /** Trilinear is mag = linear and min = linear and mip = linear */
  74480. static readonly TRILINEAR_SAMPLINGMODE: number;
  74481. /** Trilinear is mag = linear and min = linear and mip = linear */
  74482. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  74483. /** mag = nearest and min = nearest and mip = nearest */
  74484. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  74485. /** mag = nearest and min = linear and mip = nearest */
  74486. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  74487. /** mag = nearest and min = linear and mip = linear */
  74488. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  74489. /** mag = nearest and min = linear and mip = none */
  74490. static readonly NEAREST_LINEAR: number;
  74491. /** mag = nearest and min = nearest and mip = none */
  74492. static readonly NEAREST_NEAREST: number;
  74493. /** mag = linear and min = nearest and mip = nearest */
  74494. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  74495. /** mag = linear and min = nearest and mip = linear */
  74496. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  74497. /** mag = linear and min = linear and mip = none */
  74498. static readonly LINEAR_LINEAR: number;
  74499. /** mag = linear and min = nearest and mip = none */
  74500. static readonly LINEAR_NEAREST: number;
  74501. /** Explicit coordinates mode */
  74502. static readonly EXPLICIT_MODE: number;
  74503. /** Spherical coordinates mode */
  74504. static readonly SPHERICAL_MODE: number;
  74505. /** Planar coordinates mode */
  74506. static readonly PLANAR_MODE: number;
  74507. /** Cubic coordinates mode */
  74508. static readonly CUBIC_MODE: number;
  74509. /** Projection coordinates mode */
  74510. static readonly PROJECTION_MODE: number;
  74511. /** Inverse Cubic coordinates mode */
  74512. static readonly SKYBOX_MODE: number;
  74513. /** Inverse Cubic coordinates mode */
  74514. static readonly INVCUBIC_MODE: number;
  74515. /** Equirectangular coordinates mode */
  74516. static readonly EQUIRECTANGULAR_MODE: number;
  74517. /** Equirectangular Fixed coordinates mode */
  74518. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  74519. /** Equirectangular Fixed Mirrored coordinates mode */
  74520. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  74521. /** Texture is not repeating outside of 0..1 UVs */
  74522. static readonly CLAMP_ADDRESSMODE: number;
  74523. /** Texture is repeating outside of 0..1 UVs */
  74524. static readonly WRAP_ADDRESSMODE: number;
  74525. /** Texture is repeating and mirrored */
  74526. static readonly MIRROR_ADDRESSMODE: number;
  74527. /**
  74528. * 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
  74529. */
  74530. static UseSerializedUrlIfAny: boolean;
  74531. /**
  74532. * Define the url of the texture.
  74533. */
  74534. url: Nullable<string>;
  74535. /**
  74536. * Define an offset on the texture to offset the u coordinates of the UVs
  74537. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  74538. */
  74539. uOffset: number;
  74540. /**
  74541. * Define an offset on the texture to offset the v coordinates of the UVs
  74542. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  74543. */
  74544. vOffset: number;
  74545. /**
  74546. * Define an offset on the texture to scale the u coordinates of the UVs
  74547. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  74548. */
  74549. uScale: number;
  74550. /**
  74551. * Define an offset on the texture to scale the v coordinates of the UVs
  74552. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  74553. */
  74554. vScale: number;
  74555. /**
  74556. * Define an offset on the texture to rotate around the u coordinates of the UVs
  74557. * @see http://doc.babylonjs.com/how_to/more_materials
  74558. */
  74559. uAng: number;
  74560. /**
  74561. * Define an offset on the texture to rotate around the v coordinates of the UVs
  74562. * @see http://doc.babylonjs.com/how_to/more_materials
  74563. */
  74564. vAng: number;
  74565. /**
  74566. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  74567. * @see http://doc.babylonjs.com/how_to/more_materials
  74568. */
  74569. wAng: number;
  74570. /**
  74571. * Defines the center of rotation (U)
  74572. */
  74573. uRotationCenter: number;
  74574. /**
  74575. * Defines the center of rotation (V)
  74576. */
  74577. vRotationCenter: number;
  74578. /**
  74579. * Defines the center of rotation (W)
  74580. */
  74581. wRotationCenter: number;
  74582. /**
  74583. * Are mip maps generated for this texture or not.
  74584. */
  74585. readonly noMipmap: boolean;
  74586. private _noMipmap;
  74587. /** @hidden */
  74588. _invertY: boolean;
  74589. private _rowGenerationMatrix;
  74590. private _cachedTextureMatrix;
  74591. private _projectionModeMatrix;
  74592. private _t0;
  74593. private _t1;
  74594. private _t2;
  74595. private _cachedUOffset;
  74596. private _cachedVOffset;
  74597. private _cachedUScale;
  74598. private _cachedVScale;
  74599. private _cachedUAng;
  74600. private _cachedVAng;
  74601. private _cachedWAng;
  74602. private _cachedProjectionMatrixId;
  74603. private _cachedCoordinatesMode;
  74604. /** @hidden */
  74605. protected _initialSamplingMode: number;
  74606. /** @hidden */
  74607. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  74608. private _deleteBuffer;
  74609. protected _format: Nullable<number>;
  74610. private _delayedOnLoad;
  74611. private _delayedOnError;
  74612. /**
  74613. * Observable triggered once the texture has been loaded.
  74614. */
  74615. onLoadObservable: Observable<Texture>;
  74616. protected _isBlocking: boolean;
  74617. /**
  74618. * Is the texture preventing material to render while loading.
  74619. * If false, a default texture will be used instead of the loading one during the preparation step.
  74620. */
  74621. isBlocking: boolean;
  74622. /**
  74623. * Get the current sampling mode associated with the texture.
  74624. */
  74625. readonly samplingMode: number;
  74626. /**
  74627. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  74628. */
  74629. readonly invertY: boolean;
  74630. /**
  74631. * Instantiates a new texture.
  74632. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  74633. * @see http://doc.babylonjs.com/babylon101/materials#texture
  74634. * @param url define the url of the picture to load as a texture
  74635. * @param scene define the scene the texture will belong to
  74636. * @param noMipmap define if the texture will require mip maps or not
  74637. * @param invertY define if the texture needs to be inverted on the y axis during loading
  74638. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  74639. * @param onLoad define a callback triggered when the texture has been loaded
  74640. * @param onError define a callback triggered when an error occurred during the loading session
  74641. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  74642. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  74643. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  74644. */
  74645. 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);
  74646. /**
  74647. * Update the url (and optional buffer) of this texture if url was null during construction.
  74648. * @param url the url of the texture
  74649. * @param buffer the buffer of the texture (defaults to null)
  74650. * @param onLoad callback called when the texture is loaded (defaults to null)
  74651. */
  74652. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  74653. /**
  74654. * Finish the loading sequence of a texture flagged as delayed load.
  74655. * @hidden
  74656. */
  74657. delayLoad(): void;
  74658. private _prepareRowForTextureGeneration;
  74659. /**
  74660. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  74661. * @returns the transform matrix of the texture.
  74662. */
  74663. getTextureMatrix(): Matrix;
  74664. /**
  74665. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  74666. * @returns The reflection texture transform
  74667. */
  74668. getReflectionTextureMatrix(): Matrix;
  74669. /**
  74670. * Clones the texture.
  74671. * @returns the cloned texture
  74672. */
  74673. clone(): Texture;
  74674. /**
  74675. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  74676. * @returns The JSON representation of the texture
  74677. */
  74678. serialize(): any;
  74679. /**
  74680. * Get the current class name of the texture useful for serialization or dynamic coding.
  74681. * @returns "Texture"
  74682. */
  74683. getClassName(): string;
  74684. /**
  74685. * Dispose the texture and release its associated resources.
  74686. */
  74687. dispose(): void;
  74688. /**
  74689. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  74690. * @param parsedTexture Define the JSON representation of the texture
  74691. * @param scene Define the scene the parsed texture should be instantiated in
  74692. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  74693. * @returns The parsed texture if successful
  74694. */
  74695. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  74696. /**
  74697. * Creates a texture from its base 64 representation.
  74698. * @param data Define the base64 payload without the data: prefix
  74699. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  74700. * @param scene Define the scene the texture should belong to
  74701. * @param noMipmap Forces the texture to not create mip map information if true
  74702. * @param invertY define if the texture needs to be inverted on the y axis during loading
  74703. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  74704. * @param onLoad define a callback triggered when the texture has been loaded
  74705. * @param onError define a callback triggered when an error occurred during the loading session
  74706. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  74707. * @returns the created texture
  74708. */
  74709. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  74710. /**
  74711. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  74712. * @param data Define the base64 payload without the data: prefix
  74713. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  74714. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  74715. * @param scene Define the scene the texture should belong to
  74716. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  74717. * @param noMipmap Forces the texture to not create mip map information if true
  74718. * @param invertY define if the texture needs to be inverted on the y axis during loading
  74719. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  74720. * @param onLoad define a callback triggered when the texture has been loaded
  74721. * @param onError define a callback triggered when an error occurred during the loading session
  74722. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  74723. * @returns the created texture
  74724. */
  74725. 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;
  74726. }
  74727. }
  74728. declare module BABYLON {
  74729. /**
  74730. * Raw texture can help creating a texture directly from an array of data.
  74731. * This can be super useful if you either get the data from an uncompressed source or
  74732. * if you wish to create your texture pixel by pixel.
  74733. */
  74734. export class RawTexture extends Texture {
  74735. /**
  74736. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  74737. */
  74738. format: number;
  74739. private _engine;
  74740. /**
  74741. * Instantiates a new RawTexture.
  74742. * Raw texture can help creating a texture directly from an array of data.
  74743. * This can be super useful if you either get the data from an uncompressed source or
  74744. * if you wish to create your texture pixel by pixel.
  74745. * @param data define the array of data to use to create the texture
  74746. * @param width define the width of the texture
  74747. * @param height define the height of the texture
  74748. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  74749. * @param scene define the scene the texture belongs to
  74750. * @param generateMipMaps define whether mip maps should be generated or not
  74751. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  74752. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  74753. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  74754. */
  74755. constructor(data: ArrayBufferView, width: number, height: number,
  74756. /**
  74757. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  74758. */
  74759. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  74760. /**
  74761. * Updates the texture underlying data.
  74762. * @param data Define the new data of the texture
  74763. */
  74764. update(data: ArrayBufferView): void;
  74765. /**
  74766. * Creates a luminance texture from some data.
  74767. * @param data Define the texture data
  74768. * @param width Define the width of the texture
  74769. * @param height Define the height of the texture
  74770. * @param scene Define the scene the texture belongs to
  74771. * @param generateMipMaps Define whether or not to create mip maps for the texture
  74772. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  74773. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  74774. * @returns the luminance texture
  74775. */
  74776. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  74777. /**
  74778. * Creates a luminance alpha texture from some data.
  74779. * @param data Define the texture data
  74780. * @param width Define the width of the texture
  74781. * @param height Define the height of the texture
  74782. * @param scene Define the scene the texture belongs to
  74783. * @param generateMipMaps Define whether or not to create mip maps for the texture
  74784. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  74785. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  74786. * @returns the luminance alpha texture
  74787. */
  74788. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  74789. /**
  74790. * Creates an alpha texture from some data.
  74791. * @param data Define the texture data
  74792. * @param width Define the width of the texture
  74793. * @param height Define the height of the texture
  74794. * @param scene Define the scene the texture belongs to
  74795. * @param generateMipMaps Define whether or not to create mip maps for the texture
  74796. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  74797. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  74798. * @returns the alpha texture
  74799. */
  74800. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  74801. /**
  74802. * Creates a RGB texture from some data.
  74803. * @param data Define the texture data
  74804. * @param width Define the width of the texture
  74805. * @param height Define the height of the texture
  74806. * @param scene Define the scene the texture belongs to
  74807. * @param generateMipMaps Define whether or not to create mip maps for the texture
  74808. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  74809. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  74810. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  74811. * @returns the RGB alpha texture
  74812. */
  74813. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  74814. /**
  74815. * Creates a RGBA texture from some data.
  74816. * @param data Define the texture data
  74817. * @param width Define the width of the texture
  74818. * @param height Define the height of the texture
  74819. * @param scene Define the scene the texture belongs to
  74820. * @param generateMipMaps Define whether or not to create mip maps for the texture
  74821. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  74822. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  74823. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  74824. * @returns the RGBA texture
  74825. */
  74826. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  74827. /**
  74828. * Creates a R texture from some data.
  74829. * @param data Define the texture data
  74830. * @param width Define the width of the texture
  74831. * @param height Define the height of the texture
  74832. * @param scene Define the scene the texture belongs to
  74833. * @param generateMipMaps Define whether or not to create mip maps for the texture
  74834. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  74835. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  74836. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  74837. * @returns the R texture
  74838. */
  74839. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  74840. }
  74841. }
  74842. declare module BABYLON {
  74843. /**
  74844. * Defines a runtime animation
  74845. */
  74846. export class RuntimeAnimation {
  74847. private _events;
  74848. /**
  74849. * The current frame of the runtime animation
  74850. */
  74851. private _currentFrame;
  74852. /**
  74853. * The animation used by the runtime animation
  74854. */
  74855. private _animation;
  74856. /**
  74857. * The target of the runtime animation
  74858. */
  74859. private _target;
  74860. /**
  74861. * The initiating animatable
  74862. */
  74863. private _host;
  74864. /**
  74865. * The original value of the runtime animation
  74866. */
  74867. private _originalValue;
  74868. /**
  74869. * The original blend value of the runtime animation
  74870. */
  74871. private _originalBlendValue;
  74872. /**
  74873. * The offsets cache of the runtime animation
  74874. */
  74875. private _offsetsCache;
  74876. /**
  74877. * The high limits cache of the runtime animation
  74878. */
  74879. private _highLimitsCache;
  74880. /**
  74881. * Specifies if the runtime animation has been stopped
  74882. */
  74883. private _stopped;
  74884. /**
  74885. * The blending factor of the runtime animation
  74886. */
  74887. private _blendingFactor;
  74888. /**
  74889. * The BabylonJS scene
  74890. */
  74891. private _scene;
  74892. /**
  74893. * The current value of the runtime animation
  74894. */
  74895. private _currentValue;
  74896. /** @hidden */
  74897. _workValue: any;
  74898. /**
  74899. * The active target of the runtime animation
  74900. */
  74901. private _activeTarget;
  74902. /**
  74903. * The target path of the runtime animation
  74904. */
  74905. private _targetPath;
  74906. /**
  74907. * The weight of the runtime animation
  74908. */
  74909. private _weight;
  74910. /**
  74911. * The ratio offset of the runtime animation
  74912. */
  74913. private _ratioOffset;
  74914. /**
  74915. * The previous delay of the runtime animation
  74916. */
  74917. private _previousDelay;
  74918. /**
  74919. * The previous ratio of the runtime animation
  74920. */
  74921. private _previousRatio;
  74922. /**
  74923. * Gets the current frame of the runtime animation
  74924. */
  74925. readonly currentFrame: number;
  74926. /**
  74927. * Gets the weight of the runtime animation
  74928. */
  74929. readonly weight: number;
  74930. /**
  74931. * Gets the current value of the runtime animation
  74932. */
  74933. readonly currentValue: any;
  74934. /**
  74935. * Gets the target path of the runtime animation
  74936. */
  74937. readonly targetPath: string;
  74938. /**
  74939. * Gets the actual target of the runtime animation
  74940. */
  74941. readonly target: any;
  74942. /**
  74943. * Create a new RuntimeAnimation object
  74944. * @param target defines the target of the animation
  74945. * @param animation defines the source animation object
  74946. * @param scene defines the hosting scene
  74947. * @param host defines the initiating Animatable
  74948. */
  74949. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  74950. /**
  74951. * Gets the animation from the runtime animation
  74952. */
  74953. readonly animation: Animation;
  74954. /**
  74955. * Resets the runtime animation to the beginning
  74956. * @param restoreOriginal defines whether to restore the target property to the original value
  74957. */
  74958. reset(restoreOriginal?: boolean): void;
  74959. /**
  74960. * Specifies if the runtime animation is stopped
  74961. * @returns Boolean specifying if the runtime animation is stopped
  74962. */
  74963. isStopped(): boolean;
  74964. /**
  74965. * Disposes of the runtime animation
  74966. */
  74967. dispose(): void;
  74968. /**
  74969. * Interpolates the animation from the current frame
  74970. * @param currentFrame The frame to interpolate the animation to
  74971. * @param repeatCount The number of times that the animation should loop
  74972. * @param loopMode The type of looping mode to use
  74973. * @param offsetValue Animation offset value
  74974. * @param highLimitValue The high limit value
  74975. * @returns The interpolated value
  74976. */
  74977. private _interpolate;
  74978. /**
  74979. * Apply the interpolated value to the target
  74980. * @param currentValue defines the value computed by the animation
  74981. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  74982. */
  74983. setValue(currentValue: any, weight?: number): void;
  74984. private _setValue;
  74985. /**
  74986. * Gets the loop pmode of the runtime animation
  74987. * @returns Loop Mode
  74988. */
  74989. private _getCorrectLoopMode;
  74990. /**
  74991. * Move the current animation to a given frame
  74992. * @param frame defines the frame to move to
  74993. */
  74994. goToFrame(frame: number): void;
  74995. /**
  74996. * @hidden Internal use only
  74997. */
  74998. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  74999. /**
  75000. * Execute the current animation
  75001. * @param delay defines the delay to add to the current frame
  75002. * @param from defines the lower bound of the animation range
  75003. * @param to defines the upper bound of the animation range
  75004. * @param loop defines if the current animation must loop
  75005. * @param speedRatio defines the current speed ratio
  75006. * @param weight defines the weight of the animation (default is -1 so no weight)
  75007. * @param onLoop optional callback called when animation loops
  75008. * @returns a boolean indicating if the animation is running
  75009. */
  75010. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  75011. }
  75012. }
  75013. declare module BABYLON {
  75014. /**
  75015. * Class used to store an actual running animation
  75016. */
  75017. export class Animatable {
  75018. /** defines the target object */
  75019. target: any;
  75020. /** defines the starting frame number (default is 0) */
  75021. fromFrame: number;
  75022. /** defines the ending frame number (default is 100) */
  75023. toFrame: number;
  75024. /** defines if the animation must loop (default is false) */
  75025. loopAnimation: boolean;
  75026. /** defines a callback to call when animation ends if it is not looping */
  75027. onAnimationEnd?: (() => void) | null | undefined;
  75028. /** defines a callback to call when animation loops */
  75029. onAnimationLoop?: (() => void) | null | undefined;
  75030. private _localDelayOffset;
  75031. private _pausedDelay;
  75032. private _runtimeAnimations;
  75033. private _paused;
  75034. private _scene;
  75035. private _speedRatio;
  75036. private _weight;
  75037. private _syncRoot;
  75038. /**
  75039. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  75040. * This will only apply for non looping animation (default is true)
  75041. */
  75042. disposeOnEnd: boolean;
  75043. /**
  75044. * Gets a boolean indicating if the animation has started
  75045. */
  75046. animationStarted: boolean;
  75047. /**
  75048. * Observer raised when the animation ends
  75049. */
  75050. onAnimationEndObservable: Observable<Animatable>;
  75051. /**
  75052. * Observer raised when the animation loops
  75053. */
  75054. onAnimationLoopObservable: Observable<Animatable>;
  75055. /**
  75056. * Gets the root Animatable used to synchronize and normalize animations
  75057. */
  75058. readonly syncRoot: Animatable;
  75059. /**
  75060. * Gets the current frame of the first RuntimeAnimation
  75061. * Used to synchronize Animatables
  75062. */
  75063. readonly masterFrame: number;
  75064. /**
  75065. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  75066. */
  75067. weight: number;
  75068. /**
  75069. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  75070. */
  75071. speedRatio: number;
  75072. /**
  75073. * Creates a new Animatable
  75074. * @param scene defines the hosting scene
  75075. * @param target defines the target object
  75076. * @param fromFrame defines the starting frame number (default is 0)
  75077. * @param toFrame defines the ending frame number (default is 100)
  75078. * @param loopAnimation defines if the animation must loop (default is false)
  75079. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  75080. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  75081. * @param animations defines a group of animation to add to the new Animatable
  75082. * @param onAnimationLoop defines a callback to call when animation loops
  75083. */
  75084. constructor(scene: Scene,
  75085. /** defines the target object */
  75086. target: any,
  75087. /** defines the starting frame number (default is 0) */
  75088. fromFrame?: number,
  75089. /** defines the ending frame number (default is 100) */
  75090. toFrame?: number,
  75091. /** defines if the animation must loop (default is false) */
  75092. loopAnimation?: boolean, speedRatio?: number,
  75093. /** defines a callback to call when animation ends if it is not looping */
  75094. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  75095. /** defines a callback to call when animation loops */
  75096. onAnimationLoop?: (() => void) | null | undefined);
  75097. /**
  75098. * Synchronize and normalize current Animatable with a source Animatable
  75099. * This is useful when using animation weights and when animations are not of the same length
  75100. * @param root defines the root Animatable to synchronize with
  75101. * @returns the current Animatable
  75102. */
  75103. syncWith(root: Animatable): Animatable;
  75104. /**
  75105. * Gets the list of runtime animations
  75106. * @returns an array of RuntimeAnimation
  75107. */
  75108. getAnimations(): RuntimeAnimation[];
  75109. /**
  75110. * Adds more animations to the current animatable
  75111. * @param target defines the target of the animations
  75112. * @param animations defines the new animations to add
  75113. */
  75114. appendAnimations(target: any, animations: Animation[]): void;
  75115. /**
  75116. * Gets the source animation for a specific property
  75117. * @param property defines the propertyu to look for
  75118. * @returns null or the source animation for the given property
  75119. */
  75120. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  75121. /**
  75122. * Gets the runtime animation for a specific property
  75123. * @param property defines the propertyu to look for
  75124. * @returns null or the runtime animation for the given property
  75125. */
  75126. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  75127. /**
  75128. * Resets the animatable to its original state
  75129. */
  75130. reset(): void;
  75131. /**
  75132. * Allows the animatable to blend with current running animations
  75133. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  75134. * @param blendingSpeed defines the blending speed to use
  75135. */
  75136. enableBlending(blendingSpeed: number): void;
  75137. /**
  75138. * Disable animation blending
  75139. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  75140. */
  75141. disableBlending(): void;
  75142. /**
  75143. * Jump directly to a given frame
  75144. * @param frame defines the frame to jump to
  75145. */
  75146. goToFrame(frame: number): void;
  75147. /**
  75148. * Pause the animation
  75149. */
  75150. pause(): void;
  75151. /**
  75152. * Restart the animation
  75153. */
  75154. restart(): void;
  75155. private _raiseOnAnimationEnd;
  75156. /**
  75157. * Stop and delete the current animation
  75158. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  75159. * @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)
  75160. */
  75161. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  75162. /**
  75163. * Wait asynchronously for the animation to end
  75164. * @returns a promise which will be fullfilled when the animation ends
  75165. */
  75166. waitAsync(): Promise<Animatable>;
  75167. /** @hidden */
  75168. _animate(delay: number): boolean;
  75169. }
  75170. interface Scene {
  75171. /** @hidden */
  75172. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  75173. /** @hidden */
  75174. _processLateAnimationBindingsForMatrices(holder: {
  75175. totalWeight: number;
  75176. animations: RuntimeAnimation[];
  75177. originalValue: Matrix;
  75178. }): any;
  75179. /** @hidden */
  75180. _processLateAnimationBindingsForQuaternions(holder: {
  75181. totalWeight: number;
  75182. animations: RuntimeAnimation[];
  75183. originalValue: Quaternion;
  75184. }, refQuaternion: Quaternion): Quaternion;
  75185. /** @hidden */
  75186. _processLateAnimationBindings(): void;
  75187. /**
  75188. * Will start the animation sequence of a given target
  75189. * @param target defines the target
  75190. * @param from defines from which frame should animation start
  75191. * @param to defines until which frame should animation run.
  75192. * @param weight defines the weight to apply to the animation (1.0 by default)
  75193. * @param loop defines if the animation loops
  75194. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  75195. * @param onAnimationEnd defines the function to be executed when the animation ends
  75196. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  75197. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  75198. * @param onAnimationLoop defines the callback to call when an animation loops
  75199. * @returns the animatable object created for this animation
  75200. */
  75201. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  75202. /**
  75203. * Will start the animation sequence of a given target
  75204. * @param target defines the target
  75205. * @param from defines from which frame should animation start
  75206. * @param to defines until which frame should animation run.
  75207. * @param loop defines if the animation loops
  75208. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  75209. * @param onAnimationEnd defines the function to be executed when the animation ends
  75210. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  75211. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  75212. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  75213. * @param onAnimationLoop defines the callback to call when an animation loops
  75214. * @returns the animatable object created for this animation
  75215. */
  75216. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  75217. /**
  75218. * Will start the animation sequence of a given target and its hierarchy
  75219. * @param target defines the target
  75220. * @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.
  75221. * @param from defines from which frame should animation start
  75222. * @param to defines until which frame should animation run.
  75223. * @param loop defines if the animation loops
  75224. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  75225. * @param onAnimationEnd defines the function to be executed when the animation ends
  75226. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  75227. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  75228. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  75229. * @param onAnimationLoop defines the callback to call when an animation loops
  75230. * @returns the list of created animatables
  75231. */
  75232. 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[];
  75233. /**
  75234. * Begin a new animation on a given node
  75235. * @param target defines the target where the animation will take place
  75236. * @param animations defines the list of animations to start
  75237. * @param from defines the initial value
  75238. * @param to defines the final value
  75239. * @param loop defines if you want animation to loop (off by default)
  75240. * @param speedRatio defines the speed ratio to apply to all animations
  75241. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  75242. * @param onAnimationLoop defines the callback to call when an animation loops
  75243. * @returns the list of created animatables
  75244. */
  75245. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  75246. /**
  75247. * Begin a new animation on a given node and its hierarchy
  75248. * @param target defines the root node where the animation will take place
  75249. * @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.
  75250. * @param animations defines the list of animations to start
  75251. * @param from defines the initial value
  75252. * @param to defines the final value
  75253. * @param loop defines if you want animation to loop (off by default)
  75254. * @param speedRatio defines the speed ratio to apply to all animations
  75255. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  75256. * @param onAnimationLoop defines the callback to call when an animation loops
  75257. * @returns the list of animatables created for all nodes
  75258. */
  75259. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  75260. /**
  75261. * Gets the animatable associated with a specific target
  75262. * @param target defines the target of the animatable
  75263. * @returns the required animatable if found
  75264. */
  75265. getAnimatableByTarget(target: any): Nullable<Animatable>;
  75266. /**
  75267. * Gets all animatables associated with a given target
  75268. * @param target defines the target to look animatables for
  75269. * @returns an array of Animatables
  75270. */
  75271. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  75272. /**
  75273. * Will stop the animation of the given target
  75274. * @param target - the target
  75275. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  75276. * @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)
  75277. */
  75278. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  75279. /**
  75280. * Stops and removes all animations that have been applied to the scene
  75281. */
  75282. stopAllAnimations(): void;
  75283. }
  75284. interface Bone {
  75285. /**
  75286. * Copy an animation range from another bone
  75287. * @param source defines the source bone
  75288. * @param rangeName defines the range name to copy
  75289. * @param frameOffset defines the frame offset
  75290. * @param rescaleAsRequired defines if rescaling must be applied if required
  75291. * @param skelDimensionsRatio defines the scaling ratio
  75292. * @returns true if operation was successful
  75293. */
  75294. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  75295. }
  75296. }
  75297. declare module BABYLON {
  75298. /**
  75299. * Class used to handle skinning animations
  75300. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  75301. */
  75302. export class Skeleton implements IAnimatable {
  75303. /** defines the skeleton name */
  75304. name: string;
  75305. /** defines the skeleton Id */
  75306. id: string;
  75307. /**
  75308. * Defines the list of child bones
  75309. */
  75310. bones: Bone[];
  75311. /**
  75312. * Defines an estimate of the dimension of the skeleton at rest
  75313. */
  75314. dimensionsAtRest: Vector3;
  75315. /**
  75316. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  75317. */
  75318. needInitialSkinMatrix: boolean;
  75319. /**
  75320. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  75321. */
  75322. overrideMesh: Nullable<AbstractMesh>;
  75323. /**
  75324. * Gets the list of animations attached to this skeleton
  75325. */
  75326. animations: Array<Animation>;
  75327. private _scene;
  75328. private _isDirty;
  75329. private _transformMatrices;
  75330. private _transformMatrixTexture;
  75331. private _meshesWithPoseMatrix;
  75332. private _animatables;
  75333. private _identity;
  75334. private _synchronizedWithMesh;
  75335. private _ranges;
  75336. private _lastAbsoluteTransformsUpdateId;
  75337. private _canUseTextureForBones;
  75338. /** @hidden */
  75339. _numBonesWithLinkedTransformNode: number;
  75340. /**
  75341. * Specifies if the skeleton should be serialized
  75342. */
  75343. doNotSerialize: boolean;
  75344. /**
  75345. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  75346. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  75347. */
  75348. useTextureToStoreBoneMatrices: boolean;
  75349. private _animationPropertiesOverride;
  75350. /**
  75351. * Gets or sets the animation properties override
  75352. */
  75353. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  75354. /**
  75355. * An observable triggered before computing the skeleton's matrices
  75356. */
  75357. onBeforeComputeObservable: Observable<Skeleton>;
  75358. /**
  75359. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  75360. */
  75361. readonly isUsingTextureForMatrices: boolean;
  75362. /**
  75363. * Creates a new skeleton
  75364. * @param name defines the skeleton name
  75365. * @param id defines the skeleton Id
  75366. * @param scene defines the hosting scene
  75367. */
  75368. constructor(
  75369. /** defines the skeleton name */
  75370. name: string,
  75371. /** defines the skeleton Id */
  75372. id: string, scene: Scene);
  75373. /**
  75374. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  75375. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  75376. * @returns a Float32Array containing matrices data
  75377. */
  75378. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  75379. /**
  75380. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  75381. * @returns a raw texture containing the data
  75382. */
  75383. getTransformMatrixTexture(): Nullable<RawTexture>;
  75384. /**
  75385. * Gets the current hosting scene
  75386. * @returns a scene object
  75387. */
  75388. getScene(): Scene;
  75389. /**
  75390. * Gets a string representing the current skeleton data
  75391. * @param fullDetails defines a boolean indicating if we want a verbose version
  75392. * @returns a string representing the current skeleton data
  75393. */
  75394. toString(fullDetails?: boolean): string;
  75395. /**
  75396. * Get bone's index searching by name
  75397. * @param name defines bone's name to search for
  75398. * @return the indice of the bone. Returns -1 if not found
  75399. */
  75400. getBoneIndexByName(name: string): number;
  75401. /**
  75402. * Creater a new animation range
  75403. * @param name defines the name of the range
  75404. * @param from defines the start key
  75405. * @param to defines the end key
  75406. */
  75407. createAnimationRange(name: string, from: number, to: number): void;
  75408. /**
  75409. * Delete a specific animation range
  75410. * @param name defines the name of the range
  75411. * @param deleteFrames defines if frames must be removed as well
  75412. */
  75413. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  75414. /**
  75415. * Gets a specific animation range
  75416. * @param name defines the name of the range to look for
  75417. * @returns the requested animation range or null if not found
  75418. */
  75419. getAnimationRange(name: string): Nullable<AnimationRange>;
  75420. /**
  75421. * Gets the list of all animation ranges defined on this skeleton
  75422. * @returns an array
  75423. */
  75424. getAnimationRanges(): Nullable<AnimationRange>[];
  75425. /**
  75426. * Copy animation range from a source skeleton.
  75427. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  75428. * @param source defines the source skeleton
  75429. * @param name defines the name of the range to copy
  75430. * @param rescaleAsRequired defines if rescaling must be applied if required
  75431. * @returns true if operation was successful
  75432. */
  75433. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  75434. /**
  75435. * Forces the skeleton to go to rest pose
  75436. */
  75437. returnToRest(): void;
  75438. private _getHighestAnimationFrame;
  75439. /**
  75440. * Begin a specific animation range
  75441. * @param name defines the name of the range to start
  75442. * @param loop defines if looping must be turned on (false by default)
  75443. * @param speedRatio defines the speed ratio to apply (1 by default)
  75444. * @param onAnimationEnd defines a callback which will be called when animation will end
  75445. * @returns a new animatable
  75446. */
  75447. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  75448. /** @hidden */
  75449. _markAsDirty(): void;
  75450. /** @hidden */
  75451. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  75452. /** @hidden */
  75453. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  75454. private _computeTransformMatrices;
  75455. /**
  75456. * Build all resources required to render a skeleton
  75457. */
  75458. prepare(): void;
  75459. /**
  75460. * Gets the list of animatables currently running for this skeleton
  75461. * @returns an array of animatables
  75462. */
  75463. getAnimatables(): IAnimatable[];
  75464. /**
  75465. * Clone the current skeleton
  75466. * @param name defines the name of the new skeleton
  75467. * @param id defines the id of the enw skeleton
  75468. * @returns the new skeleton
  75469. */
  75470. clone(name: string, id: string): Skeleton;
  75471. /**
  75472. * Enable animation blending for this skeleton
  75473. * @param blendingSpeed defines the blending speed to apply
  75474. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  75475. */
  75476. enableBlending(blendingSpeed?: number): void;
  75477. /**
  75478. * Releases all resources associated with the current skeleton
  75479. */
  75480. dispose(): void;
  75481. /**
  75482. * Serialize the skeleton in a JSON object
  75483. * @returns a JSON object
  75484. */
  75485. serialize(): any;
  75486. /**
  75487. * Creates a new skeleton from serialized data
  75488. * @param parsedSkeleton defines the serialized data
  75489. * @param scene defines the hosting scene
  75490. * @returns a new skeleton
  75491. */
  75492. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  75493. /**
  75494. * Compute all node absolute transforms
  75495. * @param forceUpdate defines if computation must be done even if cache is up to date
  75496. */
  75497. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  75498. /**
  75499. * Gets the root pose matrix
  75500. * @returns a matrix
  75501. */
  75502. getPoseMatrix(): Nullable<Matrix>;
  75503. /**
  75504. * Sorts bones per internal index
  75505. */
  75506. sortBones(): void;
  75507. private _sortBones;
  75508. }
  75509. }
  75510. declare module BABYLON {
  75511. /**
  75512. * Defines a target to use with MorphTargetManager
  75513. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  75514. */
  75515. export class MorphTarget implements IAnimatable {
  75516. /** defines the name of the target */
  75517. name: string;
  75518. /**
  75519. * Gets or sets the list of animations
  75520. */
  75521. animations: Animation[];
  75522. private _scene;
  75523. private _positions;
  75524. private _normals;
  75525. private _tangents;
  75526. private _influence;
  75527. /**
  75528. * Observable raised when the influence changes
  75529. */
  75530. onInfluenceChanged: Observable<boolean>;
  75531. /** @hidden */
  75532. _onDataLayoutChanged: Observable<void>;
  75533. /**
  75534. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  75535. */
  75536. influence: number;
  75537. /**
  75538. * Gets or sets the id of the morph Target
  75539. */
  75540. id: string;
  75541. private _animationPropertiesOverride;
  75542. /**
  75543. * Gets or sets the animation properties override
  75544. */
  75545. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  75546. /**
  75547. * Creates a new MorphTarget
  75548. * @param name defines the name of the target
  75549. * @param influence defines the influence to use
  75550. * @param scene defines the scene the morphtarget belongs to
  75551. */
  75552. constructor(
  75553. /** defines the name of the target */
  75554. name: string, influence?: number, scene?: Nullable<Scene>);
  75555. /**
  75556. * Gets a boolean defining if the target contains position data
  75557. */
  75558. readonly hasPositions: boolean;
  75559. /**
  75560. * Gets a boolean defining if the target contains normal data
  75561. */
  75562. readonly hasNormals: boolean;
  75563. /**
  75564. * Gets a boolean defining if the target contains tangent data
  75565. */
  75566. readonly hasTangents: boolean;
  75567. /**
  75568. * Affects position data to this target
  75569. * @param data defines the position data to use
  75570. */
  75571. setPositions(data: Nullable<FloatArray>): void;
  75572. /**
  75573. * Gets the position data stored in this target
  75574. * @returns a FloatArray containing the position data (or null if not present)
  75575. */
  75576. getPositions(): Nullable<FloatArray>;
  75577. /**
  75578. * Affects normal data to this target
  75579. * @param data defines the normal data to use
  75580. */
  75581. setNormals(data: Nullable<FloatArray>): void;
  75582. /**
  75583. * Gets the normal data stored in this target
  75584. * @returns a FloatArray containing the normal data (or null if not present)
  75585. */
  75586. getNormals(): Nullable<FloatArray>;
  75587. /**
  75588. * Affects tangent data to this target
  75589. * @param data defines the tangent data to use
  75590. */
  75591. setTangents(data: Nullable<FloatArray>): void;
  75592. /**
  75593. * Gets the tangent data stored in this target
  75594. * @returns a FloatArray containing the tangent data (or null if not present)
  75595. */
  75596. getTangents(): Nullable<FloatArray>;
  75597. /**
  75598. * Serializes the current target into a Serialization object
  75599. * @returns the serialized object
  75600. */
  75601. serialize(): any;
  75602. /**
  75603. * Returns the string "MorphTarget"
  75604. * @returns "MorphTarget"
  75605. */
  75606. getClassName(): string;
  75607. /**
  75608. * Creates a new target from serialized data
  75609. * @param serializationObject defines the serialized data to use
  75610. * @returns a new MorphTarget
  75611. */
  75612. static Parse(serializationObject: any): MorphTarget;
  75613. /**
  75614. * Creates a MorphTarget from mesh data
  75615. * @param mesh defines the source mesh
  75616. * @param name defines the name to use for the new target
  75617. * @param influence defines the influence to attach to the target
  75618. * @returns a new MorphTarget
  75619. */
  75620. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  75621. }
  75622. }
  75623. declare module BABYLON {
  75624. /**
  75625. * This class is used to deform meshes using morphing between different targets
  75626. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  75627. */
  75628. export class MorphTargetManager {
  75629. private _targets;
  75630. private _targetInfluenceChangedObservers;
  75631. private _targetDataLayoutChangedObservers;
  75632. private _activeTargets;
  75633. private _scene;
  75634. private _influences;
  75635. private _supportsNormals;
  75636. private _supportsTangents;
  75637. private _vertexCount;
  75638. private _uniqueId;
  75639. private _tempInfluences;
  75640. /**
  75641. * Creates a new MorphTargetManager
  75642. * @param scene defines the current scene
  75643. */
  75644. constructor(scene?: Nullable<Scene>);
  75645. /**
  75646. * Gets the unique ID of this manager
  75647. */
  75648. readonly uniqueId: number;
  75649. /**
  75650. * Gets the number of vertices handled by this manager
  75651. */
  75652. readonly vertexCount: number;
  75653. /**
  75654. * Gets a boolean indicating if this manager supports morphing of normals
  75655. */
  75656. readonly supportsNormals: boolean;
  75657. /**
  75658. * Gets a boolean indicating if this manager supports morphing of tangents
  75659. */
  75660. readonly supportsTangents: boolean;
  75661. /**
  75662. * Gets the number of targets stored in this manager
  75663. */
  75664. readonly numTargets: number;
  75665. /**
  75666. * Gets the number of influencers (ie. the number of targets with influences > 0)
  75667. */
  75668. readonly numInfluencers: number;
  75669. /**
  75670. * Gets the list of influences (one per target)
  75671. */
  75672. readonly influences: Float32Array;
  75673. /**
  75674. * Gets the active target at specified index. An active target is a target with an influence > 0
  75675. * @param index defines the index to check
  75676. * @returns the requested target
  75677. */
  75678. getActiveTarget(index: number): MorphTarget;
  75679. /**
  75680. * Gets the target at specified index
  75681. * @param index defines the index to check
  75682. * @returns the requested target
  75683. */
  75684. getTarget(index: number): MorphTarget;
  75685. /**
  75686. * Add a new target to this manager
  75687. * @param target defines the target to add
  75688. */
  75689. addTarget(target: MorphTarget): void;
  75690. /**
  75691. * Removes a target from the manager
  75692. * @param target defines the target to remove
  75693. */
  75694. removeTarget(target: MorphTarget): void;
  75695. /**
  75696. * Serializes the current manager into a Serialization object
  75697. * @returns the serialized object
  75698. */
  75699. serialize(): any;
  75700. private _syncActiveTargets;
  75701. /**
  75702. * Syncrhonize the targets with all the meshes using this morph target manager
  75703. */
  75704. synchronize(): void;
  75705. /**
  75706. * Creates a new MorphTargetManager from serialized data
  75707. * @param serializationObject defines the serialized data
  75708. * @param scene defines the hosting scene
  75709. * @returns the new MorphTargetManager
  75710. */
  75711. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  75712. }
  75713. }
  75714. declare module BABYLON {
  75715. /**
  75716. * Mesh representing the gorund
  75717. */
  75718. export class GroundMesh extends Mesh {
  75719. /** If octree should be generated */
  75720. generateOctree: boolean;
  75721. private _heightQuads;
  75722. /** @hidden */
  75723. _subdivisionsX: number;
  75724. /** @hidden */
  75725. _subdivisionsY: number;
  75726. /** @hidden */
  75727. _width: number;
  75728. /** @hidden */
  75729. _height: number;
  75730. /** @hidden */
  75731. _minX: number;
  75732. /** @hidden */
  75733. _maxX: number;
  75734. /** @hidden */
  75735. _minZ: number;
  75736. /** @hidden */
  75737. _maxZ: number;
  75738. constructor(name: string, scene: Scene);
  75739. /**
  75740. * "GroundMesh"
  75741. * @returns "GroundMesh"
  75742. */
  75743. getClassName(): string;
  75744. /**
  75745. * The minimum of x and y subdivisions
  75746. */
  75747. readonly subdivisions: number;
  75748. /**
  75749. * X subdivisions
  75750. */
  75751. readonly subdivisionsX: number;
  75752. /**
  75753. * Y subdivisions
  75754. */
  75755. readonly subdivisionsY: number;
  75756. /**
  75757. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  75758. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  75759. * @param chunksCount the number of subdivisions for x and y
  75760. * @param octreeBlocksSize (Default: 32)
  75761. */
  75762. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  75763. /**
  75764. * Returns a height (y) value in the Worl system :
  75765. * the ground altitude at the coordinates (x, z) expressed in the World system.
  75766. * @param x x coordinate
  75767. * @param z z coordinate
  75768. * @returns the ground y position if (x, z) are outside the ground surface.
  75769. */
  75770. getHeightAtCoordinates(x: number, z: number): number;
  75771. /**
  75772. * Returns a normalized vector (Vector3) orthogonal to the ground
  75773. * at the ground coordinates (x, z) expressed in the World system.
  75774. * @param x x coordinate
  75775. * @param z z coordinate
  75776. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  75777. */
  75778. getNormalAtCoordinates(x: number, z: number): Vector3;
  75779. /**
  75780. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  75781. * at the ground coordinates (x, z) expressed in the World system.
  75782. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  75783. * @param x x coordinate
  75784. * @param z z coordinate
  75785. * @param ref vector to store the result
  75786. * @returns the GroundMesh.
  75787. */
  75788. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  75789. /**
  75790. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  75791. * if the ground has been updated.
  75792. * This can be used in the render loop.
  75793. * @returns the GroundMesh.
  75794. */
  75795. updateCoordinateHeights(): GroundMesh;
  75796. private _getFacetAt;
  75797. private _initHeightQuads;
  75798. private _computeHeightQuads;
  75799. /**
  75800. * Serializes this ground mesh
  75801. * @param serializationObject object to write serialization to
  75802. */
  75803. serialize(serializationObject: any): void;
  75804. /**
  75805. * Parses a serialized ground mesh
  75806. * @param parsedMesh the serialized mesh
  75807. * @param scene the scene to create the ground mesh in
  75808. * @returns the created ground mesh
  75809. */
  75810. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  75811. }
  75812. }
  75813. declare module BABYLON {
  75814. /**
  75815. * Interface for Physics-Joint data
  75816. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75817. */
  75818. export interface PhysicsJointData {
  75819. /**
  75820. * The main pivot of the joint
  75821. */
  75822. mainPivot?: Vector3;
  75823. /**
  75824. * The connected pivot of the joint
  75825. */
  75826. connectedPivot?: Vector3;
  75827. /**
  75828. * The main axis of the joint
  75829. */
  75830. mainAxis?: Vector3;
  75831. /**
  75832. * The connected axis of the joint
  75833. */
  75834. connectedAxis?: Vector3;
  75835. /**
  75836. * The collision of the joint
  75837. */
  75838. collision?: boolean;
  75839. /**
  75840. * Native Oimo/Cannon/Energy data
  75841. */
  75842. nativeParams?: any;
  75843. }
  75844. /**
  75845. * This is a holder class for the physics joint created by the physics plugin
  75846. * It holds a set of functions to control the underlying joint
  75847. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75848. */
  75849. export class PhysicsJoint {
  75850. /**
  75851. * The type of the physics joint
  75852. */
  75853. type: number;
  75854. /**
  75855. * The data for the physics joint
  75856. */
  75857. jointData: PhysicsJointData;
  75858. private _physicsJoint;
  75859. protected _physicsPlugin: IPhysicsEnginePlugin;
  75860. /**
  75861. * Initializes the physics joint
  75862. * @param type The type of the physics joint
  75863. * @param jointData The data for the physics joint
  75864. */
  75865. constructor(
  75866. /**
  75867. * The type of the physics joint
  75868. */
  75869. type: number,
  75870. /**
  75871. * The data for the physics joint
  75872. */
  75873. jointData: PhysicsJointData);
  75874. /**
  75875. * Gets the physics joint
  75876. */
  75877. /**
  75878. * Sets the physics joint
  75879. */
  75880. physicsJoint: any;
  75881. /**
  75882. * Sets the physics plugin
  75883. */
  75884. physicsPlugin: IPhysicsEnginePlugin;
  75885. /**
  75886. * Execute a function that is physics-plugin specific.
  75887. * @param {Function} func the function that will be executed.
  75888. * It accepts two parameters: the physics world and the physics joint
  75889. */
  75890. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  75891. /**
  75892. * Distance-Joint type
  75893. */
  75894. static DistanceJoint: number;
  75895. /**
  75896. * Hinge-Joint type
  75897. */
  75898. static HingeJoint: number;
  75899. /**
  75900. * Ball-and-Socket joint type
  75901. */
  75902. static BallAndSocketJoint: number;
  75903. /**
  75904. * Wheel-Joint type
  75905. */
  75906. static WheelJoint: number;
  75907. /**
  75908. * Slider-Joint type
  75909. */
  75910. static SliderJoint: number;
  75911. /**
  75912. * Prismatic-Joint type
  75913. */
  75914. static PrismaticJoint: number;
  75915. /**
  75916. * Universal-Joint type
  75917. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  75918. */
  75919. static UniversalJoint: number;
  75920. /**
  75921. * Hinge-Joint 2 type
  75922. */
  75923. static Hinge2Joint: number;
  75924. /**
  75925. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  75926. */
  75927. static PointToPointJoint: number;
  75928. /**
  75929. * Spring-Joint type
  75930. */
  75931. static SpringJoint: number;
  75932. /**
  75933. * Lock-Joint type
  75934. */
  75935. static LockJoint: number;
  75936. }
  75937. /**
  75938. * A class representing a physics distance joint
  75939. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75940. */
  75941. export class DistanceJoint extends PhysicsJoint {
  75942. /**
  75943. *
  75944. * @param jointData The data for the Distance-Joint
  75945. */
  75946. constructor(jointData: DistanceJointData);
  75947. /**
  75948. * Update the predefined distance.
  75949. * @param maxDistance The maximum preferred distance
  75950. * @param minDistance The minimum preferred distance
  75951. */
  75952. updateDistance(maxDistance: number, minDistance?: number): void;
  75953. }
  75954. /**
  75955. * Represents a Motor-Enabled Joint
  75956. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75957. */
  75958. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  75959. /**
  75960. * Initializes the Motor-Enabled Joint
  75961. * @param type The type of the joint
  75962. * @param jointData The physica joint data for the joint
  75963. */
  75964. constructor(type: number, jointData: PhysicsJointData);
  75965. /**
  75966. * Set the motor values.
  75967. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75968. * @param force the force to apply
  75969. * @param maxForce max force for this motor.
  75970. */
  75971. setMotor(force?: number, maxForce?: number): void;
  75972. /**
  75973. * Set the motor's limits.
  75974. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75975. * @param upperLimit The upper limit of the motor
  75976. * @param lowerLimit The lower limit of the motor
  75977. */
  75978. setLimit(upperLimit: number, lowerLimit?: number): void;
  75979. }
  75980. /**
  75981. * This class represents a single physics Hinge-Joint
  75982. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75983. */
  75984. export class HingeJoint extends MotorEnabledJoint {
  75985. /**
  75986. * Initializes the Hinge-Joint
  75987. * @param jointData The joint data for the Hinge-Joint
  75988. */
  75989. constructor(jointData: PhysicsJointData);
  75990. /**
  75991. * Set the motor values.
  75992. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75993. * @param {number} force the force to apply
  75994. * @param {number} maxForce max force for this motor.
  75995. */
  75996. setMotor(force?: number, maxForce?: number): void;
  75997. /**
  75998. * Set the motor's limits.
  75999. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76000. * @param upperLimit The upper limit of the motor
  76001. * @param lowerLimit The lower limit of the motor
  76002. */
  76003. setLimit(upperLimit: number, lowerLimit?: number): void;
  76004. }
  76005. /**
  76006. * This class represents a dual hinge physics joint (same as wheel joint)
  76007. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76008. */
  76009. export class Hinge2Joint extends MotorEnabledJoint {
  76010. /**
  76011. * Initializes the Hinge2-Joint
  76012. * @param jointData The joint data for the Hinge2-Joint
  76013. */
  76014. constructor(jointData: PhysicsJointData);
  76015. /**
  76016. * Set the motor values.
  76017. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76018. * @param {number} targetSpeed the speed the motor is to reach
  76019. * @param {number} maxForce max force for this motor.
  76020. * @param {motorIndex} the motor's index, 0 or 1.
  76021. */
  76022. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  76023. /**
  76024. * Set the motor limits.
  76025. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76026. * @param {number} upperLimit the upper limit
  76027. * @param {number} lowerLimit lower limit
  76028. * @param {motorIndex} the motor's index, 0 or 1.
  76029. */
  76030. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  76031. }
  76032. /**
  76033. * Interface for a motor enabled joint
  76034. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76035. */
  76036. export interface IMotorEnabledJoint {
  76037. /**
  76038. * Physics joint
  76039. */
  76040. physicsJoint: any;
  76041. /**
  76042. * Sets the motor of the motor-enabled joint
  76043. * @param force The force of the motor
  76044. * @param maxForce The maximum force of the motor
  76045. * @param motorIndex The index of the motor
  76046. */
  76047. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  76048. /**
  76049. * Sets the limit of the motor
  76050. * @param upperLimit The upper limit of the motor
  76051. * @param lowerLimit The lower limit of the motor
  76052. * @param motorIndex The index of the motor
  76053. */
  76054. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  76055. }
  76056. /**
  76057. * Joint data for a Distance-Joint
  76058. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76059. */
  76060. export interface DistanceJointData extends PhysicsJointData {
  76061. /**
  76062. * Max distance the 2 joint objects can be apart
  76063. */
  76064. maxDistance: number;
  76065. }
  76066. /**
  76067. * Joint data from a spring joint
  76068. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76069. */
  76070. export interface SpringJointData extends PhysicsJointData {
  76071. /**
  76072. * Length of the spring
  76073. */
  76074. length: number;
  76075. /**
  76076. * Stiffness of the spring
  76077. */
  76078. stiffness: number;
  76079. /**
  76080. * Damping of the spring
  76081. */
  76082. damping: number;
  76083. /** this callback will be called when applying the force to the impostors. */
  76084. forceApplicationCallback: () => void;
  76085. }
  76086. }
  76087. declare module BABYLON {
  76088. /**
  76089. * Interface used to describe a physics joint
  76090. */
  76091. export interface PhysicsImpostorJoint {
  76092. /** Defines the main impostor to which the joint is linked */
  76093. mainImpostor: PhysicsImpostor;
  76094. /** Defines the impostor that is connected to the main impostor using this joint */
  76095. connectedImpostor: PhysicsImpostor;
  76096. /** Defines the joint itself */
  76097. joint: PhysicsJoint;
  76098. }
  76099. /** @hidden */
  76100. export interface IPhysicsEnginePlugin {
  76101. world: any;
  76102. name: string;
  76103. setGravity(gravity: Vector3): void;
  76104. setTimeStep(timeStep: number): void;
  76105. getTimeStep(): number;
  76106. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  76107. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  76108. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  76109. generatePhysicsBody(impostor: PhysicsImpostor): void;
  76110. removePhysicsBody(impostor: PhysicsImpostor): void;
  76111. generateJoint(joint: PhysicsImpostorJoint): void;
  76112. removeJoint(joint: PhysicsImpostorJoint): void;
  76113. isSupported(): boolean;
  76114. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  76115. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  76116. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  76117. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  76118. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  76119. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  76120. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  76121. getBodyMass(impostor: PhysicsImpostor): number;
  76122. getBodyFriction(impostor: PhysicsImpostor): number;
  76123. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  76124. getBodyRestitution(impostor: PhysicsImpostor): number;
  76125. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  76126. sleepBody(impostor: PhysicsImpostor): void;
  76127. wakeUpBody(impostor: PhysicsImpostor): void;
  76128. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  76129. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  76130. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  76131. getRadius(impostor: PhysicsImpostor): number;
  76132. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  76133. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  76134. dispose(): void;
  76135. }
  76136. /**
  76137. * Interface used to define a physics engine
  76138. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  76139. */
  76140. export interface IPhysicsEngine {
  76141. /**
  76142. * Gets the gravity vector used by the simulation
  76143. */
  76144. gravity: Vector3;
  76145. /**
  76146. * Sets the gravity vector used by the simulation
  76147. * @param gravity defines the gravity vector to use
  76148. */
  76149. setGravity(gravity: Vector3): void;
  76150. /**
  76151. * Set the time step of the physics engine.
  76152. * Default is 1/60.
  76153. * To slow it down, enter 1/600 for example.
  76154. * To speed it up, 1/30
  76155. * @param newTimeStep the new timestep to apply to this world.
  76156. */
  76157. setTimeStep(newTimeStep: number): void;
  76158. /**
  76159. * Get the time step of the physics engine.
  76160. * @returns the current time step
  76161. */
  76162. getTimeStep(): number;
  76163. /**
  76164. * Release all resources
  76165. */
  76166. dispose(): void;
  76167. /**
  76168. * Gets the name of the current physics plugin
  76169. * @returns the name of the plugin
  76170. */
  76171. getPhysicsPluginName(): string;
  76172. /**
  76173. * Adding a new impostor for the impostor tracking.
  76174. * This will be done by the impostor itself.
  76175. * @param impostor the impostor to add
  76176. */
  76177. addImpostor(impostor: PhysicsImpostor): void;
  76178. /**
  76179. * Remove an impostor from the engine.
  76180. * This impostor and its mesh will not longer be updated by the physics engine.
  76181. * @param impostor the impostor to remove
  76182. */
  76183. removeImpostor(impostor: PhysicsImpostor): void;
  76184. /**
  76185. * Add a joint to the physics engine
  76186. * @param mainImpostor defines the main impostor to which the joint is added.
  76187. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  76188. * @param joint defines the joint that will connect both impostors.
  76189. */
  76190. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  76191. /**
  76192. * Removes a joint from the simulation
  76193. * @param mainImpostor defines the impostor used with the joint
  76194. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  76195. * @param joint defines the joint to remove
  76196. */
  76197. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  76198. /**
  76199. * Gets the current plugin used to run the simulation
  76200. * @returns current plugin
  76201. */
  76202. getPhysicsPlugin(): IPhysicsEnginePlugin;
  76203. /**
  76204. * Gets the list of physic impostors
  76205. * @returns an array of PhysicsImpostor
  76206. */
  76207. getImpostors(): Array<PhysicsImpostor>;
  76208. /**
  76209. * Gets the impostor for a physics enabled object
  76210. * @param object defines the object impersonated by the impostor
  76211. * @returns the PhysicsImpostor or null if not found
  76212. */
  76213. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  76214. /**
  76215. * Gets the impostor for a physics body object
  76216. * @param body defines physics body used by the impostor
  76217. * @returns the PhysicsImpostor or null if not found
  76218. */
  76219. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  76220. /**
  76221. * Called by the scene. No need to call it.
  76222. * @param delta defines the timespam between frames
  76223. */
  76224. _step(delta: number): void;
  76225. }
  76226. }
  76227. declare module BABYLON {
  76228. /**
  76229. * The interface for the physics imposter parameters
  76230. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76231. */
  76232. export interface PhysicsImpostorParameters {
  76233. /**
  76234. * The mass of the physics imposter
  76235. */
  76236. mass: number;
  76237. /**
  76238. * The friction of the physics imposter
  76239. */
  76240. friction?: number;
  76241. /**
  76242. * The coefficient of restitution of the physics imposter
  76243. */
  76244. restitution?: number;
  76245. /**
  76246. * The native options of the physics imposter
  76247. */
  76248. nativeOptions?: any;
  76249. /**
  76250. * Specifies if the parent should be ignored
  76251. */
  76252. ignoreParent?: boolean;
  76253. /**
  76254. * Specifies if bi-directional transformations should be disabled
  76255. */
  76256. disableBidirectionalTransformation?: boolean;
  76257. }
  76258. /**
  76259. * Interface for a physics-enabled object
  76260. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76261. */
  76262. export interface IPhysicsEnabledObject {
  76263. /**
  76264. * The position of the physics-enabled object
  76265. */
  76266. position: Vector3;
  76267. /**
  76268. * The rotation of the physics-enabled object
  76269. */
  76270. rotationQuaternion: Nullable<Quaternion>;
  76271. /**
  76272. * The scale of the physics-enabled object
  76273. */
  76274. scaling: Vector3;
  76275. /**
  76276. * The rotation of the physics-enabled object
  76277. */
  76278. rotation?: Vector3;
  76279. /**
  76280. * The parent of the physics-enabled object
  76281. */
  76282. parent?: any;
  76283. /**
  76284. * The bounding info of the physics-enabled object
  76285. * @returns The bounding info of the physics-enabled object
  76286. */
  76287. getBoundingInfo(): BoundingInfo;
  76288. /**
  76289. * Computes the world matrix
  76290. * @param force Specifies if the world matrix should be computed by force
  76291. * @returns A world matrix
  76292. */
  76293. computeWorldMatrix(force: boolean): Matrix;
  76294. /**
  76295. * Gets the world matrix
  76296. * @returns A world matrix
  76297. */
  76298. getWorldMatrix?(): Matrix;
  76299. /**
  76300. * Gets the child meshes
  76301. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  76302. * @returns An array of abstract meshes
  76303. */
  76304. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  76305. /**
  76306. * Gets the vertex data
  76307. * @param kind The type of vertex data
  76308. * @returns A nullable array of numbers, or a float32 array
  76309. */
  76310. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  76311. /**
  76312. * Gets the indices from the mesh
  76313. * @returns A nullable array of index arrays
  76314. */
  76315. getIndices?(): Nullable<IndicesArray>;
  76316. /**
  76317. * Gets the scene from the mesh
  76318. * @returns the indices array or null
  76319. */
  76320. getScene?(): Scene;
  76321. /**
  76322. * Gets the absolute position from the mesh
  76323. * @returns the absolute position
  76324. */
  76325. getAbsolutePosition(): Vector3;
  76326. /**
  76327. * Gets the absolute pivot point from the mesh
  76328. * @returns the absolute pivot point
  76329. */
  76330. getAbsolutePivotPoint(): Vector3;
  76331. /**
  76332. * Rotates the mesh
  76333. * @param axis The axis of rotation
  76334. * @param amount The amount of rotation
  76335. * @param space The space of the rotation
  76336. * @returns The rotation transform node
  76337. */
  76338. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  76339. /**
  76340. * Translates the mesh
  76341. * @param axis The axis of translation
  76342. * @param distance The distance of translation
  76343. * @param space The space of the translation
  76344. * @returns The transform node
  76345. */
  76346. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  76347. /**
  76348. * Sets the absolute position of the mesh
  76349. * @param absolutePosition The absolute position of the mesh
  76350. * @returns The transform node
  76351. */
  76352. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  76353. /**
  76354. * Gets the class name of the mesh
  76355. * @returns The class name
  76356. */
  76357. getClassName(): string;
  76358. }
  76359. /**
  76360. * Represents a physics imposter
  76361. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76362. */
  76363. export class PhysicsImpostor {
  76364. /**
  76365. * The physics-enabled object used as the physics imposter
  76366. */
  76367. object: IPhysicsEnabledObject;
  76368. /**
  76369. * The type of the physics imposter
  76370. */
  76371. type: number;
  76372. private _options;
  76373. private _scene?;
  76374. /**
  76375. * The default object size of the imposter
  76376. */
  76377. static DEFAULT_OBJECT_SIZE: Vector3;
  76378. /**
  76379. * The identity quaternion of the imposter
  76380. */
  76381. static IDENTITY_QUATERNION: Quaternion;
  76382. /** @hidden */
  76383. _pluginData: any;
  76384. private _physicsEngine;
  76385. private _physicsBody;
  76386. private _bodyUpdateRequired;
  76387. private _onBeforePhysicsStepCallbacks;
  76388. private _onAfterPhysicsStepCallbacks;
  76389. /** @hidden */
  76390. _onPhysicsCollideCallbacks: Array<{
  76391. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  76392. otherImpostors: Array<PhysicsImpostor>;
  76393. }>;
  76394. private _deltaPosition;
  76395. private _deltaRotation;
  76396. private _deltaRotationConjugated;
  76397. private _parent;
  76398. private _isDisposed;
  76399. private static _tmpVecs;
  76400. private static _tmpQuat;
  76401. /**
  76402. * Specifies if the physics imposter is disposed
  76403. */
  76404. readonly isDisposed: boolean;
  76405. /**
  76406. * Gets the mass of the physics imposter
  76407. */
  76408. mass: number;
  76409. /**
  76410. * Gets the coefficient of friction
  76411. */
  76412. /**
  76413. * Sets the coefficient of friction
  76414. */
  76415. friction: number;
  76416. /**
  76417. * Gets the coefficient of restitution
  76418. */
  76419. /**
  76420. * Sets the coefficient of restitution
  76421. */
  76422. restitution: number;
  76423. /**
  76424. * The unique id of the physics imposter
  76425. * set by the physics engine when adding this impostor to the array
  76426. */
  76427. uniqueId: number;
  76428. private _joints;
  76429. /**
  76430. * Initializes the physics imposter
  76431. * @param object The physics-enabled object used as the physics imposter
  76432. * @param type The type of the physics imposter
  76433. * @param _options The options for the physics imposter
  76434. * @param _scene The Babylon scene
  76435. */
  76436. constructor(
  76437. /**
  76438. * The physics-enabled object used as the physics imposter
  76439. */
  76440. object: IPhysicsEnabledObject,
  76441. /**
  76442. * The type of the physics imposter
  76443. */
  76444. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  76445. /**
  76446. * This function will completly initialize this impostor.
  76447. * It will create a new body - but only if this mesh has no parent.
  76448. * If it has, this impostor will not be used other than to define the impostor
  76449. * of the child mesh.
  76450. * @hidden
  76451. */
  76452. _init(): void;
  76453. private _getPhysicsParent;
  76454. /**
  76455. * Should a new body be generated.
  76456. * @returns boolean specifying if body initialization is required
  76457. */
  76458. isBodyInitRequired(): boolean;
  76459. /**
  76460. * Sets the updated scaling
  76461. * @param updated Specifies if the scaling is updated
  76462. */
  76463. setScalingUpdated(): void;
  76464. /**
  76465. * Force a regeneration of this or the parent's impostor's body.
  76466. * Use under cautious - This will remove all joints already implemented.
  76467. */
  76468. forceUpdate(): void;
  76469. /**
  76470. * Gets the body that holds this impostor. Either its own, or its parent.
  76471. */
  76472. /**
  76473. * Set the physics body. Used mainly by the physics engine/plugin
  76474. */
  76475. physicsBody: any;
  76476. /**
  76477. * Get the parent of the physics imposter
  76478. * @returns Physics imposter or null
  76479. */
  76480. /**
  76481. * Sets the parent of the physics imposter
  76482. */
  76483. parent: Nullable<PhysicsImpostor>;
  76484. /**
  76485. * Resets the update flags
  76486. */
  76487. resetUpdateFlags(): void;
  76488. /**
  76489. * Gets the object extend size
  76490. * @returns the object extend size
  76491. */
  76492. getObjectExtendSize(): Vector3;
  76493. /**
  76494. * Gets the object center
  76495. * @returns The object center
  76496. */
  76497. getObjectCenter(): Vector3;
  76498. /**
  76499. * Get a specific parametes from the options parameter
  76500. * @param paramName The object parameter name
  76501. * @returns The object parameter
  76502. */
  76503. getParam(paramName: string): any;
  76504. /**
  76505. * Sets a specific parameter in the options given to the physics plugin
  76506. * @param paramName The parameter name
  76507. * @param value The value of the parameter
  76508. */
  76509. setParam(paramName: string, value: number): void;
  76510. /**
  76511. * Specifically change the body's mass option. Won't recreate the physics body object
  76512. * @param mass The mass of the physics imposter
  76513. */
  76514. setMass(mass: number): void;
  76515. /**
  76516. * Gets the linear velocity
  76517. * @returns linear velocity or null
  76518. */
  76519. getLinearVelocity(): Nullable<Vector3>;
  76520. /**
  76521. * Sets the linear velocity
  76522. * @param velocity linear velocity or null
  76523. */
  76524. setLinearVelocity(velocity: Nullable<Vector3>): void;
  76525. /**
  76526. * Gets the angular velocity
  76527. * @returns angular velocity or null
  76528. */
  76529. getAngularVelocity(): Nullable<Vector3>;
  76530. /**
  76531. * Sets the angular velocity
  76532. * @param velocity The velocity or null
  76533. */
  76534. setAngularVelocity(velocity: Nullable<Vector3>): void;
  76535. /**
  76536. * Execute a function with the physics plugin native code
  76537. * Provide a function the will have two variables - the world object and the physics body object
  76538. * @param func The function to execute with the physics plugin native code
  76539. */
  76540. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  76541. /**
  76542. * Register a function that will be executed before the physics world is stepping forward
  76543. * @param func The function to execute before the physics world is stepped forward
  76544. */
  76545. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76546. /**
  76547. * Unregister a function that will be executed before the physics world is stepping forward
  76548. * @param func The function to execute before the physics world is stepped forward
  76549. */
  76550. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76551. /**
  76552. * Register a function that will be executed after the physics step
  76553. * @param func The function to execute after physics step
  76554. */
  76555. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76556. /**
  76557. * Unregisters a function that will be executed after the physics step
  76558. * @param func The function to execute after physics step
  76559. */
  76560. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76561. /**
  76562. * register a function that will be executed when this impostor collides against a different body
  76563. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  76564. * @param func Callback that is executed on collision
  76565. */
  76566. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  76567. /**
  76568. * Unregisters the physics imposter on contact
  76569. * @param collideAgainst The physics object to collide against
  76570. * @param func Callback to execute on collision
  76571. */
  76572. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  76573. private _tmpQuat;
  76574. private _tmpQuat2;
  76575. /**
  76576. * Get the parent rotation
  76577. * @returns The parent rotation
  76578. */
  76579. getParentsRotation(): Quaternion;
  76580. /**
  76581. * this function is executed by the physics engine.
  76582. */
  76583. beforeStep: () => void;
  76584. /**
  76585. * this function is executed by the physics engine
  76586. */
  76587. afterStep: () => void;
  76588. /**
  76589. * Legacy collision detection event support
  76590. */
  76591. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  76592. /**
  76593. * event and body object due to cannon's event-based architecture.
  76594. */
  76595. onCollide: (e: {
  76596. body: any;
  76597. }) => void;
  76598. /**
  76599. * Apply a force
  76600. * @param force The force to apply
  76601. * @param contactPoint The contact point for the force
  76602. * @returns The physics imposter
  76603. */
  76604. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  76605. /**
  76606. * Apply an impulse
  76607. * @param force The impulse force
  76608. * @param contactPoint The contact point for the impulse force
  76609. * @returns The physics imposter
  76610. */
  76611. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  76612. /**
  76613. * A help function to create a joint
  76614. * @param otherImpostor A physics imposter used to create a joint
  76615. * @param jointType The type of joint
  76616. * @param jointData The data for the joint
  76617. * @returns The physics imposter
  76618. */
  76619. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  76620. /**
  76621. * Add a joint to this impostor with a different impostor
  76622. * @param otherImpostor A physics imposter used to add a joint
  76623. * @param joint The joint to add
  76624. * @returns The physics imposter
  76625. */
  76626. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  76627. /**
  76628. * Will keep this body still, in a sleep mode.
  76629. * @returns the physics imposter
  76630. */
  76631. sleep(): PhysicsImpostor;
  76632. /**
  76633. * Wake the body up.
  76634. * @returns The physics imposter
  76635. */
  76636. wakeUp(): PhysicsImpostor;
  76637. /**
  76638. * Clones the physics imposter
  76639. * @param newObject The physics imposter clones to this physics-enabled object
  76640. * @returns A nullable physics imposter
  76641. */
  76642. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  76643. /**
  76644. * Disposes the physics imposter
  76645. */
  76646. dispose(): void;
  76647. /**
  76648. * Sets the delta position
  76649. * @param position The delta position amount
  76650. */
  76651. setDeltaPosition(position: Vector3): void;
  76652. /**
  76653. * Sets the delta rotation
  76654. * @param rotation The delta rotation amount
  76655. */
  76656. setDeltaRotation(rotation: Quaternion): void;
  76657. /**
  76658. * Gets the box size of the physics imposter and stores the result in the input parameter
  76659. * @param result Stores the box size
  76660. * @returns The physics imposter
  76661. */
  76662. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  76663. /**
  76664. * Gets the radius of the physics imposter
  76665. * @returns Radius of the physics imposter
  76666. */
  76667. getRadius(): number;
  76668. /**
  76669. * Sync a bone with this impostor
  76670. * @param bone The bone to sync to the impostor.
  76671. * @param boneMesh The mesh that the bone is influencing.
  76672. * @param jointPivot The pivot of the joint / bone in local space.
  76673. * @param distToJoint Optional distance from the impostor to the joint.
  76674. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  76675. */
  76676. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  76677. /**
  76678. * Sync impostor to a bone
  76679. * @param bone The bone that the impostor will be synced to.
  76680. * @param boneMesh The mesh that the bone is influencing.
  76681. * @param jointPivot The pivot of the joint / bone in local space.
  76682. * @param distToJoint Optional distance from the impostor to the joint.
  76683. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  76684. * @param boneAxis Optional vector3 axis the bone is aligned with
  76685. */
  76686. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  76687. /**
  76688. * No-Imposter type
  76689. */
  76690. static NoImpostor: number;
  76691. /**
  76692. * Sphere-Imposter type
  76693. */
  76694. static SphereImpostor: number;
  76695. /**
  76696. * Box-Imposter type
  76697. */
  76698. static BoxImpostor: number;
  76699. /**
  76700. * Plane-Imposter type
  76701. */
  76702. static PlaneImpostor: number;
  76703. /**
  76704. * Mesh-imposter type
  76705. */
  76706. static MeshImpostor: number;
  76707. /**
  76708. * Cylinder-Imposter type
  76709. */
  76710. static CylinderImpostor: number;
  76711. /**
  76712. * Particle-Imposter type
  76713. */
  76714. static ParticleImpostor: number;
  76715. /**
  76716. * Heightmap-Imposter type
  76717. */
  76718. static HeightmapImpostor: number;
  76719. }
  76720. }
  76721. declare module BABYLON {
  76722. /**
  76723. * Class used to represent a specific level of detail of a mesh
  76724. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  76725. */
  76726. export class MeshLODLevel {
  76727. /** Defines the distance where this level should star being displayed */
  76728. distance: number;
  76729. /** Defines the mesh to use to render this level */
  76730. mesh: Nullable<Mesh>;
  76731. /**
  76732. * Creates a new LOD level
  76733. * @param distance defines the distance where this level should star being displayed
  76734. * @param mesh defines the mesh to use to render this level
  76735. */
  76736. constructor(
  76737. /** Defines the distance where this level should star being displayed */
  76738. distance: number,
  76739. /** Defines the mesh to use to render this level */
  76740. mesh: Nullable<Mesh>);
  76741. }
  76742. /**
  76743. * @hidden
  76744. **/
  76745. export class _CreationDataStorage {
  76746. closePath?: boolean;
  76747. closeArray?: boolean;
  76748. idx: number[];
  76749. dashSize: number;
  76750. gapSize: number;
  76751. path3D: Path3D;
  76752. pathArray: Vector3[][];
  76753. arc: number;
  76754. radius: number;
  76755. cap: number;
  76756. tessellation: number;
  76757. }
  76758. /**
  76759. * @hidden
  76760. **/
  76761. class _InstanceDataStorage {
  76762. visibleInstances: any;
  76763. renderIdForInstances: number[];
  76764. batchCache: _InstancesBatch;
  76765. instancesBufferSize: number;
  76766. instancesBuffer: Nullable<Buffer>;
  76767. instancesData: Float32Array;
  76768. overridenInstanceCount: number;
  76769. }
  76770. /**
  76771. * @hidden
  76772. **/
  76773. export class _InstancesBatch {
  76774. mustReturn: boolean;
  76775. visibleInstances: Nullable<InstancedMesh[]>[];
  76776. renderSelf: boolean[];
  76777. }
  76778. /**
  76779. * Class used to represent renderable models
  76780. */
  76781. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  76782. /**
  76783. * Mesh side orientation : usually the external or front surface
  76784. */
  76785. static readonly FRONTSIDE: number;
  76786. /**
  76787. * Mesh side orientation : usually the internal or back surface
  76788. */
  76789. static readonly BACKSIDE: number;
  76790. /**
  76791. * Mesh side orientation : both internal and external or front and back surfaces
  76792. */
  76793. static readonly DOUBLESIDE: number;
  76794. /**
  76795. * Mesh side orientation : by default, `FRONTSIDE`
  76796. */
  76797. static readonly DEFAULTSIDE: number;
  76798. /**
  76799. * Mesh cap setting : no cap
  76800. */
  76801. static readonly NO_CAP: number;
  76802. /**
  76803. * Mesh cap setting : one cap at the beginning of the mesh
  76804. */
  76805. static readonly CAP_START: number;
  76806. /**
  76807. * Mesh cap setting : one cap at the end of the mesh
  76808. */
  76809. static readonly CAP_END: number;
  76810. /**
  76811. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  76812. */
  76813. static readonly CAP_ALL: number;
  76814. /**
  76815. * Gets the default side orientation.
  76816. * @param orientation the orientation to value to attempt to get
  76817. * @returns the default orientation
  76818. * @hidden
  76819. */
  76820. static _GetDefaultSideOrientation(orientation?: number): number;
  76821. private _onBeforeRenderObservable;
  76822. private _onBeforeBindObservable;
  76823. private _onAfterRenderObservable;
  76824. private _onBeforeDrawObservable;
  76825. /**
  76826. * An event triggered before rendering the mesh
  76827. */
  76828. readonly onBeforeRenderObservable: Observable<Mesh>;
  76829. /**
  76830. * An event triggered before binding the mesh
  76831. */
  76832. readonly onBeforeBindObservable: Observable<Mesh>;
  76833. /**
  76834. * An event triggered after rendering the mesh
  76835. */
  76836. readonly onAfterRenderObservable: Observable<Mesh>;
  76837. /**
  76838. * An event triggered before drawing the mesh
  76839. */
  76840. readonly onBeforeDrawObservable: Observable<Mesh>;
  76841. private _onBeforeDrawObserver;
  76842. /**
  76843. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  76844. */
  76845. onBeforeDraw: () => void;
  76846. /**
  76847. * Gets the delay loading state of the mesh (when delay loading is turned on)
  76848. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  76849. */
  76850. delayLoadState: number;
  76851. /**
  76852. * Gets the list of instances created from this mesh
  76853. * it is not supposed to be modified manually.
  76854. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  76855. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  76856. */
  76857. instances: InstancedMesh[];
  76858. /**
  76859. * Gets the file containing delay loading data for this mesh
  76860. */
  76861. delayLoadingFile: string;
  76862. /** @hidden */
  76863. _binaryInfo: any;
  76864. private _LODLevels;
  76865. /**
  76866. * User defined function used to change how LOD level selection is done
  76867. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  76868. */
  76869. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  76870. private _morphTargetManager;
  76871. /**
  76872. * Gets or sets the morph target manager
  76873. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  76874. */
  76875. morphTargetManager: Nullable<MorphTargetManager>;
  76876. /** @hidden */
  76877. _creationDataStorage: Nullable<_CreationDataStorage>;
  76878. /** @hidden */
  76879. _geometry: Nullable<Geometry>;
  76880. /** @hidden */
  76881. _delayInfo: Array<string>;
  76882. /** @hidden */
  76883. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  76884. /** @hidden */
  76885. _instanceDataStorage: _InstanceDataStorage;
  76886. private _effectiveMaterial;
  76887. /** @hidden */
  76888. _shouldGenerateFlatShading: boolean;
  76889. private _preActivateId;
  76890. /** @hidden */
  76891. _originalBuilderSideOrientation: number;
  76892. /**
  76893. * Use this property to change the original side orientation defined at construction time
  76894. */
  76895. overrideMaterialSideOrientation: Nullable<number>;
  76896. private _areNormalsFrozen;
  76897. private _sourcePositions;
  76898. private _sourceNormals;
  76899. private _source;
  76900. private meshMap;
  76901. /**
  76902. * Gets the source mesh (the one used to clone this one from)
  76903. */
  76904. readonly source: Nullable<Mesh>;
  76905. /**
  76906. * Gets or sets a boolean indicating that this mesh does not use index buffer
  76907. */
  76908. isUnIndexed: boolean;
  76909. /**
  76910. * @constructor
  76911. * @param name The value used by scene.getMeshByName() to do a lookup.
  76912. * @param scene The scene to add this mesh to.
  76913. * @param parent The parent of this mesh, if it has one
  76914. * @param source An optional Mesh from which geometry is shared, cloned.
  76915. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  76916. * When false, achieved by calling a clone(), also passing False.
  76917. * This will make creation of children, recursive.
  76918. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  76919. */
  76920. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  76921. /**
  76922. * Gets the class name
  76923. * @returns the string "Mesh".
  76924. */
  76925. getClassName(): string;
  76926. /** @hidden */
  76927. readonly _isMesh: boolean;
  76928. /**
  76929. * Returns a description of this mesh
  76930. * @param fullDetails define if full details about this mesh must be used
  76931. * @returns a descriptive string representing this mesh
  76932. */
  76933. toString(fullDetails?: boolean): string;
  76934. /** @hidden */
  76935. _unBindEffect(): void;
  76936. /**
  76937. * Gets a boolean indicating if this mesh has LOD
  76938. */
  76939. readonly hasLODLevels: boolean;
  76940. /**
  76941. * Gets the list of MeshLODLevel associated with the current mesh
  76942. * @returns an array of MeshLODLevel
  76943. */
  76944. getLODLevels(): MeshLODLevel[];
  76945. private _sortLODLevels;
  76946. /**
  76947. * Add a mesh as LOD level triggered at the given distance.
  76948. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  76949. * @param distance The distance from the center of the object to show this level
  76950. * @param mesh The mesh to be added as LOD level (can be null)
  76951. * @return This mesh (for chaining)
  76952. */
  76953. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  76954. /**
  76955. * Returns the LOD level mesh at the passed distance or null if not found.
  76956. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  76957. * @param distance The distance from the center of the object to show this level
  76958. * @returns a Mesh or `null`
  76959. */
  76960. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  76961. /**
  76962. * Remove a mesh from the LOD array
  76963. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  76964. * @param mesh defines the mesh to be removed
  76965. * @return This mesh (for chaining)
  76966. */
  76967. removeLODLevel(mesh: Mesh): Mesh;
  76968. /**
  76969. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  76970. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  76971. * @param camera defines the camera to use to compute distance
  76972. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  76973. * @return This mesh (for chaining)
  76974. */
  76975. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  76976. /**
  76977. * Gets the mesh internal Geometry object
  76978. */
  76979. readonly geometry: Nullable<Geometry>;
  76980. /**
  76981. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  76982. * @returns the total number of vertices
  76983. */
  76984. getTotalVertices(): number;
  76985. /**
  76986. * Returns the content of an associated vertex buffer
  76987. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  76988. * - VertexBuffer.PositionKind
  76989. * - VertexBuffer.UVKind
  76990. * - VertexBuffer.UV2Kind
  76991. * - VertexBuffer.UV3Kind
  76992. * - VertexBuffer.UV4Kind
  76993. * - VertexBuffer.UV5Kind
  76994. * - VertexBuffer.UV6Kind
  76995. * - VertexBuffer.ColorKind
  76996. * - VertexBuffer.MatricesIndicesKind
  76997. * - VertexBuffer.MatricesIndicesExtraKind
  76998. * - VertexBuffer.MatricesWeightsKind
  76999. * - VertexBuffer.MatricesWeightsExtraKind
  77000. * @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
  77001. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  77002. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  77003. */
  77004. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  77005. /**
  77006. * Returns the mesh VertexBuffer object from the requested `kind`
  77007. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77008. * - VertexBuffer.PositionKind
  77009. * - VertexBuffer.UVKind
  77010. * - VertexBuffer.UV2Kind
  77011. * - VertexBuffer.UV3Kind
  77012. * - VertexBuffer.UV4Kind
  77013. * - VertexBuffer.UV5Kind
  77014. * - VertexBuffer.UV6Kind
  77015. * - VertexBuffer.ColorKind
  77016. * - VertexBuffer.MatricesIndicesKind
  77017. * - VertexBuffer.MatricesIndicesExtraKind
  77018. * - VertexBuffer.MatricesWeightsKind
  77019. * - VertexBuffer.MatricesWeightsExtraKind
  77020. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  77021. */
  77022. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  77023. /**
  77024. * Tests if a specific vertex buffer is associated with this mesh
  77025. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  77026. * - VertexBuffer.PositionKind
  77027. * - VertexBuffer.UVKind
  77028. * - VertexBuffer.UV2Kind
  77029. * - VertexBuffer.UV3Kind
  77030. * - VertexBuffer.UV4Kind
  77031. * - VertexBuffer.UV5Kind
  77032. * - VertexBuffer.UV6Kind
  77033. * - VertexBuffer.ColorKind
  77034. * - VertexBuffer.MatricesIndicesKind
  77035. * - VertexBuffer.MatricesIndicesExtraKind
  77036. * - VertexBuffer.MatricesWeightsKind
  77037. * - VertexBuffer.MatricesWeightsExtraKind
  77038. * @returns a boolean
  77039. */
  77040. isVerticesDataPresent(kind: string): boolean;
  77041. /**
  77042. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  77043. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  77044. * - VertexBuffer.PositionKind
  77045. * - VertexBuffer.UVKind
  77046. * - VertexBuffer.UV2Kind
  77047. * - VertexBuffer.UV3Kind
  77048. * - VertexBuffer.UV4Kind
  77049. * - VertexBuffer.UV5Kind
  77050. * - VertexBuffer.UV6Kind
  77051. * - VertexBuffer.ColorKind
  77052. * - VertexBuffer.MatricesIndicesKind
  77053. * - VertexBuffer.MatricesIndicesExtraKind
  77054. * - VertexBuffer.MatricesWeightsKind
  77055. * - VertexBuffer.MatricesWeightsExtraKind
  77056. * @returns a boolean
  77057. */
  77058. isVertexBufferUpdatable(kind: string): boolean;
  77059. /**
  77060. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  77061. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77062. * - VertexBuffer.PositionKind
  77063. * - VertexBuffer.UVKind
  77064. * - VertexBuffer.UV2Kind
  77065. * - VertexBuffer.UV3Kind
  77066. * - VertexBuffer.UV4Kind
  77067. * - VertexBuffer.UV5Kind
  77068. * - VertexBuffer.UV6Kind
  77069. * - VertexBuffer.ColorKind
  77070. * - VertexBuffer.MatricesIndicesKind
  77071. * - VertexBuffer.MatricesIndicesExtraKind
  77072. * - VertexBuffer.MatricesWeightsKind
  77073. * - VertexBuffer.MatricesWeightsExtraKind
  77074. * @returns an array of strings
  77075. */
  77076. getVerticesDataKinds(): string[];
  77077. /**
  77078. * Returns a positive integer : the total number of indices in this mesh geometry.
  77079. * @returns the numner of indices or zero if the mesh has no geometry.
  77080. */
  77081. getTotalIndices(): number;
  77082. /**
  77083. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  77084. * @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.
  77085. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  77086. * @returns the indices array or an empty array if the mesh has no geometry
  77087. */
  77088. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  77089. readonly isBlocked: boolean;
  77090. /**
  77091. * Determine if the current mesh is ready to be rendered
  77092. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  77093. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  77094. * @returns true if all associated assets are ready (material, textures, shaders)
  77095. */
  77096. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  77097. /**
  77098. * 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.
  77099. */
  77100. readonly areNormalsFrozen: boolean;
  77101. /**
  77102. * 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.
  77103. * @returns the current mesh
  77104. */
  77105. freezeNormals(): Mesh;
  77106. /**
  77107. * 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
  77108. * @returns the current mesh
  77109. */
  77110. unfreezeNormals(): Mesh;
  77111. /**
  77112. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  77113. */
  77114. overridenInstanceCount: number;
  77115. /** @hidden */
  77116. _preActivate(): Mesh;
  77117. /** @hidden */
  77118. _preActivateForIntermediateRendering(renderId: number): Mesh;
  77119. /** @hidden */
  77120. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  77121. /**
  77122. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  77123. * This means the mesh underlying bounding box and sphere are recomputed.
  77124. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  77125. * @returns the current mesh
  77126. */
  77127. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  77128. /** @hidden */
  77129. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  77130. /**
  77131. * This function will subdivide the mesh into multiple submeshes
  77132. * @param count defines the expected number of submeshes
  77133. */
  77134. subdivide(count: number): void;
  77135. /**
  77136. * Copy a FloatArray into a specific associated vertex buffer
  77137. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  77138. * - VertexBuffer.PositionKind
  77139. * - VertexBuffer.UVKind
  77140. * - VertexBuffer.UV2Kind
  77141. * - VertexBuffer.UV3Kind
  77142. * - VertexBuffer.UV4Kind
  77143. * - VertexBuffer.UV5Kind
  77144. * - VertexBuffer.UV6Kind
  77145. * - VertexBuffer.ColorKind
  77146. * - VertexBuffer.MatricesIndicesKind
  77147. * - VertexBuffer.MatricesIndicesExtraKind
  77148. * - VertexBuffer.MatricesWeightsKind
  77149. * - VertexBuffer.MatricesWeightsExtraKind
  77150. * @param data defines the data source
  77151. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  77152. * @param stride defines the data stride size (can be null)
  77153. * @returns the current mesh
  77154. */
  77155. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  77156. /**
  77157. * Flags an associated vertex buffer as updatable
  77158. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  77159. * - VertexBuffer.PositionKind
  77160. * - VertexBuffer.UVKind
  77161. * - VertexBuffer.UV2Kind
  77162. * - VertexBuffer.UV3Kind
  77163. * - VertexBuffer.UV4Kind
  77164. * - VertexBuffer.UV5Kind
  77165. * - VertexBuffer.UV6Kind
  77166. * - VertexBuffer.ColorKind
  77167. * - VertexBuffer.MatricesIndicesKind
  77168. * - VertexBuffer.MatricesIndicesExtraKind
  77169. * - VertexBuffer.MatricesWeightsKind
  77170. * - VertexBuffer.MatricesWeightsExtraKind
  77171. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  77172. */
  77173. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  77174. /**
  77175. * Sets the mesh global Vertex Buffer
  77176. * @param buffer defines the buffer to use
  77177. * @returns the current mesh
  77178. */
  77179. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  77180. /**
  77181. * Update a specific associated vertex buffer
  77182. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  77183. * - VertexBuffer.PositionKind
  77184. * - VertexBuffer.UVKind
  77185. * - VertexBuffer.UV2Kind
  77186. * - VertexBuffer.UV3Kind
  77187. * - VertexBuffer.UV4Kind
  77188. * - VertexBuffer.UV5Kind
  77189. * - VertexBuffer.UV6Kind
  77190. * - VertexBuffer.ColorKind
  77191. * - VertexBuffer.MatricesIndicesKind
  77192. * - VertexBuffer.MatricesIndicesExtraKind
  77193. * - VertexBuffer.MatricesWeightsKind
  77194. * - VertexBuffer.MatricesWeightsExtraKind
  77195. * @param data defines the data source
  77196. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  77197. * @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)
  77198. * @returns the current mesh
  77199. */
  77200. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  77201. /**
  77202. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  77203. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  77204. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  77205. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  77206. * @returns the current mesh
  77207. */
  77208. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  77209. /**
  77210. * Creates a un-shared specific occurence of the geometry for the mesh.
  77211. * @returns the current mesh
  77212. */
  77213. makeGeometryUnique(): Mesh;
  77214. /**
  77215. * Set the index buffer of this mesh
  77216. * @param indices defines the source data
  77217. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  77218. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  77219. * @returns the current mesh
  77220. */
  77221. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  77222. /**
  77223. * Update the current index buffer
  77224. * @param indices defines the source data
  77225. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  77226. * @returns the current mesh
  77227. */
  77228. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  77229. /**
  77230. * Invert the geometry to move from a right handed system to a left handed one.
  77231. * @returns the current mesh
  77232. */
  77233. toLeftHanded(): Mesh;
  77234. /** @hidden */
  77235. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  77236. /** @hidden */
  77237. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  77238. /**
  77239. * Registers for this mesh a javascript function called just before the rendering process
  77240. * @param func defines the function to call before rendering this mesh
  77241. * @returns the current mesh
  77242. */
  77243. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  77244. /**
  77245. * Disposes a previously registered javascript function called before the rendering
  77246. * @param func defines the function to remove
  77247. * @returns the current mesh
  77248. */
  77249. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  77250. /**
  77251. * Registers for this mesh a javascript function called just after the rendering is complete
  77252. * @param func defines the function to call after rendering this mesh
  77253. * @returns the current mesh
  77254. */
  77255. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  77256. /**
  77257. * Disposes a previously registered javascript function called after the rendering.
  77258. * @param func defines the function to remove
  77259. * @returns the current mesh
  77260. */
  77261. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  77262. /** @hidden */
  77263. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  77264. /** @hidden */
  77265. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  77266. /** @hidden */
  77267. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  77268. /**
  77269. * 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
  77270. * @param subMesh defines the subMesh to render
  77271. * @param enableAlphaMode defines if alpha mode can be changed
  77272. * @returns the current mesh
  77273. */
  77274. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  77275. private _onBeforeDraw;
  77276. /**
  77277. * Renormalize the mesh and patch it up if there are no weights
  77278. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  77279. * However in the case of zero weights then we set just a single influence to 1.
  77280. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  77281. */
  77282. cleanMatrixWeights(): void;
  77283. private normalizeSkinFourWeights;
  77284. private normalizeSkinWeightsAndExtra;
  77285. /**
  77286. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  77287. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  77288. * the user know there was an issue with importing the mesh
  77289. * @returns a validation object with skinned, valid and report string
  77290. */
  77291. validateSkinning(): {
  77292. skinned: boolean;
  77293. valid: boolean;
  77294. report: string;
  77295. };
  77296. /** @hidden */
  77297. _checkDelayState(): Mesh;
  77298. private _queueLoad;
  77299. /**
  77300. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  77301. * A mesh is in the frustum if its bounding box intersects the frustum
  77302. * @param frustumPlanes defines the frustum to test
  77303. * @returns true if the mesh is in the frustum planes
  77304. */
  77305. isInFrustum(frustumPlanes: Plane[]): boolean;
  77306. /**
  77307. * Sets the mesh material by the material or multiMaterial `id` property
  77308. * @param id is a string identifying the material or the multiMaterial
  77309. * @returns the current mesh
  77310. */
  77311. setMaterialByID(id: string): Mesh;
  77312. /**
  77313. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  77314. * @returns an array of IAnimatable
  77315. */
  77316. getAnimatables(): IAnimatable[];
  77317. /**
  77318. * Modifies the mesh geometry according to the passed transformation matrix.
  77319. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  77320. * The mesh normals are modified using the same transformation.
  77321. * Note that, under the hood, this method sets a new VertexBuffer each call.
  77322. * @param transform defines the transform matrix to use
  77323. * @see http://doc.babylonjs.com/resources/baking_transformations
  77324. * @returns the current mesh
  77325. */
  77326. bakeTransformIntoVertices(transform: Matrix): Mesh;
  77327. /**
  77328. * Modifies the mesh geometry according to its own current World Matrix.
  77329. * The mesh World Matrix is then reset.
  77330. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  77331. * Note that, under the hood, this method sets a new VertexBuffer each call.
  77332. * @see http://doc.babylonjs.com/resources/baking_transformations
  77333. * @returns the current mesh
  77334. */
  77335. bakeCurrentTransformIntoVertices(): Mesh;
  77336. /** @hidden */
  77337. readonly _positions: Nullable<Vector3[]>;
  77338. /** @hidden */
  77339. _resetPointsArrayCache(): Mesh;
  77340. /** @hidden */
  77341. _generatePointsArray(): boolean;
  77342. /**
  77343. * Returns a new Mesh object generated from the current mesh properties.
  77344. * This method must not get confused with createInstance()
  77345. * @param name is a string, the name given to the new mesh
  77346. * @param newParent can be any Node object (default `null`)
  77347. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  77348. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  77349. * @returns a new mesh
  77350. */
  77351. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  77352. /**
  77353. * Releases resources associated with this mesh.
  77354. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  77355. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  77356. */
  77357. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  77358. /**
  77359. * Modifies the mesh geometry according to a displacement map.
  77360. * 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.
  77361. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  77362. * @param url is a string, the URL from the image file is to be downloaded.
  77363. * @param minHeight is the lower limit of the displacement.
  77364. * @param maxHeight is the upper limit of the displacement.
  77365. * @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.
  77366. * @param uvOffset is an optional vector2 used to offset UV.
  77367. * @param uvScale is an optional vector2 used to scale UV.
  77368. * @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.
  77369. * @returns the Mesh.
  77370. */
  77371. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  77372. /**
  77373. * Modifies the mesh geometry according to a displacementMap buffer.
  77374. * 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.
  77375. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  77376. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  77377. * @param heightMapWidth is the width of the buffer image.
  77378. * @param heightMapHeight is the height of the buffer image.
  77379. * @param minHeight is the lower limit of the displacement.
  77380. * @param maxHeight is the upper limit of the displacement.
  77381. * @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.
  77382. * @param uvOffset is an optional vector2 used to offset UV.
  77383. * @param uvScale is an optional vector2 used to scale UV.
  77384. * @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.
  77385. * @returns the Mesh.
  77386. */
  77387. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  77388. /**
  77389. * Modify the mesh to get a flat shading rendering.
  77390. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  77391. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  77392. * @returns current mesh
  77393. */
  77394. convertToFlatShadedMesh(): Mesh;
  77395. /**
  77396. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  77397. * In other words, more vertices, no more indices and a single bigger VBO.
  77398. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  77399. * @returns current mesh
  77400. */
  77401. convertToUnIndexedMesh(): Mesh;
  77402. /**
  77403. * Inverses facet orientations.
  77404. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  77405. * @param flipNormals will also inverts the normals
  77406. * @returns current mesh
  77407. */
  77408. flipFaces(flipNormals?: boolean): Mesh;
  77409. /** @hidden */
  77410. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  77411. /** @hidden */
  77412. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  77413. /**
  77414. * Creates a new InstancedMesh object from the mesh model.
  77415. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  77416. * @param name defines the name of the new instance
  77417. * @returns a new InstancedMesh
  77418. */
  77419. createInstance(name: string): InstancedMesh;
  77420. /**
  77421. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  77422. * After this call, all the mesh instances have the same submeshes than the current mesh.
  77423. * @returns the current mesh
  77424. */
  77425. synchronizeInstances(): Mesh;
  77426. /**
  77427. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  77428. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  77429. * This should be used together with the simplification to avoid disappearing triangles.
  77430. * @param successCallback an optional success callback to be called after the optimization finished.
  77431. * @returns the current mesh
  77432. */
  77433. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  77434. /**
  77435. * Serialize current mesh
  77436. * @param serializationObject defines the object which will receive the serialization data
  77437. */
  77438. serialize(serializationObject: any): void;
  77439. /** @hidden */
  77440. _syncGeometryWithMorphTargetManager(): void;
  77441. /** @hidden */
  77442. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  77443. /**
  77444. * Returns a new Mesh object parsed from the source provided.
  77445. * @param parsedMesh is the source
  77446. * @param scene defines the hosting scene
  77447. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  77448. * @returns a new Mesh
  77449. */
  77450. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  77451. /**
  77452. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  77453. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77454. * @param name defines the name of the mesh to create
  77455. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  77456. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  77457. * @param closePath creates a seam between the first and the last points of each path of the path array
  77458. * @param offset is taken in account only if the `pathArray` is containing a single path
  77459. * @param scene defines the hosting scene
  77460. * @param updatable defines if the mesh must be flagged as updatable
  77461. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77462. * @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)
  77463. * @returns a new Mesh
  77464. */
  77465. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  77466. /**
  77467. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  77468. * @param name defines the name of the mesh to create
  77469. * @param radius sets the radius size (float) of the polygon (default 0.5)
  77470. * @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
  77471. * @param scene defines the hosting scene
  77472. * @param updatable defines if the mesh must be flagged as updatable
  77473. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77474. * @returns a new Mesh
  77475. */
  77476. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  77477. /**
  77478. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  77479. * @param name defines the name of the mesh to create
  77480. * @param size sets the size (float) of each box side (default 1)
  77481. * @param scene defines the hosting scene
  77482. * @param updatable defines if the mesh must be flagged as updatable
  77483. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77484. * @returns a new Mesh
  77485. */
  77486. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  77487. /**
  77488. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  77489. * @param name defines the name of the mesh to create
  77490. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  77491. * @param diameter sets the diameter size (float) of the sphere (default 1)
  77492. * @param scene defines the hosting scene
  77493. * @param updatable defines if the mesh must be flagged as updatable
  77494. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77495. * @returns a new Mesh
  77496. */
  77497. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77498. /**
  77499. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  77500. * @param name defines the name of the mesh to create
  77501. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  77502. * @param diameterTop set the top cap diameter (floats, default 1)
  77503. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  77504. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  77505. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  77506. * @param scene defines the hosting scene
  77507. * @param updatable defines if the mesh must be flagged as updatable
  77508. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77509. * @returns a new Mesh
  77510. */
  77511. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  77512. /**
  77513. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  77514. * @param name defines the name of the mesh to create
  77515. * @param diameter sets the diameter size (float) of the torus (default 1)
  77516. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  77517. * @param tessellation sets the number of torus sides (postive integer, default 16)
  77518. * @param scene defines the hosting scene
  77519. * @param updatable defines if the mesh must be flagged as updatable
  77520. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77521. * @returns a new Mesh
  77522. */
  77523. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77524. /**
  77525. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  77526. * @param name defines the name of the mesh to create
  77527. * @param radius sets the global radius size (float) of the torus knot (default 2)
  77528. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  77529. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  77530. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  77531. * @param p the number of windings on X axis (positive integers, default 2)
  77532. * @param q the number of windings on Y axis (positive integers, default 3)
  77533. * @param scene defines the hosting scene
  77534. * @param updatable defines if the mesh must be flagged as updatable
  77535. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77536. * @returns a new Mesh
  77537. */
  77538. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77539. /**
  77540. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  77541. * @param name defines the name of the mesh to create
  77542. * @param points is an array successive Vector3
  77543. * @param scene defines the hosting scene
  77544. * @param updatable defines if the mesh must be flagged as updatable
  77545. * @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).
  77546. * @returns a new Mesh
  77547. */
  77548. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  77549. /**
  77550. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  77551. * @param name defines the name of the mesh to create
  77552. * @param points is an array successive Vector3
  77553. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  77554. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  77555. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  77556. * @param scene defines the hosting scene
  77557. * @param updatable defines if the mesh must be flagged as updatable
  77558. * @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)
  77559. * @returns a new Mesh
  77560. */
  77561. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  77562. /**
  77563. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  77564. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  77565. * 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.
  77566. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77567. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  77568. * Remember you can only change the shape positions, not their number when updating a polygon.
  77569. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  77570. * @param name defines the name of the mesh to create
  77571. * @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
  77572. * @param scene defines the hosting scene
  77573. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  77574. * @param updatable defines if the mesh must be flagged as updatable
  77575. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77576. * @param earcutInjection can be used to inject your own earcut reference
  77577. * @returns a new Mesh
  77578. */
  77579. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  77580. /**
  77581. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  77582. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  77583. * @param name defines the name of the mesh to create
  77584. * @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
  77585. * @param depth defines the height of extrusion
  77586. * @param scene defines the hosting scene
  77587. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  77588. * @param updatable defines if the mesh must be flagged as updatable
  77589. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77590. * @param earcutInjection can be used to inject your own earcut reference
  77591. * @returns a new Mesh
  77592. */
  77593. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  77594. /**
  77595. * Creates an extruded shape mesh.
  77596. * 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
  77597. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77598. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  77599. * @param name defines the name of the mesh to create
  77600. * @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
  77601. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  77602. * @param scale is the value to scale the shape
  77603. * @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
  77604. * @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
  77605. * @param scene defines the hosting scene
  77606. * @param updatable defines if the mesh must be flagged as updatable
  77607. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77608. * @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)
  77609. * @returns a new Mesh
  77610. */
  77611. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  77612. /**
  77613. * Creates an custom extruded shape mesh.
  77614. * The custom extrusion is a parametric shape.
  77615. * It has no predefined shape. Its final shape will depend on the input parameters.
  77616. * Please consider using the same method from the MeshBuilder class instead
  77617. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  77618. * @param name defines the name of the mesh to create
  77619. * @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
  77620. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  77621. * @param scaleFunction is a custom Javascript function called on each path point
  77622. * @param rotationFunction is a custom Javascript function called on each path point
  77623. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  77624. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  77625. * @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
  77626. * @param scene defines the hosting scene
  77627. * @param updatable defines if the mesh must be flagged as updatable
  77628. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77629. * @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)
  77630. * @returns a new Mesh
  77631. */
  77632. 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;
  77633. /**
  77634. * Creates lathe mesh.
  77635. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  77636. * Please consider using the same method from the MeshBuilder class instead
  77637. * @param name defines the name of the mesh to create
  77638. * @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
  77639. * @param radius is the radius value of the lathe
  77640. * @param tessellation is the side number of the lathe.
  77641. * @param scene defines the hosting scene
  77642. * @param updatable defines if the mesh must be flagged as updatable
  77643. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77644. * @returns a new Mesh
  77645. */
  77646. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77647. /**
  77648. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  77649. * @param name defines the name of the mesh to create
  77650. * @param size sets the size (float) of both sides of the plane at once (default 1)
  77651. * @param scene defines the hosting scene
  77652. * @param updatable defines if the mesh must be flagged as updatable
  77653. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77654. * @returns a new Mesh
  77655. */
  77656. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77657. /**
  77658. * Creates a ground mesh.
  77659. * Please consider using the same method from the MeshBuilder class instead
  77660. * @param name defines the name of the mesh to create
  77661. * @param width set the width of the ground
  77662. * @param height set the height of the ground
  77663. * @param subdivisions sets the number of subdivisions per side
  77664. * @param scene defines the hosting scene
  77665. * @param updatable defines if the mesh must be flagged as updatable
  77666. * @returns a new Mesh
  77667. */
  77668. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  77669. /**
  77670. * Creates a tiled ground mesh.
  77671. * Please consider using the same method from the MeshBuilder class instead
  77672. * @param name defines the name of the mesh to create
  77673. * @param xmin set the ground minimum X coordinate
  77674. * @param zmin set the ground minimum Y coordinate
  77675. * @param xmax set the ground maximum X coordinate
  77676. * @param zmax set the ground maximum Z coordinate
  77677. * @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
  77678. * @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
  77679. * @param scene defines the hosting scene
  77680. * @param updatable defines if the mesh must be flagged as updatable
  77681. * @returns a new Mesh
  77682. */
  77683. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  77684. w: number;
  77685. h: number;
  77686. }, precision: {
  77687. w: number;
  77688. h: number;
  77689. }, scene: Scene, updatable?: boolean): Mesh;
  77690. /**
  77691. * Creates a ground mesh from a height map.
  77692. * Please consider using the same method from the MeshBuilder class instead
  77693. * @see http://doc.babylonjs.com/babylon101/height_map
  77694. * @param name defines the name of the mesh to create
  77695. * @param url sets the URL of the height map image resource
  77696. * @param width set the ground width size
  77697. * @param height set the ground height size
  77698. * @param subdivisions sets the number of subdivision per side
  77699. * @param minHeight is the minimum altitude on the ground
  77700. * @param maxHeight is the maximum altitude on the ground
  77701. * @param scene defines the hosting scene
  77702. * @param updatable defines if the mesh must be flagged as updatable
  77703. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  77704. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  77705. * @returns a new Mesh
  77706. */
  77707. 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;
  77708. /**
  77709. * Creates a tube mesh.
  77710. * The tube is a parametric shape.
  77711. * It has no predefined shape. Its final shape will depend on the input parameters.
  77712. * Please consider using the same method from the MeshBuilder class instead
  77713. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77714. * @param name defines the name of the mesh to create
  77715. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  77716. * @param radius sets the tube radius size
  77717. * @param tessellation is the number of sides on the tubular surface
  77718. * @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
  77719. * @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
  77720. * @param scene defines the hosting scene
  77721. * @param updatable defines if the mesh must be flagged as updatable
  77722. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77723. * @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)
  77724. * @returns a new Mesh
  77725. */
  77726. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  77727. (i: number, distance: number): number;
  77728. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  77729. /**
  77730. * Creates a polyhedron mesh.
  77731. * Please consider using the same method from the MeshBuilder class instead.
  77732. * * 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
  77733. * * The parameter `size` (positive float, default 1) sets the polygon size
  77734. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  77735. * * 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`
  77736. * * 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
  77737. * * 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)`)
  77738. * * 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
  77739. * * 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
  77740. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77741. * * If you create a double-sided mesh, you can choose what parts of 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
  77742. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77743. * @param name defines the name of the mesh to create
  77744. * @param options defines the options used to create the mesh
  77745. * @param scene defines the hosting scene
  77746. * @returns a new Mesh
  77747. */
  77748. static CreatePolyhedron(name: string, options: {
  77749. type?: number;
  77750. size?: number;
  77751. sizeX?: number;
  77752. sizeY?: number;
  77753. sizeZ?: number;
  77754. custom?: any;
  77755. faceUV?: Vector4[];
  77756. faceColors?: Color4[];
  77757. updatable?: boolean;
  77758. sideOrientation?: number;
  77759. }, scene: Scene): Mesh;
  77760. /**
  77761. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  77762. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  77763. * * 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`)
  77764. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  77765. * * 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
  77766. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77767. * * If you create a double-sided mesh, you can choose what parts of 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
  77768. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77769. * @param name defines the name of the mesh
  77770. * @param options defines the options used to create the mesh
  77771. * @param scene defines the hosting scene
  77772. * @returns a new Mesh
  77773. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  77774. */
  77775. static CreateIcoSphere(name: string, options: {
  77776. radius?: number;
  77777. flat?: boolean;
  77778. subdivisions?: number;
  77779. sideOrientation?: number;
  77780. updatable?: boolean;
  77781. }, scene: Scene): Mesh;
  77782. /**
  77783. * Creates a decal mesh.
  77784. * Please consider using the same method from the MeshBuilder class instead.
  77785. * A decal is a mesh usually applied as a model onto the surface of another mesh
  77786. * @param name defines the name of the mesh
  77787. * @param sourceMesh defines the mesh receiving the decal
  77788. * @param position sets the position of the decal in world coordinates
  77789. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  77790. * @param size sets the decal scaling
  77791. * @param angle sets the angle to rotate the decal
  77792. * @returns a new Mesh
  77793. */
  77794. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  77795. /**
  77796. * Prepare internal position array for software CPU skinning
  77797. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  77798. */
  77799. setPositionsForCPUSkinning(): Float32Array;
  77800. /**
  77801. * Prepare internal normal array for software CPU skinning
  77802. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  77803. */
  77804. setNormalsForCPUSkinning(): Float32Array;
  77805. /**
  77806. * Updates the vertex buffer by applying transformation from the bones
  77807. * @param skeleton defines the skeleton to apply to current mesh
  77808. * @returns the current mesh
  77809. */
  77810. applySkeleton(skeleton: Skeleton): Mesh;
  77811. /**
  77812. * 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
  77813. * @param meshes defines the list of meshes to scan
  77814. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  77815. */
  77816. static MinMax(meshes: AbstractMesh[]): {
  77817. min: Vector3;
  77818. max: Vector3;
  77819. };
  77820. /**
  77821. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  77822. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  77823. * @returns a vector3
  77824. */
  77825. static Center(meshesOrMinMaxVector: {
  77826. min: Vector3;
  77827. max: Vector3;
  77828. } | AbstractMesh[]): Vector3;
  77829. /**
  77830. * Merge the array of meshes into a single mesh for performance reasons.
  77831. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  77832. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  77833. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  77834. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  77835. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  77836. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  77837. * @returns a new mesh
  77838. */
  77839. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  77840. /** @hidden */
  77841. addInstance(instance: InstancedMesh): void;
  77842. /** @hidden */
  77843. removeInstance(instance: InstancedMesh): void;
  77844. }
  77845. }
  77846. declare module BABYLON {
  77847. /**
  77848. * Base class for the main features of a material in Babylon.js
  77849. */
  77850. export class Material implements IAnimatable {
  77851. /**
  77852. * Returns the triangle fill mode
  77853. */
  77854. static readonly TriangleFillMode: number;
  77855. /**
  77856. * Returns the wireframe mode
  77857. */
  77858. static readonly WireFrameFillMode: number;
  77859. /**
  77860. * Returns the point fill mode
  77861. */
  77862. static readonly PointFillMode: number;
  77863. /**
  77864. * Returns the point list draw mode
  77865. */
  77866. static readonly PointListDrawMode: number;
  77867. /**
  77868. * Returns the line list draw mode
  77869. */
  77870. static readonly LineListDrawMode: number;
  77871. /**
  77872. * Returns the line loop draw mode
  77873. */
  77874. static readonly LineLoopDrawMode: number;
  77875. /**
  77876. * Returns the line strip draw mode
  77877. */
  77878. static readonly LineStripDrawMode: number;
  77879. /**
  77880. * Returns the triangle strip draw mode
  77881. */
  77882. static readonly TriangleStripDrawMode: number;
  77883. /**
  77884. * Returns the triangle fan draw mode
  77885. */
  77886. static readonly TriangleFanDrawMode: number;
  77887. /**
  77888. * Stores the clock-wise side orientation
  77889. */
  77890. static readonly ClockWiseSideOrientation: number;
  77891. /**
  77892. * Stores the counter clock-wise side orientation
  77893. */
  77894. static readonly CounterClockWiseSideOrientation: number;
  77895. /**
  77896. * The dirty texture flag value
  77897. */
  77898. static readonly TextureDirtyFlag: number;
  77899. /**
  77900. * The dirty light flag value
  77901. */
  77902. static readonly LightDirtyFlag: number;
  77903. /**
  77904. * The dirty fresnel flag value
  77905. */
  77906. static readonly FresnelDirtyFlag: number;
  77907. /**
  77908. * The dirty attribute flag value
  77909. */
  77910. static readonly AttributesDirtyFlag: number;
  77911. /**
  77912. * The dirty misc flag value
  77913. */
  77914. static readonly MiscDirtyFlag: number;
  77915. /**
  77916. * The all dirty flag value
  77917. */
  77918. static readonly AllDirtyFlag: number;
  77919. /**
  77920. * The ID of the material
  77921. */
  77922. id: string;
  77923. /**
  77924. * Gets or sets the unique id of the material
  77925. */
  77926. uniqueId: number;
  77927. /**
  77928. * The name of the material
  77929. */
  77930. name: string;
  77931. /**
  77932. * Gets or sets user defined metadata
  77933. */
  77934. metadata: any;
  77935. /**
  77936. * For internal use only. Please do not use.
  77937. */
  77938. reservedDataStore: any;
  77939. /**
  77940. * Specifies if the ready state should be checked on each call
  77941. */
  77942. checkReadyOnEveryCall: boolean;
  77943. /**
  77944. * Specifies if the ready state should be checked once
  77945. */
  77946. checkReadyOnlyOnce: boolean;
  77947. /**
  77948. * The state of the material
  77949. */
  77950. state: string;
  77951. /**
  77952. * The alpha value of the material
  77953. */
  77954. protected _alpha: number;
  77955. /**
  77956. * Sets the alpha value of the material
  77957. */
  77958. /**
  77959. * Gets the alpha value of the material
  77960. */
  77961. alpha: number;
  77962. /**
  77963. * Specifies if back face culling is enabled
  77964. */
  77965. protected _backFaceCulling: boolean;
  77966. /**
  77967. * Sets the back-face culling state
  77968. */
  77969. /**
  77970. * Gets the back-face culling state
  77971. */
  77972. backFaceCulling: boolean;
  77973. /**
  77974. * Stores the value for side orientation
  77975. */
  77976. sideOrientation: number;
  77977. /**
  77978. * Callback triggered when the material is compiled
  77979. */
  77980. onCompiled: (effect: Effect) => void;
  77981. /**
  77982. * Callback triggered when an error occurs
  77983. */
  77984. onError: (effect: Effect, errors: string) => void;
  77985. /**
  77986. * Callback triggered to get the render target textures
  77987. */
  77988. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  77989. /**
  77990. * Gets a boolean indicating that current material needs to register RTT
  77991. */
  77992. readonly hasRenderTargetTextures: boolean;
  77993. /**
  77994. * Specifies if the material should be serialized
  77995. */
  77996. doNotSerialize: boolean;
  77997. /**
  77998. * @hidden
  77999. */
  78000. _storeEffectOnSubMeshes: boolean;
  78001. /**
  78002. * Stores the animations for the material
  78003. */
  78004. animations: Array<Animation>;
  78005. /**
  78006. * An event triggered when the material is disposed
  78007. */
  78008. onDisposeObservable: Observable<Material>;
  78009. /**
  78010. * An observer which watches for dispose events
  78011. */
  78012. private _onDisposeObserver;
  78013. private _onUnBindObservable;
  78014. /**
  78015. * Called during a dispose event
  78016. */
  78017. onDispose: () => void;
  78018. private _onBindObservable;
  78019. /**
  78020. * An event triggered when the material is bound
  78021. */
  78022. readonly onBindObservable: Observable<AbstractMesh>;
  78023. /**
  78024. * An observer which watches for bind events
  78025. */
  78026. private _onBindObserver;
  78027. /**
  78028. * Called during a bind event
  78029. */
  78030. onBind: (Mesh: AbstractMesh) => void;
  78031. /**
  78032. * An event triggered when the material is unbound
  78033. */
  78034. readonly onUnBindObservable: Observable<Material>;
  78035. /**
  78036. * Stores the value of the alpha mode
  78037. */
  78038. private _alphaMode;
  78039. /**
  78040. * Sets the value of the alpha mode.
  78041. *
  78042. * | Value | Type | Description |
  78043. * | --- | --- | --- |
  78044. * | 0 | ALPHA_DISABLE | |
  78045. * | 1 | ALPHA_ADD | |
  78046. * | 2 | ALPHA_COMBINE | |
  78047. * | 3 | ALPHA_SUBTRACT | |
  78048. * | 4 | ALPHA_MULTIPLY | |
  78049. * | 5 | ALPHA_MAXIMIZED | |
  78050. * | 6 | ALPHA_ONEONE | |
  78051. * | 7 | ALPHA_PREMULTIPLIED | |
  78052. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  78053. * | 9 | ALPHA_INTERPOLATE | |
  78054. * | 10 | ALPHA_SCREENMODE | |
  78055. *
  78056. */
  78057. /**
  78058. * Gets the value of the alpha mode
  78059. */
  78060. alphaMode: number;
  78061. /**
  78062. * Stores the state of the need depth pre-pass value
  78063. */
  78064. private _needDepthPrePass;
  78065. /**
  78066. * Sets the need depth pre-pass value
  78067. */
  78068. /**
  78069. * Gets the depth pre-pass value
  78070. */
  78071. needDepthPrePass: boolean;
  78072. /**
  78073. * Specifies if depth writing should be disabled
  78074. */
  78075. disableDepthWrite: boolean;
  78076. /**
  78077. * Specifies if depth writing should be forced
  78078. */
  78079. forceDepthWrite: boolean;
  78080. /**
  78081. * Specifies if there should be a separate pass for culling
  78082. */
  78083. separateCullingPass: boolean;
  78084. /**
  78085. * Stores the state specifing if fog should be enabled
  78086. */
  78087. private _fogEnabled;
  78088. /**
  78089. * Sets the state for enabling fog
  78090. */
  78091. /**
  78092. * Gets the value of the fog enabled state
  78093. */
  78094. fogEnabled: boolean;
  78095. /**
  78096. * Stores the size of points
  78097. */
  78098. pointSize: number;
  78099. /**
  78100. * Stores the z offset value
  78101. */
  78102. zOffset: number;
  78103. /**
  78104. * Gets a value specifying if wireframe mode is enabled
  78105. */
  78106. /**
  78107. * Sets the state of wireframe mode
  78108. */
  78109. wireframe: boolean;
  78110. /**
  78111. * Gets the value specifying if point clouds are enabled
  78112. */
  78113. /**
  78114. * Sets the state of point cloud mode
  78115. */
  78116. pointsCloud: boolean;
  78117. /**
  78118. * Gets the material fill mode
  78119. */
  78120. /**
  78121. * Sets the material fill mode
  78122. */
  78123. fillMode: number;
  78124. /**
  78125. * @hidden
  78126. * Stores the effects for the material
  78127. */
  78128. _effect: Nullable<Effect>;
  78129. /**
  78130. * @hidden
  78131. * Specifies if the material was previously ready
  78132. */
  78133. _wasPreviouslyReady: boolean;
  78134. /**
  78135. * Specifies if uniform buffers should be used
  78136. */
  78137. private _useUBO;
  78138. /**
  78139. * Stores a reference to the scene
  78140. */
  78141. private _scene;
  78142. /**
  78143. * Stores the fill mode state
  78144. */
  78145. private _fillMode;
  78146. /**
  78147. * Specifies if the depth write state should be cached
  78148. */
  78149. private _cachedDepthWriteState;
  78150. /**
  78151. * Stores the uniform buffer
  78152. */
  78153. protected _uniformBuffer: UniformBuffer;
  78154. /** @hidden */
  78155. _indexInSceneMaterialArray: number;
  78156. /** @hidden */
  78157. meshMap: Nullable<{
  78158. [id: string]: AbstractMesh | undefined;
  78159. }>;
  78160. /**
  78161. * Creates a material instance
  78162. * @param name defines the name of the material
  78163. * @param scene defines the scene to reference
  78164. * @param doNotAdd specifies if the material should be added to the scene
  78165. */
  78166. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  78167. /**
  78168. * Returns a string representation of the current material
  78169. * @param fullDetails defines a boolean indicating which levels of logging is desired
  78170. * @returns a string with material information
  78171. */
  78172. toString(fullDetails?: boolean): string;
  78173. /**
  78174. * Gets the class name of the material
  78175. * @returns a string with the class name of the material
  78176. */
  78177. getClassName(): string;
  78178. /**
  78179. * Specifies if updates for the material been locked
  78180. */
  78181. readonly isFrozen: boolean;
  78182. /**
  78183. * Locks updates for the material
  78184. */
  78185. freeze(): void;
  78186. /**
  78187. * Unlocks updates for the material
  78188. */
  78189. unfreeze(): void;
  78190. /**
  78191. * Specifies if the material is ready to be used
  78192. * @param mesh defines the mesh to check
  78193. * @param useInstances specifies if instances should be used
  78194. * @returns a boolean indicating if the material is ready to be used
  78195. */
  78196. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  78197. /**
  78198. * Specifies that the submesh is ready to be used
  78199. * @param mesh defines the mesh to check
  78200. * @param subMesh defines which submesh to check
  78201. * @param useInstances specifies that instances should be used
  78202. * @returns a boolean indicating that the submesh is ready or not
  78203. */
  78204. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  78205. /**
  78206. * Returns the material effect
  78207. * @returns the effect associated with the material
  78208. */
  78209. getEffect(): Nullable<Effect>;
  78210. /**
  78211. * Returns the current scene
  78212. * @returns a Scene
  78213. */
  78214. getScene(): Scene;
  78215. /**
  78216. * Specifies if the material will require alpha blending
  78217. * @returns a boolean specifying if alpha blending is needed
  78218. */
  78219. needAlphaBlending(): boolean;
  78220. /**
  78221. * Specifies if the mesh will require alpha blending
  78222. * @param mesh defines the mesh to check
  78223. * @returns a boolean specifying if alpha blending is needed for the mesh
  78224. */
  78225. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  78226. /**
  78227. * Specifies if this material should be rendered in alpha test mode
  78228. * @returns a boolean specifying if an alpha test is needed.
  78229. */
  78230. needAlphaTesting(): boolean;
  78231. /**
  78232. * Gets the texture used for the alpha test
  78233. * @returns the texture to use for alpha testing
  78234. */
  78235. getAlphaTestTexture(): Nullable<BaseTexture>;
  78236. /**
  78237. * Marks the material to indicate that it needs to be re-calculated
  78238. */
  78239. markDirty(): void;
  78240. /** @hidden */
  78241. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  78242. /**
  78243. * Binds the material to the mesh
  78244. * @param world defines the world transformation matrix
  78245. * @param mesh defines the mesh to bind the material to
  78246. */
  78247. bind(world: Matrix, mesh?: Mesh): void;
  78248. /**
  78249. * Binds the submesh to the material
  78250. * @param world defines the world transformation matrix
  78251. * @param mesh defines the mesh containing the submesh
  78252. * @param subMesh defines the submesh to bind the material to
  78253. */
  78254. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  78255. /**
  78256. * Binds the world matrix to the material
  78257. * @param world defines the world transformation matrix
  78258. */
  78259. bindOnlyWorldMatrix(world: Matrix): void;
  78260. /**
  78261. * Binds the scene's uniform buffer to the effect.
  78262. * @param effect defines the effect to bind to the scene uniform buffer
  78263. * @param sceneUbo defines the uniform buffer storing scene data
  78264. */
  78265. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  78266. /**
  78267. * Binds the view matrix to the effect
  78268. * @param effect defines the effect to bind the view matrix to
  78269. */
  78270. bindView(effect: Effect): void;
  78271. /**
  78272. * Binds the view projection matrix to the effect
  78273. * @param effect defines the effect to bind the view projection matrix to
  78274. */
  78275. bindViewProjection(effect: Effect): void;
  78276. /**
  78277. * Specifies if material alpha testing should be turned on for the mesh
  78278. * @param mesh defines the mesh to check
  78279. */
  78280. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  78281. /**
  78282. * Processes to execute after binding the material to a mesh
  78283. * @param mesh defines the rendered mesh
  78284. */
  78285. protected _afterBind(mesh?: Mesh): void;
  78286. /**
  78287. * Unbinds the material from the mesh
  78288. */
  78289. unbind(): void;
  78290. /**
  78291. * Gets the active textures from the material
  78292. * @returns an array of textures
  78293. */
  78294. getActiveTextures(): BaseTexture[];
  78295. /**
  78296. * Specifies if the material uses a texture
  78297. * @param texture defines the texture to check against the material
  78298. * @returns a boolean specifying if the material uses the texture
  78299. */
  78300. hasTexture(texture: BaseTexture): boolean;
  78301. /**
  78302. * Makes a duplicate of the material, and gives it a new name
  78303. * @param name defines the new name for the duplicated material
  78304. * @returns the cloned material
  78305. */
  78306. clone(name: string): Nullable<Material>;
  78307. /**
  78308. * Gets the meshes bound to the material
  78309. * @returns an array of meshes bound to the material
  78310. */
  78311. getBindedMeshes(): AbstractMesh[];
  78312. /**
  78313. * Force shader compilation
  78314. * @param mesh defines the mesh associated with this material
  78315. * @param onCompiled defines a function to execute once the material is compiled
  78316. * @param options defines the options to configure the compilation
  78317. */
  78318. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  78319. clipPlane: boolean;
  78320. }>): void;
  78321. /**
  78322. * Force shader compilation
  78323. * @param mesh defines the mesh that will use this material
  78324. * @param options defines additional options for compiling the shaders
  78325. * @returns a promise that resolves when the compilation completes
  78326. */
  78327. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  78328. clipPlane: boolean;
  78329. }>): Promise<void>;
  78330. private static readonly _ImageProcessingDirtyCallBack;
  78331. private static readonly _TextureDirtyCallBack;
  78332. private static readonly _FresnelDirtyCallBack;
  78333. private static readonly _MiscDirtyCallBack;
  78334. private static readonly _LightsDirtyCallBack;
  78335. private static readonly _AttributeDirtyCallBack;
  78336. private static _FresnelAndMiscDirtyCallBack;
  78337. private static _TextureAndMiscDirtyCallBack;
  78338. private static readonly _DirtyCallbackArray;
  78339. private static readonly _RunDirtyCallBacks;
  78340. /**
  78341. * Marks a define in the material to indicate that it needs to be re-computed
  78342. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  78343. */
  78344. markAsDirty(flag: number): void;
  78345. /**
  78346. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  78347. * @param func defines a function which checks material defines against the submeshes
  78348. */
  78349. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  78350. /**
  78351. * Indicates that image processing needs to be re-calculated for all submeshes
  78352. */
  78353. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  78354. /**
  78355. * Indicates that textures need to be re-calculated for all submeshes
  78356. */
  78357. protected _markAllSubMeshesAsTexturesDirty(): void;
  78358. /**
  78359. * Indicates that fresnel needs to be re-calculated for all submeshes
  78360. */
  78361. protected _markAllSubMeshesAsFresnelDirty(): void;
  78362. /**
  78363. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  78364. */
  78365. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  78366. /**
  78367. * Indicates that lights need to be re-calculated for all submeshes
  78368. */
  78369. protected _markAllSubMeshesAsLightsDirty(): void;
  78370. /**
  78371. * Indicates that attributes need to be re-calculated for all submeshes
  78372. */
  78373. protected _markAllSubMeshesAsAttributesDirty(): void;
  78374. /**
  78375. * Indicates that misc needs to be re-calculated for all submeshes
  78376. */
  78377. protected _markAllSubMeshesAsMiscDirty(): void;
  78378. /**
  78379. * Indicates that textures and misc need to be re-calculated for all submeshes
  78380. */
  78381. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  78382. /**
  78383. * Disposes the material
  78384. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  78385. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  78386. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  78387. */
  78388. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  78389. /** @hidden */
  78390. private releaseVertexArrayObject;
  78391. /**
  78392. * Serializes this material
  78393. * @returns the serialized material object
  78394. */
  78395. serialize(): any;
  78396. /**
  78397. * Creates a material from parsed material data
  78398. * @param parsedMaterial defines parsed material data
  78399. * @param scene defines the hosting scene
  78400. * @param rootUrl defines the root URL to use to load textures
  78401. * @returns a new material
  78402. */
  78403. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  78404. }
  78405. }
  78406. declare module BABYLON {
  78407. /**
  78408. * Base class for submeshes
  78409. */
  78410. export class BaseSubMesh {
  78411. /** @hidden */
  78412. _materialDefines: Nullable<MaterialDefines>;
  78413. /** @hidden */
  78414. _materialEffect: Nullable<Effect>;
  78415. /**
  78416. * Gets associated effect
  78417. */
  78418. readonly effect: Nullable<Effect>;
  78419. /**
  78420. * Sets associated effect (effect used to render this submesh)
  78421. * @param effect defines the effect to associate with
  78422. * @param defines defines the set of defines used to compile this effect
  78423. */
  78424. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  78425. }
  78426. /**
  78427. * Defines a subdivision inside a mesh
  78428. */
  78429. export class SubMesh extends BaseSubMesh implements ICullable {
  78430. /** the material index to use */
  78431. materialIndex: number;
  78432. /** vertex index start */
  78433. verticesStart: number;
  78434. /** vertices count */
  78435. verticesCount: number;
  78436. /** index start */
  78437. indexStart: number;
  78438. /** indices count */
  78439. indexCount: number;
  78440. /** @hidden */
  78441. _linesIndexCount: number;
  78442. private _mesh;
  78443. private _renderingMesh;
  78444. private _boundingInfo;
  78445. private _linesIndexBuffer;
  78446. /** @hidden */
  78447. _lastColliderWorldVertices: Nullable<Vector3[]>;
  78448. /** @hidden */
  78449. _trianglePlanes: Plane[];
  78450. /** @hidden */
  78451. _lastColliderTransformMatrix: Matrix;
  78452. /** @hidden */
  78453. _renderId: number;
  78454. /** @hidden */
  78455. _alphaIndex: number;
  78456. /** @hidden */
  78457. _distanceToCamera: number;
  78458. /** @hidden */
  78459. _id: number;
  78460. private _currentMaterial;
  78461. /**
  78462. * Add a new submesh to a mesh
  78463. * @param materialIndex defines the material index to use
  78464. * @param verticesStart defines vertex index start
  78465. * @param verticesCount defines vertices count
  78466. * @param indexStart defines index start
  78467. * @param indexCount defines indices count
  78468. * @param mesh defines the parent mesh
  78469. * @param renderingMesh defines an optional rendering mesh
  78470. * @param createBoundingBox defines if bounding box should be created for this submesh
  78471. * @returns the new submesh
  78472. */
  78473. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  78474. /**
  78475. * Creates a new submesh
  78476. * @param materialIndex defines the material index to use
  78477. * @param verticesStart defines vertex index start
  78478. * @param verticesCount defines vertices count
  78479. * @param indexStart defines index start
  78480. * @param indexCount defines indices count
  78481. * @param mesh defines the parent mesh
  78482. * @param renderingMesh defines an optional rendering mesh
  78483. * @param createBoundingBox defines if bounding box should be created for this submesh
  78484. */
  78485. constructor(
  78486. /** the material index to use */
  78487. materialIndex: number,
  78488. /** vertex index start */
  78489. verticesStart: number,
  78490. /** vertices count */
  78491. verticesCount: number,
  78492. /** index start */
  78493. indexStart: number,
  78494. /** indices count */
  78495. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  78496. /**
  78497. * Returns true if this submesh covers the entire parent mesh
  78498. * @ignorenaming
  78499. */
  78500. readonly IsGlobal: boolean;
  78501. /**
  78502. * Returns the submesh BoudingInfo object
  78503. * @returns current bounding info (or mesh's one if the submesh is global)
  78504. */
  78505. getBoundingInfo(): BoundingInfo;
  78506. /**
  78507. * Sets the submesh BoundingInfo
  78508. * @param boundingInfo defines the new bounding info to use
  78509. * @returns the SubMesh
  78510. */
  78511. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  78512. /**
  78513. * Returns the mesh of the current submesh
  78514. * @return the parent mesh
  78515. */
  78516. getMesh(): AbstractMesh;
  78517. /**
  78518. * Returns the rendering mesh of the submesh
  78519. * @returns the rendering mesh (could be different from parent mesh)
  78520. */
  78521. getRenderingMesh(): Mesh;
  78522. /**
  78523. * Returns the submesh material
  78524. * @returns null or the current material
  78525. */
  78526. getMaterial(): Nullable<Material>;
  78527. /**
  78528. * Sets a new updated BoundingInfo object to the submesh
  78529. * @returns the SubMesh
  78530. */
  78531. refreshBoundingInfo(): SubMesh;
  78532. /** @hidden */
  78533. _checkCollision(collider: Collider): boolean;
  78534. /**
  78535. * Updates the submesh BoundingInfo
  78536. * @param world defines the world matrix to use to update the bounding info
  78537. * @returns the submesh
  78538. */
  78539. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  78540. /**
  78541. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  78542. * @param frustumPlanes defines the frustum planes
  78543. * @returns true if the submesh is intersecting with the frustum
  78544. */
  78545. isInFrustum(frustumPlanes: Plane[]): boolean;
  78546. /**
  78547. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  78548. * @param frustumPlanes defines the frustum planes
  78549. * @returns true if the submesh is inside the frustum
  78550. */
  78551. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  78552. /**
  78553. * Renders the submesh
  78554. * @param enableAlphaMode defines if alpha needs to be used
  78555. * @returns the submesh
  78556. */
  78557. render(enableAlphaMode: boolean): SubMesh;
  78558. /**
  78559. * @hidden
  78560. */
  78561. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  78562. /**
  78563. * Checks if the submesh intersects with a ray
  78564. * @param ray defines the ray to test
  78565. * @returns true is the passed ray intersects the submesh bounding box
  78566. */
  78567. canIntersects(ray: Ray): boolean;
  78568. /**
  78569. * Intersects current submesh with a ray
  78570. * @param ray defines the ray to test
  78571. * @param positions defines mesh's positions array
  78572. * @param indices defines mesh's indices array
  78573. * @param fastCheck defines if only bounding info should be used
  78574. * @returns intersection info or null if no intersection
  78575. */
  78576. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  78577. /** @hidden */
  78578. private _intersectLines;
  78579. /** @hidden */
  78580. private _intersectTriangles;
  78581. /** @hidden */
  78582. _rebuild(): void;
  78583. /**
  78584. * Creates a new submesh from the passed mesh
  78585. * @param newMesh defines the new hosting mesh
  78586. * @param newRenderingMesh defines an optional rendering mesh
  78587. * @returns the new submesh
  78588. */
  78589. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  78590. /**
  78591. * Release associated resources
  78592. */
  78593. dispose(): void;
  78594. /**
  78595. * Gets the class name
  78596. * @returns the string "SubMesh".
  78597. */
  78598. getClassName(): string;
  78599. /**
  78600. * Creates a new submesh from indices data
  78601. * @param materialIndex the index of the main mesh material
  78602. * @param startIndex the index where to start the copy in the mesh indices array
  78603. * @param indexCount the number of indices to copy then from the startIndex
  78604. * @param mesh the main mesh to create the submesh from
  78605. * @param renderingMesh the optional rendering mesh
  78606. * @returns a new submesh
  78607. */
  78608. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  78609. }
  78610. }
  78611. declare module BABYLON {
  78612. /**
  78613. * Class used to store geometry data (vertex buffers + index buffer)
  78614. */
  78615. export class Geometry implements IGetSetVerticesData {
  78616. /**
  78617. * Gets or sets the ID of the geometry
  78618. */
  78619. id: string;
  78620. /**
  78621. * Gets or sets the unique ID of the geometry
  78622. */
  78623. uniqueId: number;
  78624. /**
  78625. * Gets the delay loading state of the geometry (none by default which means not delayed)
  78626. */
  78627. delayLoadState: number;
  78628. /**
  78629. * Gets the file containing the data to load when running in delay load state
  78630. */
  78631. delayLoadingFile: Nullable<string>;
  78632. /**
  78633. * Callback called when the geometry is updated
  78634. */
  78635. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  78636. private _scene;
  78637. private _engine;
  78638. private _meshes;
  78639. private _totalVertices;
  78640. /** @hidden */
  78641. _indices: IndicesArray;
  78642. /** @hidden */
  78643. _vertexBuffers: {
  78644. [key: string]: VertexBuffer;
  78645. };
  78646. private _isDisposed;
  78647. private _extend;
  78648. private _boundingBias;
  78649. /** @hidden */
  78650. _delayInfo: Array<string>;
  78651. private _indexBuffer;
  78652. private _indexBufferIsUpdatable;
  78653. /** @hidden */
  78654. _boundingInfo: Nullable<BoundingInfo>;
  78655. /** @hidden */
  78656. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  78657. /** @hidden */
  78658. _softwareSkinningFrameId: number;
  78659. private _vertexArrayObjects;
  78660. private _updatable;
  78661. /** @hidden */
  78662. _positions: Nullable<Vector3[]>;
  78663. /**
  78664. * 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
  78665. */
  78666. /**
  78667. * 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
  78668. */
  78669. boundingBias: Vector2;
  78670. /**
  78671. * Static function used to attach a new empty geometry to a mesh
  78672. * @param mesh defines the mesh to attach the geometry to
  78673. * @returns the new Geometry
  78674. */
  78675. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  78676. /**
  78677. * Creates a new geometry
  78678. * @param id defines the unique ID
  78679. * @param scene defines the hosting scene
  78680. * @param vertexData defines the VertexData used to get geometry data
  78681. * @param updatable defines if geometry must be updatable (false by default)
  78682. * @param mesh defines the mesh that will be associated with the geometry
  78683. */
  78684. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  78685. /**
  78686. * Gets the current extend of the geometry
  78687. */
  78688. readonly extend: {
  78689. minimum: Vector3;
  78690. maximum: Vector3;
  78691. };
  78692. /**
  78693. * Gets the hosting scene
  78694. * @returns the hosting Scene
  78695. */
  78696. getScene(): Scene;
  78697. /**
  78698. * Gets the hosting engine
  78699. * @returns the hosting Engine
  78700. */
  78701. getEngine(): Engine;
  78702. /**
  78703. * Defines if the geometry is ready to use
  78704. * @returns true if the geometry is ready to be used
  78705. */
  78706. isReady(): boolean;
  78707. /**
  78708. * Gets a value indicating that the geometry should not be serialized
  78709. */
  78710. readonly doNotSerialize: boolean;
  78711. /** @hidden */
  78712. _rebuild(): void;
  78713. /**
  78714. * Affects all geometry data in one call
  78715. * @param vertexData defines the geometry data
  78716. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  78717. */
  78718. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  78719. /**
  78720. * Set specific vertex data
  78721. * @param kind defines the data kind (Position, normal, etc...)
  78722. * @param data defines the vertex data to use
  78723. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  78724. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  78725. */
  78726. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  78727. /**
  78728. * Removes a specific vertex data
  78729. * @param kind defines the data kind (Position, normal, etc...)
  78730. */
  78731. removeVerticesData(kind: string): void;
  78732. /**
  78733. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  78734. * @param buffer defines the vertex buffer to use
  78735. * @param totalVertices defines the total number of vertices for position kind (could be null)
  78736. */
  78737. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  78738. /**
  78739. * Update a specific vertex buffer
  78740. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  78741. * It will do nothing if the buffer is not updatable
  78742. * @param kind defines the data kind (Position, normal, etc...)
  78743. * @param data defines the data to use
  78744. * @param offset defines the offset in the target buffer where to store the data
  78745. * @param useBytes set to true if the offset is in bytes
  78746. */
  78747. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  78748. /**
  78749. * Update a specific vertex buffer
  78750. * This function will create a new buffer if the current one is not updatable
  78751. * @param kind defines the data kind (Position, normal, etc...)
  78752. * @param data defines the data to use
  78753. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  78754. */
  78755. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  78756. private _updateBoundingInfo;
  78757. /** @hidden */
  78758. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  78759. /**
  78760. * Gets total number of vertices
  78761. * @returns the total number of vertices
  78762. */
  78763. getTotalVertices(): number;
  78764. /**
  78765. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  78766. * @param kind defines the data kind (Position, normal, etc...)
  78767. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  78768. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  78769. * @returns a float array containing vertex data
  78770. */
  78771. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  78772. /**
  78773. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  78774. * @param kind defines the data kind (Position, normal, etc...)
  78775. * @returns true if the vertex buffer with the specified kind is updatable
  78776. */
  78777. isVertexBufferUpdatable(kind: string): boolean;
  78778. /**
  78779. * Gets a specific vertex buffer
  78780. * @param kind defines the data kind (Position, normal, etc...)
  78781. * @returns a VertexBuffer
  78782. */
  78783. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  78784. /**
  78785. * Returns all vertex buffers
  78786. * @return an object holding all vertex buffers indexed by kind
  78787. */
  78788. getVertexBuffers(): Nullable<{
  78789. [key: string]: VertexBuffer;
  78790. }>;
  78791. /**
  78792. * Gets a boolean indicating if specific vertex buffer is present
  78793. * @param kind defines the data kind (Position, normal, etc...)
  78794. * @returns true if data is present
  78795. */
  78796. isVerticesDataPresent(kind: string): boolean;
  78797. /**
  78798. * Gets a list of all attached data kinds (Position, normal, etc...)
  78799. * @returns a list of string containing all kinds
  78800. */
  78801. getVerticesDataKinds(): string[];
  78802. /**
  78803. * Update index buffer
  78804. * @param indices defines the indices to store in the index buffer
  78805. * @param offset defines the offset in the target buffer where to store the data
  78806. */
  78807. updateIndices(indices: IndicesArray, offset?: number): void;
  78808. /**
  78809. * Creates a new index buffer
  78810. * @param indices defines the indices to store in the index buffer
  78811. * @param totalVertices defines the total number of vertices (could be null)
  78812. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  78813. */
  78814. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  78815. /**
  78816. * Return the total number of indices
  78817. * @returns the total number of indices
  78818. */
  78819. getTotalIndices(): number;
  78820. /**
  78821. * Gets the index buffer array
  78822. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  78823. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  78824. * @returns the index buffer array
  78825. */
  78826. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  78827. /**
  78828. * Gets the index buffer
  78829. * @return the index buffer
  78830. */
  78831. getIndexBuffer(): Nullable<WebGLBuffer>;
  78832. /** @hidden */
  78833. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  78834. /**
  78835. * Release the associated resources for a specific mesh
  78836. * @param mesh defines the source mesh
  78837. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  78838. */
  78839. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  78840. /**
  78841. * Apply current geometry to a given mesh
  78842. * @param mesh defines the mesh to apply geometry to
  78843. */
  78844. applyToMesh(mesh: Mesh): void;
  78845. private _updateExtend;
  78846. private _applyToMesh;
  78847. private notifyUpdate;
  78848. /**
  78849. * Load the geometry if it was flagged as delay loaded
  78850. * @param scene defines the hosting scene
  78851. * @param onLoaded defines a callback called when the geometry is loaded
  78852. */
  78853. load(scene: Scene, onLoaded?: () => void): void;
  78854. private _queueLoad;
  78855. /**
  78856. * Invert the geometry to move from a right handed system to a left handed one.
  78857. */
  78858. toLeftHanded(): void;
  78859. /** @hidden */
  78860. _resetPointsArrayCache(): void;
  78861. /** @hidden */
  78862. _generatePointsArray(): boolean;
  78863. /**
  78864. * Gets a value indicating if the geometry is disposed
  78865. * @returns true if the geometry was disposed
  78866. */
  78867. isDisposed(): boolean;
  78868. private _disposeVertexArrayObjects;
  78869. /**
  78870. * Free all associated resources
  78871. */
  78872. dispose(): void;
  78873. /**
  78874. * Clone the current geometry into a new geometry
  78875. * @param id defines the unique ID of the new geometry
  78876. * @returns a new geometry object
  78877. */
  78878. copy(id: string): Geometry;
  78879. /**
  78880. * Serialize the current geometry info (and not the vertices data) into a JSON object
  78881. * @return a JSON representation of the current geometry data (without the vertices data)
  78882. */
  78883. serialize(): any;
  78884. private toNumberArray;
  78885. /**
  78886. * Serialize all vertices data into a JSON oject
  78887. * @returns a JSON representation of the current geometry data
  78888. */
  78889. serializeVerticeData(): any;
  78890. /**
  78891. * Extracts a clone of a mesh geometry
  78892. * @param mesh defines the source mesh
  78893. * @param id defines the unique ID of the new geometry object
  78894. * @returns the new geometry object
  78895. */
  78896. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  78897. /**
  78898. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  78899. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  78900. * Be aware Math.random() could cause collisions, but:
  78901. * "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"
  78902. * @returns a string containing a new GUID
  78903. */
  78904. static RandomId(): string;
  78905. /** @hidden */
  78906. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  78907. private static _CleanMatricesWeights;
  78908. /**
  78909. * Create a new geometry from persisted data (Using .babylon file format)
  78910. * @param parsedVertexData defines the persisted data
  78911. * @param scene defines the hosting scene
  78912. * @param rootUrl defines the root url to use to load assets (like delayed data)
  78913. * @returns the new geometry object
  78914. */
  78915. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  78916. }
  78917. }
  78918. declare module BABYLON {
  78919. /**
  78920. * Define an interface for all classes that will get and set the data on vertices
  78921. */
  78922. export interface IGetSetVerticesData {
  78923. /**
  78924. * Gets a boolean indicating if specific vertex data is present
  78925. * @param kind defines the vertex data kind to use
  78926. * @returns true is data kind is present
  78927. */
  78928. isVerticesDataPresent(kind: string): boolean;
  78929. /**
  78930. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  78931. * @param kind defines the data kind (Position, normal, etc...)
  78932. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  78933. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  78934. * @returns a float array containing vertex data
  78935. */
  78936. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  78937. /**
  78938. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  78939. * @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.
  78940. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  78941. * @returns the indices array or an empty array if the mesh has no geometry
  78942. */
  78943. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  78944. /**
  78945. * Set specific vertex data
  78946. * @param kind defines the data kind (Position, normal, etc...)
  78947. * @param data defines the vertex data to use
  78948. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  78949. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  78950. */
  78951. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  78952. /**
  78953. * Update a specific associated vertex buffer
  78954. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  78955. * - VertexBuffer.PositionKind
  78956. * - VertexBuffer.UVKind
  78957. * - VertexBuffer.UV2Kind
  78958. * - VertexBuffer.UV3Kind
  78959. * - VertexBuffer.UV4Kind
  78960. * - VertexBuffer.UV5Kind
  78961. * - VertexBuffer.UV6Kind
  78962. * - VertexBuffer.ColorKind
  78963. * - VertexBuffer.MatricesIndicesKind
  78964. * - VertexBuffer.MatricesIndicesExtraKind
  78965. * - VertexBuffer.MatricesWeightsKind
  78966. * - VertexBuffer.MatricesWeightsExtraKind
  78967. * @param data defines the data source
  78968. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  78969. * @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)
  78970. */
  78971. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  78972. /**
  78973. * Creates a new index buffer
  78974. * @param indices defines the indices to store in the index buffer
  78975. * @param totalVertices defines the total number of vertices (could be null)
  78976. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  78977. */
  78978. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  78979. }
  78980. /**
  78981. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  78982. */
  78983. export class VertexData {
  78984. /**
  78985. * Mesh side orientation : usually the external or front surface
  78986. */
  78987. static readonly FRONTSIDE: number;
  78988. /**
  78989. * Mesh side orientation : usually the internal or back surface
  78990. */
  78991. static readonly BACKSIDE: number;
  78992. /**
  78993. * Mesh side orientation : both internal and external or front and back surfaces
  78994. */
  78995. static readonly DOUBLESIDE: number;
  78996. /**
  78997. * Mesh side orientation : by default, `FRONTSIDE`
  78998. */
  78999. static readonly DEFAULTSIDE: number;
  79000. /**
  79001. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  79002. */
  79003. positions: Nullable<FloatArray>;
  79004. /**
  79005. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  79006. */
  79007. normals: Nullable<FloatArray>;
  79008. /**
  79009. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  79010. */
  79011. tangents: Nullable<FloatArray>;
  79012. /**
  79013. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79014. */
  79015. uvs: Nullable<FloatArray>;
  79016. /**
  79017. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79018. */
  79019. uvs2: Nullable<FloatArray>;
  79020. /**
  79021. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79022. */
  79023. uvs3: Nullable<FloatArray>;
  79024. /**
  79025. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79026. */
  79027. uvs4: Nullable<FloatArray>;
  79028. /**
  79029. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79030. */
  79031. uvs5: Nullable<FloatArray>;
  79032. /**
  79033. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79034. */
  79035. uvs6: Nullable<FloatArray>;
  79036. /**
  79037. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  79038. */
  79039. colors: Nullable<FloatArray>;
  79040. /**
  79041. * 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).
  79042. */
  79043. matricesIndices: Nullable<FloatArray>;
  79044. /**
  79045. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  79046. */
  79047. matricesWeights: Nullable<FloatArray>;
  79048. /**
  79049. * An array extending the number of possible indices
  79050. */
  79051. matricesIndicesExtra: Nullable<FloatArray>;
  79052. /**
  79053. * An array extending the number of possible weights when the number of indices is extended
  79054. */
  79055. matricesWeightsExtra: Nullable<FloatArray>;
  79056. /**
  79057. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  79058. */
  79059. indices: Nullable<IndicesArray>;
  79060. /**
  79061. * Uses the passed data array to set the set the values for the specified kind of data
  79062. * @param data a linear array of floating numbers
  79063. * @param kind the type of data that is being set, eg positions, colors etc
  79064. */
  79065. set(data: FloatArray, kind: string): void;
  79066. /**
  79067. * Associates the vertexData to the passed Mesh.
  79068. * Sets it as updatable or not (default `false`)
  79069. * @param mesh the mesh the vertexData is applied to
  79070. * @param updatable when used and having the value true allows new data to update the vertexData
  79071. * @returns the VertexData
  79072. */
  79073. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  79074. /**
  79075. * Associates the vertexData to the passed Geometry.
  79076. * Sets it as updatable or not (default `false`)
  79077. * @param geometry the geometry the vertexData is applied to
  79078. * @param updatable when used and having the value true allows new data to update the vertexData
  79079. * @returns VertexData
  79080. */
  79081. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  79082. /**
  79083. * Updates the associated mesh
  79084. * @param mesh the mesh to be updated
  79085. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  79086. * @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
  79087. * @returns VertexData
  79088. */
  79089. updateMesh(mesh: Mesh): VertexData;
  79090. /**
  79091. * Updates the associated geometry
  79092. * @param geometry the geometry to be updated
  79093. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  79094. * @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
  79095. * @returns VertexData.
  79096. */
  79097. updateGeometry(geometry: Geometry): VertexData;
  79098. private _applyTo;
  79099. private _update;
  79100. /**
  79101. * Transforms each position and each normal of the vertexData according to the passed Matrix
  79102. * @param matrix the transforming matrix
  79103. * @returns the VertexData
  79104. */
  79105. transform(matrix: Matrix): VertexData;
  79106. /**
  79107. * Merges the passed VertexData into the current one
  79108. * @param other the VertexData to be merged into the current one
  79109. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  79110. * @returns the modified VertexData
  79111. */
  79112. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  79113. private _mergeElement;
  79114. private _validate;
  79115. /**
  79116. * Serializes the VertexData
  79117. * @returns a serialized object
  79118. */
  79119. serialize(): any;
  79120. /**
  79121. * Extracts the vertexData from a mesh
  79122. * @param mesh the mesh from which to extract the VertexData
  79123. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  79124. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  79125. * @returns the object VertexData associated to the passed mesh
  79126. */
  79127. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  79128. /**
  79129. * Extracts the vertexData from the geometry
  79130. * @param geometry the geometry from which to extract the VertexData
  79131. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  79132. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  79133. * @returns the object VertexData associated to the passed mesh
  79134. */
  79135. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  79136. private static _ExtractFrom;
  79137. /**
  79138. * Creates the VertexData for a Ribbon
  79139. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  79140. * * pathArray array of paths, each of which an array of successive Vector3
  79141. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  79142. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  79143. * * 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
  79144. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79145. * * 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)
  79146. * * 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)
  79147. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  79148. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  79149. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  79150. * @returns the VertexData of the ribbon
  79151. */
  79152. static CreateRibbon(options: {
  79153. pathArray: Vector3[][];
  79154. closeArray?: boolean;
  79155. closePath?: boolean;
  79156. offset?: number;
  79157. sideOrientation?: number;
  79158. frontUVs?: Vector4;
  79159. backUVs?: Vector4;
  79160. invertUV?: boolean;
  79161. uvs?: Vector2[];
  79162. colors?: Color4[];
  79163. }): VertexData;
  79164. /**
  79165. * Creates the VertexData for a box
  79166. * @param options an object used to set the following optional parameters for the box, required but can be empty
  79167. * * size sets the width, height and depth of the box to the value of size, optional default 1
  79168. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  79169. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  79170. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  79171. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  79172. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  79173. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79174. * * 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)
  79175. * * 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)
  79176. * @returns the VertexData of the box
  79177. */
  79178. static CreateBox(options: {
  79179. size?: number;
  79180. width?: number;
  79181. height?: number;
  79182. depth?: number;
  79183. faceUV?: Vector4[];
  79184. faceColors?: Color4[];
  79185. sideOrientation?: number;
  79186. frontUVs?: Vector4;
  79187. backUVs?: Vector4;
  79188. }): VertexData;
  79189. /**
  79190. * Creates the VertexData for an ellipsoid, defaults to a sphere
  79191. * @param options an object used to set the following optional parameters for the box, required but can be empty
  79192. * * segments sets the number of horizontal strips optional, default 32
  79193. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  79194. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  79195. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  79196. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  79197. * * 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
  79198. * * 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
  79199. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79200. * * 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)
  79201. * * 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)
  79202. * @returns the VertexData of the ellipsoid
  79203. */
  79204. static CreateSphere(options: {
  79205. segments?: number;
  79206. diameter?: number;
  79207. diameterX?: number;
  79208. diameterY?: number;
  79209. diameterZ?: number;
  79210. arc?: number;
  79211. slice?: number;
  79212. sideOrientation?: number;
  79213. frontUVs?: Vector4;
  79214. backUVs?: Vector4;
  79215. }): VertexData;
  79216. /**
  79217. * Creates the VertexData for a cylinder, cone or prism
  79218. * @param options an object used to set the following optional parameters for the box, required but can be empty
  79219. * * height sets the height (y direction) of the cylinder, optional, default 2
  79220. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  79221. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  79222. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  79223. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  79224. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  79225. * * 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
  79226. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  79227. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  79228. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  79229. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  79230. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79231. * * 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)
  79232. * * 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)
  79233. * @returns the VertexData of the cylinder, cone or prism
  79234. */
  79235. static CreateCylinder(options: {
  79236. height?: number;
  79237. diameterTop?: number;
  79238. diameterBottom?: number;
  79239. diameter?: number;
  79240. tessellation?: number;
  79241. subdivisions?: number;
  79242. arc?: number;
  79243. faceColors?: Color4[];
  79244. faceUV?: Vector4[];
  79245. hasRings?: boolean;
  79246. enclose?: boolean;
  79247. sideOrientation?: number;
  79248. frontUVs?: Vector4;
  79249. backUVs?: Vector4;
  79250. }): VertexData;
  79251. /**
  79252. * Creates the VertexData for a torus
  79253. * @param options an object used to set the following optional parameters for the box, required but can be empty
  79254. * * diameter the diameter of the torus, optional default 1
  79255. * * thickness the diameter of the tube forming the torus, optional default 0.5
  79256. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  79257. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79258. * * 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)
  79259. * * 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)
  79260. * @returns the VertexData of the torus
  79261. */
  79262. static CreateTorus(options: {
  79263. diameter?: number;
  79264. thickness?: number;
  79265. tessellation?: number;
  79266. sideOrientation?: number;
  79267. frontUVs?: Vector4;
  79268. backUVs?: Vector4;
  79269. }): VertexData;
  79270. /**
  79271. * Creates the VertexData of the LineSystem
  79272. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  79273. * - lines an array of lines, each line being an array of successive Vector3
  79274. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  79275. * @returns the VertexData of the LineSystem
  79276. */
  79277. static CreateLineSystem(options: {
  79278. lines: Vector3[][];
  79279. colors?: Nullable<Color4[][]>;
  79280. }): VertexData;
  79281. /**
  79282. * Create the VertexData for a DashedLines
  79283. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  79284. * - points an array successive Vector3
  79285. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  79286. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  79287. * - dashNb the intended total number of dashes, optional, default 200
  79288. * @returns the VertexData for the DashedLines
  79289. */
  79290. static CreateDashedLines(options: {
  79291. points: Vector3[];
  79292. dashSize?: number;
  79293. gapSize?: number;
  79294. dashNb?: number;
  79295. }): VertexData;
  79296. /**
  79297. * Creates the VertexData for a Ground
  79298. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  79299. * - width the width (x direction) of the ground, optional, default 1
  79300. * - height the height (z direction) of the ground, optional, default 1
  79301. * - subdivisions the number of subdivisions per side, optional, default 1
  79302. * @returns the VertexData of the Ground
  79303. */
  79304. static CreateGround(options: {
  79305. width?: number;
  79306. height?: number;
  79307. subdivisions?: number;
  79308. subdivisionsX?: number;
  79309. subdivisionsY?: number;
  79310. }): VertexData;
  79311. /**
  79312. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  79313. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  79314. * * xmin the ground minimum X coordinate, optional, default -1
  79315. * * zmin the ground minimum Z coordinate, optional, default -1
  79316. * * xmax the ground maximum X coordinate, optional, default 1
  79317. * * zmax the ground maximum Z coordinate, optional, default 1
  79318. * * 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}
  79319. * * 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}
  79320. * @returns the VertexData of the TiledGround
  79321. */
  79322. static CreateTiledGround(options: {
  79323. xmin: number;
  79324. zmin: number;
  79325. xmax: number;
  79326. zmax: number;
  79327. subdivisions?: {
  79328. w: number;
  79329. h: number;
  79330. };
  79331. precision?: {
  79332. w: number;
  79333. h: number;
  79334. };
  79335. }): VertexData;
  79336. /**
  79337. * Creates the VertexData of the Ground designed from a heightmap
  79338. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  79339. * * width the width (x direction) of the ground
  79340. * * height the height (z direction) of the ground
  79341. * * subdivisions the number of subdivisions per side
  79342. * * minHeight the minimum altitude on the ground, optional, default 0
  79343. * * maxHeight the maximum altitude on the ground, optional default 1
  79344. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  79345. * * buffer the array holding the image color data
  79346. * * bufferWidth the width of image
  79347. * * bufferHeight the height of image
  79348. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  79349. * @returns the VertexData of the Ground designed from a heightmap
  79350. */
  79351. static CreateGroundFromHeightMap(options: {
  79352. width: number;
  79353. height: number;
  79354. subdivisions: number;
  79355. minHeight: number;
  79356. maxHeight: number;
  79357. colorFilter: Color3;
  79358. buffer: Uint8Array;
  79359. bufferWidth: number;
  79360. bufferHeight: number;
  79361. alphaFilter: number;
  79362. }): VertexData;
  79363. /**
  79364. * Creates the VertexData for a Plane
  79365. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  79366. * * size sets the width and height of the plane to the value of size, optional default 1
  79367. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  79368. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  79369. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79370. * * 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)
  79371. * * 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)
  79372. * @returns the VertexData of the box
  79373. */
  79374. static CreatePlane(options: {
  79375. size?: number;
  79376. width?: number;
  79377. height?: number;
  79378. sideOrientation?: number;
  79379. frontUVs?: Vector4;
  79380. backUVs?: Vector4;
  79381. }): VertexData;
  79382. /**
  79383. * Creates the VertexData of the Disc or regular Polygon
  79384. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  79385. * * radius the radius of the disc, optional default 0.5
  79386. * * tessellation the number of polygon sides, optional, default 64
  79387. * * 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
  79388. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79389. * * 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)
  79390. * * 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)
  79391. * @returns the VertexData of the box
  79392. */
  79393. static CreateDisc(options: {
  79394. radius?: number;
  79395. tessellation?: number;
  79396. arc?: number;
  79397. sideOrientation?: number;
  79398. frontUVs?: Vector4;
  79399. backUVs?: Vector4;
  79400. }): VertexData;
  79401. /**
  79402. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  79403. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  79404. * @param polygon a mesh built from polygonTriangulation.build()
  79405. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79406. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  79407. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  79408. * @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)
  79409. * @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)
  79410. * @returns the VertexData of the Polygon
  79411. */
  79412. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  79413. /**
  79414. * Creates the VertexData of the IcoSphere
  79415. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  79416. * * radius the radius of the IcoSphere, optional default 1
  79417. * * radiusX allows stretching in the x direction, optional, default radius
  79418. * * radiusY allows stretching in the y direction, optional, default radius
  79419. * * radiusZ allows stretching in the z direction, optional, default radius
  79420. * * flat when true creates a flat shaded mesh, optional, default true
  79421. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  79422. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79423. * * 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)
  79424. * * 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)
  79425. * @returns the VertexData of the IcoSphere
  79426. */
  79427. static CreateIcoSphere(options: {
  79428. radius?: number;
  79429. radiusX?: number;
  79430. radiusY?: number;
  79431. radiusZ?: number;
  79432. flat?: boolean;
  79433. subdivisions?: number;
  79434. sideOrientation?: number;
  79435. frontUVs?: Vector4;
  79436. backUVs?: Vector4;
  79437. }): VertexData;
  79438. /**
  79439. * Creates the VertexData for a Polyhedron
  79440. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  79441. * * type provided types are:
  79442. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  79443. * * 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)
  79444. * * size the size of the IcoSphere, optional default 1
  79445. * * sizeX allows stretching in the x direction, optional, default size
  79446. * * sizeY allows stretching in the y direction, optional, default size
  79447. * * sizeZ allows stretching in the z direction, optional, default size
  79448. * * 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
  79449. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  79450. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  79451. * * flat when true creates a flat shaded mesh, optional, default true
  79452. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  79453. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79454. * * 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)
  79455. * * 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)
  79456. * @returns the VertexData of the Polyhedron
  79457. */
  79458. static CreatePolyhedron(options: {
  79459. type?: number;
  79460. size?: number;
  79461. sizeX?: number;
  79462. sizeY?: number;
  79463. sizeZ?: number;
  79464. custom?: any;
  79465. faceUV?: Vector4[];
  79466. faceColors?: Color4[];
  79467. flat?: boolean;
  79468. sideOrientation?: number;
  79469. frontUVs?: Vector4;
  79470. backUVs?: Vector4;
  79471. }): VertexData;
  79472. /**
  79473. * Creates the VertexData for a TorusKnot
  79474. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  79475. * * radius the radius of the torus knot, optional, default 2
  79476. * * tube the thickness of the tube, optional, default 0.5
  79477. * * radialSegments the number of sides on each tube segments, optional, default 32
  79478. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  79479. * * p the number of windings around the z axis, optional, default 2
  79480. * * q the number of windings around the x axis, optional, default 3
  79481. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79482. * * 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)
  79483. * * 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)
  79484. * @returns the VertexData of the Torus Knot
  79485. */
  79486. static CreateTorusKnot(options: {
  79487. radius?: number;
  79488. tube?: number;
  79489. radialSegments?: number;
  79490. tubularSegments?: number;
  79491. p?: number;
  79492. q?: number;
  79493. sideOrientation?: number;
  79494. frontUVs?: Vector4;
  79495. backUVs?: Vector4;
  79496. }): VertexData;
  79497. /**
  79498. * Compute normals for given positions and indices
  79499. * @param positions an array of vertex positions, [...., x, y, z, ......]
  79500. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  79501. * @param normals an array of vertex normals, [...., x, y, z, ......]
  79502. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  79503. * * facetNormals : optional array of facet normals (vector3)
  79504. * * facetPositions : optional array of facet positions (vector3)
  79505. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  79506. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  79507. * * bInfo : optional bounding info, required for facetPartitioning computation
  79508. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  79509. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  79510. * * useRightHandedSystem: optional boolean to for right handed system computation
  79511. * * depthSort : optional boolean to enable the facet depth sort computation
  79512. * * distanceTo : optional Vector3 to compute the facet depth from this location
  79513. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  79514. */
  79515. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  79516. facetNormals?: any;
  79517. facetPositions?: any;
  79518. facetPartitioning?: any;
  79519. ratio?: number;
  79520. bInfo?: any;
  79521. bbSize?: Vector3;
  79522. subDiv?: any;
  79523. useRightHandedSystem?: boolean;
  79524. depthSort?: boolean;
  79525. distanceTo?: Vector3;
  79526. depthSortedFacets?: any;
  79527. }): void;
  79528. /** @hidden */
  79529. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  79530. /**
  79531. * Applies VertexData created from the imported parameters to the geometry
  79532. * @param parsedVertexData the parsed data from an imported file
  79533. * @param geometry the geometry to apply the VertexData to
  79534. */
  79535. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  79536. }
  79537. }
  79538. declare module BABYLON {
  79539. /**
  79540. * Class containing static functions to help procedurally build meshes
  79541. */
  79542. export class DiscBuilder {
  79543. /**
  79544. * Creates a plane polygonal mesh. By default, this is a disc
  79545. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  79546. * * 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
  79547. * * 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
  79548. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  79549. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  79550. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79551. * @param name defines the name of the mesh
  79552. * @param options defines the options used to create the mesh
  79553. * @param scene defines the hosting scene
  79554. * @returns the plane polygonal mesh
  79555. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  79556. */
  79557. static CreateDisc(name: string, options: {
  79558. radius?: number;
  79559. tessellation?: number;
  79560. arc?: number;
  79561. updatable?: boolean;
  79562. sideOrientation?: number;
  79563. frontUVs?: Vector4;
  79564. backUVs?: Vector4;
  79565. }, scene?: Nullable<Scene>): Mesh;
  79566. }
  79567. }
  79568. declare module BABYLON {
  79569. /**
  79570. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  79571. *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.
  79572. * The SPS is also a particle system. It provides some methods to manage the particles.
  79573. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  79574. *
  79575. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  79576. */
  79577. export class SolidParticleSystem implements IDisposable {
  79578. /**
  79579. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  79580. * Example : var p = SPS.particles[i];
  79581. */
  79582. particles: SolidParticle[];
  79583. /**
  79584. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  79585. */
  79586. nbParticles: number;
  79587. /**
  79588. * If the particles must ever face the camera (default false). Useful for planar particles.
  79589. */
  79590. billboard: boolean;
  79591. /**
  79592. * Recompute normals when adding a shape
  79593. */
  79594. recomputeNormals: boolean;
  79595. /**
  79596. * This a counter ofr your own usage. It's not set by any SPS functions.
  79597. */
  79598. counter: number;
  79599. /**
  79600. * The SPS name. This name is also given to the underlying mesh.
  79601. */
  79602. name: string;
  79603. /**
  79604. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  79605. */
  79606. mesh: Mesh;
  79607. /**
  79608. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  79609. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  79610. */
  79611. vars: any;
  79612. /**
  79613. * This array is populated when the SPS is set as 'pickable'.
  79614. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  79615. * Each element of this array is an object `{idx: int, faceId: int}`.
  79616. * `idx` is the picked particle index in the `SPS.particles` array
  79617. * `faceId` is the picked face index counted within this particle.
  79618. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  79619. */
  79620. pickedParticles: {
  79621. idx: number;
  79622. faceId: number;
  79623. }[];
  79624. /**
  79625. * This array is populated when `enableDepthSort` is set to true.
  79626. * Each element of this array is an instance of the class DepthSortedParticle.
  79627. */
  79628. depthSortedParticles: DepthSortedParticle[];
  79629. /**
  79630. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  79631. * @hidden
  79632. */
  79633. _bSphereOnly: boolean;
  79634. /**
  79635. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  79636. * @hidden
  79637. */
  79638. _bSphereRadiusFactor: number;
  79639. private _scene;
  79640. private _positions;
  79641. private _indices;
  79642. private _normals;
  79643. private _colors;
  79644. private _uvs;
  79645. private _indices32;
  79646. private _positions32;
  79647. private _normals32;
  79648. private _fixedNormal32;
  79649. private _colors32;
  79650. private _uvs32;
  79651. private _index;
  79652. private _updatable;
  79653. private _pickable;
  79654. private _isVisibilityBoxLocked;
  79655. private _alwaysVisible;
  79656. private _depthSort;
  79657. private _shapeCounter;
  79658. private _copy;
  79659. private _color;
  79660. private _computeParticleColor;
  79661. private _computeParticleTexture;
  79662. private _computeParticleRotation;
  79663. private _computeParticleVertex;
  79664. private _computeBoundingBox;
  79665. private _depthSortParticles;
  79666. private _camera;
  79667. private _mustUnrotateFixedNormals;
  79668. private _particlesIntersect;
  79669. private _needs32Bits;
  79670. /**
  79671. * Creates a SPS (Solid Particle System) object.
  79672. * @param name (String) is the SPS name, this will be the underlying mesh name.
  79673. * @param scene (Scene) is the scene in which the SPS is added.
  79674. * @param options defines the options of the sps e.g.
  79675. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  79676. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  79677. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  79678. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  79679. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  79680. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  79681. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  79682. */
  79683. constructor(name: string, scene: Scene, options?: {
  79684. updatable?: boolean;
  79685. isPickable?: boolean;
  79686. enableDepthSort?: boolean;
  79687. particleIntersection?: boolean;
  79688. boundingSphereOnly?: boolean;
  79689. bSphereRadiusFactor?: number;
  79690. });
  79691. /**
  79692. * Builds the SPS underlying mesh. Returns a standard Mesh.
  79693. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  79694. * @returns the created mesh
  79695. */
  79696. buildMesh(): Mesh;
  79697. /**
  79698. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  79699. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  79700. * Thus the particles generated from `digest()` have their property `position` set yet.
  79701. * @param mesh ( Mesh ) is the mesh to be digested
  79702. * @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
  79703. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  79704. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  79705. * @returns the current SPS
  79706. */
  79707. digest(mesh: Mesh, options?: {
  79708. facetNb?: number;
  79709. number?: number;
  79710. delta?: number;
  79711. }): SolidParticleSystem;
  79712. private _unrotateFixedNormals;
  79713. private _resetCopy;
  79714. private _meshBuilder;
  79715. private _posToShape;
  79716. private _uvsToShapeUV;
  79717. private _addParticle;
  79718. /**
  79719. * Adds some particles to the SPS from the model shape. Returns the shape id.
  79720. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  79721. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  79722. * @param nb (positive integer) the number of particles to be created from this model
  79723. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  79724. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  79725. * @returns the number of shapes in the system
  79726. */
  79727. addShape(mesh: Mesh, nb: number, options?: {
  79728. positionFunction?: any;
  79729. vertexFunction?: any;
  79730. }): number;
  79731. private _rebuildParticle;
  79732. /**
  79733. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  79734. * @returns the SPS.
  79735. */
  79736. rebuildMesh(): SolidParticleSystem;
  79737. /**
  79738. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  79739. * This method calls `updateParticle()` for each particle of the SPS.
  79740. * For an animated SPS, it is usually called within the render loop.
  79741. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  79742. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  79743. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  79744. * @returns the SPS.
  79745. */
  79746. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  79747. /**
  79748. * Disposes the SPS.
  79749. */
  79750. dispose(): void;
  79751. /**
  79752. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  79753. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  79754. * @returns the SPS.
  79755. */
  79756. refreshVisibleSize(): SolidParticleSystem;
  79757. /**
  79758. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  79759. * @param size the size (float) of the visibility box
  79760. * note : this doesn't lock the SPS mesh bounding box.
  79761. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  79762. */
  79763. setVisibilityBox(size: number): void;
  79764. /**
  79765. * Gets whether the SPS as always visible or not
  79766. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  79767. */
  79768. /**
  79769. * Sets the SPS as always visible or not
  79770. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  79771. */
  79772. isAlwaysVisible: boolean;
  79773. /**
  79774. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  79775. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  79776. */
  79777. /**
  79778. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  79779. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  79780. */
  79781. isVisibilityBoxLocked: boolean;
  79782. /**
  79783. * Tells to `setParticles()` to compute the particle rotations or not.
  79784. * Default value : true. The SPS is faster when it's set to false.
  79785. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  79786. */
  79787. /**
  79788. * Gets if `setParticles()` computes the particle rotations or not.
  79789. * Default value : true. The SPS is faster when it's set to false.
  79790. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  79791. */
  79792. computeParticleRotation: boolean;
  79793. /**
  79794. * Tells to `setParticles()` to compute the particle colors or not.
  79795. * Default value : true. The SPS is faster when it's set to false.
  79796. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  79797. */
  79798. /**
  79799. * Gets if `setParticles()` computes the particle colors or not.
  79800. * Default value : true. The SPS is faster when it's set to false.
  79801. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  79802. */
  79803. computeParticleColor: boolean;
  79804. /**
  79805. * Gets if `setParticles()` computes the particle textures or not.
  79806. * Default value : true. The SPS is faster when it's set to false.
  79807. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  79808. */
  79809. computeParticleTexture: boolean;
  79810. /**
  79811. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  79812. * Default value : false. The SPS is faster when it's set to false.
  79813. * Note : the particle custom vertex positions aren't stored values.
  79814. */
  79815. /**
  79816. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  79817. * Default value : false. The SPS is faster when it's set to false.
  79818. * Note : the particle custom vertex positions aren't stored values.
  79819. */
  79820. computeParticleVertex: boolean;
  79821. /**
  79822. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  79823. */
  79824. /**
  79825. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  79826. */
  79827. computeBoundingBox: boolean;
  79828. /**
  79829. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  79830. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  79831. * Default : `true`
  79832. */
  79833. /**
  79834. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  79835. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  79836. * Default : `true`
  79837. */
  79838. depthSortParticles: boolean;
  79839. /**
  79840. * This function does nothing. It may be overwritten to set all the particle first values.
  79841. * The SPS doesn't call this function, you may have to call it by your own.
  79842. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  79843. */
  79844. initParticles(): void;
  79845. /**
  79846. * This function does nothing. It may be overwritten to recycle a particle.
  79847. * The SPS doesn't call this function, you may have to call it by your own.
  79848. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  79849. * @param particle The particle to recycle
  79850. * @returns the recycled particle
  79851. */
  79852. recycleParticle(particle: SolidParticle): SolidParticle;
  79853. /**
  79854. * Updates a particle : this function should be overwritten by the user.
  79855. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  79856. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  79857. * @example : just set a particle position or velocity and recycle conditions
  79858. * @param particle The particle to update
  79859. * @returns the updated particle
  79860. */
  79861. updateParticle(particle: SolidParticle): SolidParticle;
  79862. /**
  79863. * Updates a vertex of a particle : it can be overwritten by the user.
  79864. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  79865. * @param particle the current particle
  79866. * @param vertex the current index of the current particle
  79867. * @param pt the index of the current vertex in the particle shape
  79868. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  79869. * @example : just set a vertex particle position
  79870. * @returns the updated vertex
  79871. */
  79872. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  79873. /**
  79874. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  79875. * This does nothing and may be overwritten by the user.
  79876. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  79877. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  79878. * @param update the boolean update value actually passed to setParticles()
  79879. */
  79880. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  79881. /**
  79882. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  79883. * This will be passed three parameters.
  79884. * This does nothing and may be overwritten by the user.
  79885. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  79886. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  79887. * @param update the boolean update value actually passed to setParticles()
  79888. */
  79889. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  79890. }
  79891. }
  79892. declare module BABYLON {
  79893. /**
  79894. * Represents one particle of a solid particle system.
  79895. */
  79896. export class SolidParticle {
  79897. /**
  79898. * particle global index
  79899. */
  79900. idx: number;
  79901. /**
  79902. * The color of the particle
  79903. */
  79904. color: Nullable<Color4>;
  79905. /**
  79906. * The world space position of the particle.
  79907. */
  79908. position: Vector3;
  79909. /**
  79910. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  79911. */
  79912. rotation: Vector3;
  79913. /**
  79914. * The world space rotation quaternion of the particle.
  79915. */
  79916. rotationQuaternion: Nullable<Quaternion>;
  79917. /**
  79918. * The scaling of the particle.
  79919. */
  79920. scaling: Vector3;
  79921. /**
  79922. * The uvs of the particle.
  79923. */
  79924. uvs: Vector4;
  79925. /**
  79926. * The current speed of the particle.
  79927. */
  79928. velocity: Vector3;
  79929. /**
  79930. * The pivot point in the particle local space.
  79931. */
  79932. pivot: Vector3;
  79933. /**
  79934. * Must the particle be translated from its pivot point in its local space ?
  79935. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  79936. * Default : false
  79937. */
  79938. translateFromPivot: boolean;
  79939. /**
  79940. * Is the particle active or not ?
  79941. */
  79942. alive: boolean;
  79943. /**
  79944. * Is the particle visible or not ?
  79945. */
  79946. isVisible: boolean;
  79947. /**
  79948. * Index of this particle in the global "positions" array (Internal use)
  79949. * @hidden
  79950. */
  79951. _pos: number;
  79952. /**
  79953. * @hidden Index of this particle in the global "indices" array (Internal use)
  79954. */
  79955. _ind: number;
  79956. /**
  79957. * @hidden ModelShape of this particle (Internal use)
  79958. */
  79959. _model: ModelShape;
  79960. /**
  79961. * ModelShape id of this particle
  79962. */
  79963. shapeId: number;
  79964. /**
  79965. * Index of the particle in its shape id (Internal use)
  79966. */
  79967. idxInShape: number;
  79968. /**
  79969. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  79970. */
  79971. _modelBoundingInfo: BoundingInfo;
  79972. /**
  79973. * @hidden Particle BoundingInfo object (Internal use)
  79974. */
  79975. _boundingInfo: BoundingInfo;
  79976. /**
  79977. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  79978. */
  79979. _sps: SolidParticleSystem;
  79980. /**
  79981. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  79982. */
  79983. _stillInvisible: boolean;
  79984. /**
  79985. * @hidden Last computed particle rotation matrix
  79986. */
  79987. _rotationMatrix: number[];
  79988. /**
  79989. * Parent particle Id, if any.
  79990. * Default null.
  79991. */
  79992. parentId: Nullable<number>;
  79993. /**
  79994. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  79995. * The possible values are :
  79996. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  79997. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  79998. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  79999. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  80000. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  80001. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  80002. * */
  80003. cullingStrategy: number;
  80004. /**
  80005. * @hidden Internal global position in the SPS.
  80006. */
  80007. _globalPosition: Vector3;
  80008. /**
  80009. * Creates a Solid Particle object.
  80010. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  80011. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  80012. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  80013. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  80014. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  80015. * @param shapeId (integer) is the model shape identifier in the SPS.
  80016. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  80017. * @param sps defines the sps it is associated to
  80018. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  80019. */
  80020. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  80021. /**
  80022. * Legacy support, changed scale to scaling
  80023. */
  80024. /**
  80025. * Legacy support, changed scale to scaling
  80026. */
  80027. scale: Vector3;
  80028. /**
  80029. * Legacy support, changed quaternion to rotationQuaternion
  80030. */
  80031. /**
  80032. * Legacy support, changed quaternion to rotationQuaternion
  80033. */
  80034. quaternion: Nullable<Quaternion>;
  80035. /**
  80036. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  80037. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  80038. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  80039. * @returns true if it intersects
  80040. */
  80041. intersectsMesh(target: Mesh | SolidParticle): boolean;
  80042. /**
  80043. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  80044. * A particle is in the frustum if its bounding box intersects the frustum
  80045. * @param frustumPlanes defines the frustum to test
  80046. * @returns true if the particle is in the frustum planes
  80047. */
  80048. isInFrustum(frustumPlanes: Plane[]): boolean;
  80049. /**
  80050. * get the rotation matrix of the particle
  80051. * @hidden
  80052. */
  80053. getRotationMatrix(m: Matrix): void;
  80054. }
  80055. /**
  80056. * Represents the shape of the model used by one particle of a solid particle system.
  80057. * SPS internal tool, don't use it manually.
  80058. */
  80059. export class ModelShape {
  80060. /**
  80061. * The shape id
  80062. * @hidden
  80063. */
  80064. shapeID: number;
  80065. /**
  80066. * flat array of model positions (internal use)
  80067. * @hidden
  80068. */
  80069. _shape: Vector3[];
  80070. /**
  80071. * flat array of model UVs (internal use)
  80072. * @hidden
  80073. */
  80074. _shapeUV: number[];
  80075. /**
  80076. * length of the shape in the model indices array (internal use)
  80077. * @hidden
  80078. */
  80079. _indicesLength: number;
  80080. /**
  80081. * Custom position function (internal use)
  80082. * @hidden
  80083. */
  80084. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  80085. /**
  80086. * Custom vertex function (internal use)
  80087. * @hidden
  80088. */
  80089. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  80090. /**
  80091. * 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.
  80092. * SPS internal tool, don't use it manually.
  80093. * @hidden
  80094. */
  80095. 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>);
  80096. }
  80097. /**
  80098. * Represents a Depth Sorted Particle in the solid particle system.
  80099. */
  80100. export class DepthSortedParticle {
  80101. /**
  80102. * Index of the particle in the "indices" array
  80103. */
  80104. ind: number;
  80105. /**
  80106. * Length of the particle shape in the "indices" array
  80107. */
  80108. indicesLength: number;
  80109. /**
  80110. * Squared distance from the particle to the camera
  80111. */
  80112. sqDistance: number;
  80113. }
  80114. }
  80115. declare module BABYLON {
  80116. /**
  80117. * Class used to store all common mesh properties
  80118. */
  80119. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  80120. /** No occlusion */
  80121. static OCCLUSION_TYPE_NONE: number;
  80122. /** Occlusion set to optimisitic */
  80123. static OCCLUSION_TYPE_OPTIMISTIC: number;
  80124. /** Occlusion set to strict */
  80125. static OCCLUSION_TYPE_STRICT: number;
  80126. /** Use an accurante occlusion algorithm */
  80127. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  80128. /** Use a conservative occlusion algorithm */
  80129. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  80130. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  80131. * Test order :
  80132. * Is the bounding sphere outside the frustum ?
  80133. * If not, are the bounding box vertices outside the frustum ?
  80134. * It not, then the cullable object is in the frustum.
  80135. */
  80136. static readonly CULLINGSTRATEGY_STANDARD: number;
  80137. /** Culling strategy : Bounding Sphere Only.
  80138. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  80139. * It's also less accurate than the standard because some not visible objects can still be selected.
  80140. * Test : is the bounding sphere outside the frustum ?
  80141. * If not, then the cullable object is in the frustum.
  80142. */
  80143. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  80144. /** Culling strategy : Optimistic Inclusion.
  80145. * This in an inclusion test first, then the standard exclusion test.
  80146. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  80147. * 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.
  80148. * Anyway, it's as accurate as the standard strategy.
  80149. * Test :
  80150. * Is the cullable object bounding sphere center in the frustum ?
  80151. * If not, apply the default culling strategy.
  80152. */
  80153. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  80154. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  80155. * This in an inclusion test first, then the bounding sphere only exclusion test.
  80156. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  80157. * 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.
  80158. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  80159. * Test :
  80160. * Is the cullable object bounding sphere center in the frustum ?
  80161. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  80162. */
  80163. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  80164. /**
  80165. * No billboard
  80166. */
  80167. static readonly BILLBOARDMODE_NONE: number;
  80168. /** Billboard on X axis */
  80169. static readonly BILLBOARDMODE_X: number;
  80170. /** Billboard on Y axis */
  80171. static readonly BILLBOARDMODE_Y: number;
  80172. /** Billboard on Z axis */
  80173. static readonly BILLBOARDMODE_Z: number;
  80174. /** Billboard on all axes */
  80175. static readonly BILLBOARDMODE_ALL: number;
  80176. private _facetData;
  80177. /**
  80178. * The culling strategy to use to check whether the mesh must be rendered or not.
  80179. * This value can be changed at any time and will be used on the next render mesh selection.
  80180. * The possible values are :
  80181. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  80182. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  80183. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  80184. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  80185. * Please read each static variable documentation to get details about the culling process.
  80186. * */
  80187. cullingStrategy: number;
  80188. /**
  80189. * Gets the number of facets in the mesh
  80190. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  80191. */
  80192. readonly facetNb: number;
  80193. /**
  80194. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  80195. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  80196. */
  80197. partitioningSubdivisions: number;
  80198. /**
  80199. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  80200. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  80201. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  80202. */
  80203. partitioningBBoxRatio: number;
  80204. /**
  80205. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  80206. * Works only for updatable meshes.
  80207. * Doesn't work with multi-materials
  80208. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  80209. */
  80210. mustDepthSortFacets: boolean;
  80211. /**
  80212. * The location (Vector3) where the facet depth sort must be computed from.
  80213. * By default, the active camera position.
  80214. * Used only when facet depth sort is enabled
  80215. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  80216. */
  80217. facetDepthSortFrom: Vector3;
  80218. /**
  80219. * gets a boolean indicating if facetData is enabled
  80220. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  80221. */
  80222. readonly isFacetDataEnabled: boolean;
  80223. /** @hidden */
  80224. _updateNonUniformScalingState(value: boolean): boolean;
  80225. /**
  80226. * An event triggered when this mesh collides with another one
  80227. */
  80228. onCollideObservable: Observable<AbstractMesh>;
  80229. private _onCollideObserver;
  80230. /** Set a function to call when this mesh collides with another one */
  80231. onCollide: () => void;
  80232. /**
  80233. * An event triggered when the collision's position changes
  80234. */
  80235. onCollisionPositionChangeObservable: Observable<Vector3>;
  80236. private _onCollisionPositionChangeObserver;
  80237. /** Set a function to call when the collision's position changes */
  80238. onCollisionPositionChange: () => void;
  80239. /**
  80240. * An event triggered when material is changed
  80241. */
  80242. onMaterialChangedObservable: Observable<AbstractMesh>;
  80243. /**
  80244. * Gets or sets the orientation for POV movement & rotation
  80245. */
  80246. definedFacingForward: boolean;
  80247. /** @hidden */
  80248. _occlusionQuery: Nullable<WebGLQuery>;
  80249. private _visibility;
  80250. /**
  80251. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  80252. */
  80253. /**
  80254. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  80255. */
  80256. visibility: number;
  80257. /** Gets or sets the alpha index used to sort transparent meshes
  80258. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  80259. */
  80260. alphaIndex: number;
  80261. /**
  80262. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  80263. */
  80264. isVisible: boolean;
  80265. /**
  80266. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  80267. */
  80268. isPickable: boolean;
  80269. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  80270. showSubMeshesBoundingBox: boolean;
  80271. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  80272. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  80273. */
  80274. isBlocker: boolean;
  80275. /**
  80276. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  80277. */
  80278. enablePointerMoveEvents: boolean;
  80279. /**
  80280. * Specifies the rendering group id for this mesh (0 by default)
  80281. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  80282. */
  80283. renderingGroupId: number;
  80284. private _material;
  80285. /** Gets or sets current material */
  80286. material: Nullable<Material>;
  80287. private _receiveShadows;
  80288. /**
  80289. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  80290. * @see http://doc.babylonjs.com/babylon101/shadows
  80291. */
  80292. receiveShadows: boolean;
  80293. /** Defines color to use when rendering outline */
  80294. outlineColor: Color3;
  80295. /** Define width to use when rendering outline */
  80296. outlineWidth: number;
  80297. /** Defines color to use when rendering overlay */
  80298. overlayColor: Color3;
  80299. /** Defines alpha to use when rendering overlay */
  80300. overlayAlpha: number;
  80301. private _hasVertexAlpha;
  80302. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  80303. hasVertexAlpha: boolean;
  80304. private _useVertexColors;
  80305. /** 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) */
  80306. useVertexColors: boolean;
  80307. private _computeBonesUsingShaders;
  80308. /**
  80309. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  80310. */
  80311. computeBonesUsingShaders: boolean;
  80312. private _numBoneInfluencers;
  80313. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  80314. numBoneInfluencers: number;
  80315. private _applyFog;
  80316. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  80317. applyFog: boolean;
  80318. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  80319. useOctreeForRenderingSelection: boolean;
  80320. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  80321. useOctreeForPicking: boolean;
  80322. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  80323. useOctreeForCollisions: boolean;
  80324. private _layerMask;
  80325. /**
  80326. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  80327. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  80328. */
  80329. layerMask: number;
  80330. /**
  80331. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  80332. */
  80333. alwaysSelectAsActiveMesh: boolean;
  80334. /**
  80335. * Gets or sets the current action manager
  80336. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  80337. */
  80338. actionManager: Nullable<AbstractActionManager>;
  80339. private _checkCollisions;
  80340. private _collisionMask;
  80341. private _collisionGroup;
  80342. /**
  80343. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  80344. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  80345. */
  80346. ellipsoid: Vector3;
  80347. /**
  80348. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  80349. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  80350. */
  80351. ellipsoidOffset: Vector3;
  80352. private _collider;
  80353. private _oldPositionForCollisions;
  80354. private _diffPositionForCollisions;
  80355. /**
  80356. * Gets or sets a collision mask used to mask collisions (default is -1).
  80357. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  80358. */
  80359. collisionMask: number;
  80360. /**
  80361. * Gets or sets the current collision group mask (-1 by default).
  80362. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  80363. */
  80364. collisionGroup: number;
  80365. /**
  80366. * Defines edge width used when edgesRenderer is enabled
  80367. * @see https://www.babylonjs-playground.com/#10OJSG#13
  80368. */
  80369. edgesWidth: number;
  80370. /**
  80371. * Defines edge color used when edgesRenderer is enabled
  80372. * @see https://www.babylonjs-playground.com/#10OJSG#13
  80373. */
  80374. edgesColor: Color4;
  80375. /** @hidden */
  80376. _edgesRenderer: Nullable<IEdgesRenderer>;
  80377. /** @hidden */
  80378. _masterMesh: Nullable<AbstractMesh>;
  80379. /** @hidden */
  80380. _boundingInfo: Nullable<BoundingInfo>;
  80381. /** @hidden */
  80382. _renderId: number;
  80383. /**
  80384. * Gets or sets the list of subMeshes
  80385. * @see http://doc.babylonjs.com/how_to/multi_materials
  80386. */
  80387. subMeshes: SubMesh[];
  80388. /** @hidden */
  80389. _intersectionsInProgress: AbstractMesh[];
  80390. /** @hidden */
  80391. _unIndexed: boolean;
  80392. /** @hidden */
  80393. _lightSources: Light[];
  80394. /** @hidden */
  80395. readonly _positions: Nullable<Vector3[]>;
  80396. /** @hidden */
  80397. _waitingActions: any;
  80398. /** @hidden */
  80399. _waitingFreezeWorldMatrix: Nullable<boolean>;
  80400. private _skeleton;
  80401. /** @hidden */
  80402. _bonesTransformMatrices: Nullable<Float32Array>;
  80403. /**
  80404. * Gets or sets a skeleton to apply skining transformations
  80405. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  80406. */
  80407. skeleton: Nullable<Skeleton>;
  80408. /**
  80409. * An event triggered when the mesh is rebuilt.
  80410. */
  80411. onRebuildObservable: Observable<AbstractMesh>;
  80412. /**
  80413. * Creates a new AbstractMesh
  80414. * @param name defines the name of the mesh
  80415. * @param scene defines the hosting scene
  80416. */
  80417. constructor(name: string, scene?: Nullable<Scene>);
  80418. /**
  80419. * Returns the string "AbstractMesh"
  80420. * @returns "AbstractMesh"
  80421. */
  80422. getClassName(): string;
  80423. /**
  80424. * Gets a string representation of the current mesh
  80425. * @param fullDetails defines a boolean indicating if full details must be included
  80426. * @returns a string representation of the current mesh
  80427. */
  80428. toString(fullDetails?: boolean): string;
  80429. /** @hidden */
  80430. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  80431. /** @hidden */
  80432. _rebuild(): void;
  80433. /** @hidden */
  80434. _resyncLightSources(): void;
  80435. /** @hidden */
  80436. _resyncLighSource(light: Light): void;
  80437. /** @hidden */
  80438. _unBindEffect(): void;
  80439. /** @hidden */
  80440. _removeLightSource(light: Light): void;
  80441. private _markSubMeshesAsDirty;
  80442. /** @hidden */
  80443. _markSubMeshesAsLightDirty(): void;
  80444. /** @hidden */
  80445. _markSubMeshesAsAttributesDirty(): void;
  80446. /** @hidden */
  80447. _markSubMeshesAsMiscDirty(): void;
  80448. /**
  80449. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  80450. */
  80451. scaling: Vector3;
  80452. /**
  80453. * Returns true if the mesh is blocked. Implemented by child classes
  80454. */
  80455. readonly isBlocked: boolean;
  80456. /**
  80457. * Returns the mesh itself by default. Implemented by child classes
  80458. * @param camera defines the camera to use to pick the right LOD level
  80459. * @returns the currentAbstractMesh
  80460. */
  80461. getLOD(camera: Camera): Nullable<AbstractMesh>;
  80462. /**
  80463. * Returns 0 by default. Implemented by child classes
  80464. * @returns an integer
  80465. */
  80466. getTotalVertices(): number;
  80467. /**
  80468. * Returns a positive integer : the total number of indices in this mesh geometry.
  80469. * @returns the numner of indices or zero if the mesh has no geometry.
  80470. */
  80471. getTotalIndices(): number;
  80472. /**
  80473. * Returns null by default. Implemented by child classes
  80474. * @returns null
  80475. */
  80476. getIndices(): Nullable<IndicesArray>;
  80477. /**
  80478. * Returns the array of the requested vertex data kind. Implemented by child classes
  80479. * @param kind defines the vertex data kind to use
  80480. * @returns null
  80481. */
  80482. getVerticesData(kind: string): Nullable<FloatArray>;
  80483. /**
  80484. * Sets the vertex data of the mesh geometry for the requested `kind`.
  80485. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  80486. * Note that a new underlying VertexBuffer object is created each call.
  80487. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  80488. * @param kind defines vertex data kind:
  80489. * * VertexBuffer.PositionKind
  80490. * * VertexBuffer.UVKind
  80491. * * VertexBuffer.UV2Kind
  80492. * * VertexBuffer.UV3Kind
  80493. * * VertexBuffer.UV4Kind
  80494. * * VertexBuffer.UV5Kind
  80495. * * VertexBuffer.UV6Kind
  80496. * * VertexBuffer.ColorKind
  80497. * * VertexBuffer.MatricesIndicesKind
  80498. * * VertexBuffer.MatricesIndicesExtraKind
  80499. * * VertexBuffer.MatricesWeightsKind
  80500. * * VertexBuffer.MatricesWeightsExtraKind
  80501. * @param data defines the data source
  80502. * @param updatable defines if the data must be flagged as updatable (or static)
  80503. * @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
  80504. * @returns the current mesh
  80505. */
  80506. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  80507. /**
  80508. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  80509. * If the mesh has no geometry, it is simply returned as it is.
  80510. * @param kind defines vertex data kind:
  80511. * * VertexBuffer.PositionKind
  80512. * * VertexBuffer.UVKind
  80513. * * VertexBuffer.UV2Kind
  80514. * * VertexBuffer.UV3Kind
  80515. * * VertexBuffer.UV4Kind
  80516. * * VertexBuffer.UV5Kind
  80517. * * VertexBuffer.UV6Kind
  80518. * * VertexBuffer.ColorKind
  80519. * * VertexBuffer.MatricesIndicesKind
  80520. * * VertexBuffer.MatricesIndicesExtraKind
  80521. * * VertexBuffer.MatricesWeightsKind
  80522. * * VertexBuffer.MatricesWeightsExtraKind
  80523. * @param data defines the data source
  80524. * @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
  80525. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  80526. * @returns the current mesh
  80527. */
  80528. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  80529. /**
  80530. * Sets the mesh indices,
  80531. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  80532. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  80533. * @param totalVertices Defines the total number of vertices
  80534. * @returns the current mesh
  80535. */
  80536. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  80537. /**
  80538. * Gets a boolean indicating if specific vertex data is present
  80539. * @param kind defines the vertex data kind to use
  80540. * @returns true is data kind is present
  80541. */
  80542. isVerticesDataPresent(kind: string): boolean;
  80543. /**
  80544. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  80545. * @returns a BoundingInfo
  80546. */
  80547. getBoundingInfo(): BoundingInfo;
  80548. /**
  80549. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  80550. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  80551. * @returns the current mesh
  80552. */
  80553. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  80554. /**
  80555. * Overwrite the current bounding info
  80556. * @param boundingInfo defines the new bounding info
  80557. * @returns the current mesh
  80558. */
  80559. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  80560. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  80561. readonly useBones: boolean;
  80562. /** @hidden */
  80563. _preActivate(): void;
  80564. /** @hidden */
  80565. _preActivateForIntermediateRendering(renderId: number): void;
  80566. /** @hidden */
  80567. _activate(renderId: number): void;
  80568. /**
  80569. * Gets the current world matrix
  80570. * @returns a Matrix
  80571. */
  80572. getWorldMatrix(): Matrix;
  80573. /** @hidden */
  80574. _getWorldMatrixDeterminant(): number;
  80575. /**
  80576. * Perform relative position change from the point of view of behind the front of the mesh.
  80577. * This is performed taking into account the meshes current rotation, so you do not have to care.
  80578. * Supports definition of mesh facing forward or backward
  80579. * @param amountRight defines the distance on the right axis
  80580. * @param amountUp defines the distance on the up axis
  80581. * @param amountForward defines the distance on the forward axis
  80582. * @returns the current mesh
  80583. */
  80584. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  80585. /**
  80586. * Calculate relative position change from the point of view of behind the front of the mesh.
  80587. * This is performed taking into account the meshes current rotation, so you do not have to care.
  80588. * Supports definition of mesh facing forward or backward
  80589. * @param amountRight defines the distance on the right axis
  80590. * @param amountUp defines the distance on the up axis
  80591. * @param amountForward defines the distance on the forward axis
  80592. * @returns the new displacement vector
  80593. */
  80594. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  80595. /**
  80596. * Perform relative rotation change from the point of view of behind the front of the mesh.
  80597. * Supports definition of mesh facing forward or backward
  80598. * @param flipBack defines the flip
  80599. * @param twirlClockwise defines the twirl
  80600. * @param tiltRight defines the tilt
  80601. * @returns the current mesh
  80602. */
  80603. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  80604. /**
  80605. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  80606. * Supports definition of mesh facing forward or backward.
  80607. * @param flipBack defines the flip
  80608. * @param twirlClockwise defines the twirl
  80609. * @param tiltRight defines the tilt
  80610. * @returns the new rotation vector
  80611. */
  80612. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  80613. /**
  80614. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  80615. * @param includeDescendants Include bounding info from descendants as well (true by default)
  80616. * @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
  80617. * @returns the new bounding vectors
  80618. */
  80619. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  80620. min: Vector3;
  80621. max: Vector3;
  80622. };
  80623. /**
  80624. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  80625. * This means the mesh underlying bounding box and sphere are recomputed.
  80626. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  80627. * @returns the current mesh
  80628. */
  80629. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  80630. /** @hidden */
  80631. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  80632. /** @hidden */
  80633. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  80634. /** @hidden */
  80635. _updateBoundingInfo(): AbstractMesh;
  80636. /** @hidden */
  80637. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  80638. /** @hidden */
  80639. protected _afterComputeWorldMatrix(): void;
  80640. /**
  80641. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  80642. * A mesh is in the frustum if its bounding box intersects the frustum
  80643. * @param frustumPlanes defines the frustum to test
  80644. * @returns true if the mesh is in the frustum planes
  80645. */
  80646. isInFrustum(frustumPlanes: Plane[]): boolean;
  80647. /**
  80648. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  80649. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  80650. * @param frustumPlanes defines the frustum to test
  80651. * @returns true if the mesh is completely in the frustum planes
  80652. */
  80653. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  80654. /**
  80655. * True if the mesh intersects another mesh or a SolidParticle object
  80656. * @param mesh defines a target mesh or SolidParticle to test
  80657. * @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)
  80658. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  80659. * @returns true if there is an intersection
  80660. */
  80661. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  80662. /**
  80663. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  80664. * @param point defines the point to test
  80665. * @returns true if there is an intersection
  80666. */
  80667. intersectsPoint(point: Vector3): boolean;
  80668. /**
  80669. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  80670. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  80671. */
  80672. checkCollisions: boolean;
  80673. /**
  80674. * Gets Collider object used to compute collisions (not physics)
  80675. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  80676. */
  80677. readonly collider: Collider;
  80678. /**
  80679. * Move the mesh using collision engine
  80680. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  80681. * @param displacement defines the requested displacement vector
  80682. * @returns the current mesh
  80683. */
  80684. moveWithCollisions(displacement: Vector3): AbstractMesh;
  80685. private _onCollisionPositionChange;
  80686. /** @hidden */
  80687. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  80688. /** @hidden */
  80689. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  80690. /** @hidden */
  80691. _checkCollision(collider: Collider): AbstractMesh;
  80692. /** @hidden */
  80693. _generatePointsArray(): boolean;
  80694. /**
  80695. * Checks if the passed Ray intersects with the mesh
  80696. * @param ray defines the ray to use
  80697. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  80698. * @returns the picking info
  80699. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  80700. */
  80701. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  80702. /**
  80703. * Clones the current mesh
  80704. * @param name defines the mesh name
  80705. * @param newParent defines the new mesh parent
  80706. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  80707. * @returns the new mesh
  80708. */
  80709. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  80710. /**
  80711. * Disposes all the submeshes of the current meshnp
  80712. * @returns the current mesh
  80713. */
  80714. releaseSubMeshes(): AbstractMesh;
  80715. /**
  80716. * Releases resources associated with this abstract mesh.
  80717. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  80718. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  80719. */
  80720. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  80721. /**
  80722. * Adds the passed mesh as a child to the current mesh
  80723. * @param mesh defines the child mesh
  80724. * @returns the current mesh
  80725. */
  80726. addChild(mesh: AbstractMesh): AbstractMesh;
  80727. /**
  80728. * Removes the passed mesh from the current mesh children list
  80729. * @param mesh defines the child mesh
  80730. * @returns the current mesh
  80731. */
  80732. removeChild(mesh: AbstractMesh): AbstractMesh;
  80733. /** @hidden */
  80734. private _initFacetData;
  80735. /**
  80736. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  80737. * This method can be called within the render loop.
  80738. * 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
  80739. * @returns the current mesh
  80740. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80741. */
  80742. updateFacetData(): AbstractMesh;
  80743. /**
  80744. * Returns the facetLocalNormals array.
  80745. * The normals are expressed in the mesh local spac
  80746. * @returns an array of Vector3
  80747. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80748. */
  80749. getFacetLocalNormals(): Vector3[];
  80750. /**
  80751. * Returns the facetLocalPositions array.
  80752. * The facet positions are expressed in the mesh local space
  80753. * @returns an array of Vector3
  80754. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80755. */
  80756. getFacetLocalPositions(): Vector3[];
  80757. /**
  80758. * Returns the facetLocalPartioning array
  80759. * @returns an array of array of numbers
  80760. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80761. */
  80762. getFacetLocalPartitioning(): number[][];
  80763. /**
  80764. * Returns the i-th facet position in the world system.
  80765. * This method allocates a new Vector3 per call
  80766. * @param i defines the facet index
  80767. * @returns a new Vector3
  80768. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80769. */
  80770. getFacetPosition(i: number): Vector3;
  80771. /**
  80772. * Sets the reference Vector3 with the i-th facet position in the world system
  80773. * @param i defines the facet index
  80774. * @param ref defines the target vector
  80775. * @returns the current mesh
  80776. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80777. */
  80778. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  80779. /**
  80780. * Returns the i-th facet normal in the world system.
  80781. * This method allocates a new Vector3 per call
  80782. * @param i defines the facet index
  80783. * @returns a new Vector3
  80784. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80785. */
  80786. getFacetNormal(i: number): Vector3;
  80787. /**
  80788. * Sets the reference Vector3 with the i-th facet normal in the world system
  80789. * @param i defines the facet index
  80790. * @param ref defines the target vector
  80791. * @returns the current mesh
  80792. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80793. */
  80794. getFacetNormalToRef(i: number, ref: Vector3): this;
  80795. /**
  80796. * 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)
  80797. * @param x defines x coordinate
  80798. * @param y defines y coordinate
  80799. * @param z defines z coordinate
  80800. * @returns the array of facet indexes
  80801. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80802. */
  80803. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  80804. /**
  80805. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  80806. * @param projected sets as the (x,y,z) world projection on the facet
  80807. * @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
  80808. * @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
  80809. * @param x defines x coordinate
  80810. * @param y defines y coordinate
  80811. * @param z defines z coordinate
  80812. * @returns the face index if found (or null instead)
  80813. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80814. */
  80815. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  80816. /**
  80817. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  80818. * @param projected sets as the (x,y,z) local projection on the facet
  80819. * @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
  80820. * @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
  80821. * @param x defines x coordinate
  80822. * @param y defines y coordinate
  80823. * @param z defines z coordinate
  80824. * @returns the face index if found (or null instead)
  80825. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80826. */
  80827. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  80828. /**
  80829. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  80830. * @returns the parameters
  80831. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80832. */
  80833. getFacetDataParameters(): any;
  80834. /**
  80835. * Disables the feature FacetData and frees the related memory
  80836. * @returns the current mesh
  80837. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80838. */
  80839. disableFacetData(): AbstractMesh;
  80840. /**
  80841. * Updates the AbstractMesh indices array
  80842. * @param indices defines the data source
  80843. * @returns the current mesh
  80844. */
  80845. updateIndices(indices: IndicesArray): AbstractMesh;
  80846. /**
  80847. * Creates new normals data for the mesh
  80848. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  80849. * @returns the current mesh
  80850. */
  80851. createNormals(updatable: boolean): AbstractMesh;
  80852. /**
  80853. * Align the mesh with a normal
  80854. * @param normal defines the normal to use
  80855. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  80856. * @returns the current mesh
  80857. */
  80858. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  80859. /** @hidden */
  80860. _checkOcclusionQuery(): boolean;
  80861. }
  80862. }
  80863. declare module BABYLON {
  80864. /**
  80865. * Interface used to define ActionEvent
  80866. */
  80867. export interface IActionEvent {
  80868. /** The mesh or sprite that triggered the action */
  80869. source: any;
  80870. /** The X mouse cursor position at the time of the event */
  80871. pointerX: number;
  80872. /** The Y mouse cursor position at the time of the event */
  80873. pointerY: number;
  80874. /** The mesh that is currently pointed at (can be null) */
  80875. meshUnderPointer: Nullable<AbstractMesh>;
  80876. /** the original (browser) event that triggered the ActionEvent */
  80877. sourceEvent?: any;
  80878. /** additional data for the event */
  80879. additionalData?: any;
  80880. }
  80881. /**
  80882. * ActionEvent is the event being sent when an action is triggered.
  80883. */
  80884. export class ActionEvent implements IActionEvent {
  80885. /** The mesh or sprite that triggered the action */
  80886. source: any;
  80887. /** The X mouse cursor position at the time of the event */
  80888. pointerX: number;
  80889. /** The Y mouse cursor position at the time of the event */
  80890. pointerY: number;
  80891. /** The mesh that is currently pointed at (can be null) */
  80892. meshUnderPointer: Nullable<AbstractMesh>;
  80893. /** the original (browser) event that triggered the ActionEvent */
  80894. sourceEvent?: any;
  80895. /** additional data for the event */
  80896. additionalData?: any;
  80897. /**
  80898. * Creates a new ActionEvent
  80899. * @param source The mesh or sprite that triggered the action
  80900. * @param pointerX The X mouse cursor position at the time of the event
  80901. * @param pointerY The Y mouse cursor position at the time of the event
  80902. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  80903. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  80904. * @param additionalData additional data for the event
  80905. */
  80906. constructor(
  80907. /** The mesh or sprite that triggered the action */
  80908. source: any,
  80909. /** The X mouse cursor position at the time of the event */
  80910. pointerX: number,
  80911. /** The Y mouse cursor position at the time of the event */
  80912. pointerY: number,
  80913. /** The mesh that is currently pointed at (can be null) */
  80914. meshUnderPointer: Nullable<AbstractMesh>,
  80915. /** the original (browser) event that triggered the ActionEvent */
  80916. sourceEvent?: any,
  80917. /** additional data for the event */
  80918. additionalData?: any);
  80919. /**
  80920. * Helper function to auto-create an ActionEvent from a source mesh.
  80921. * @param source The source mesh that triggered the event
  80922. * @param evt The original (browser) event
  80923. * @param additionalData additional data for the event
  80924. * @returns the new ActionEvent
  80925. */
  80926. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  80927. /**
  80928. * Helper function to auto-create an ActionEvent from a source sprite
  80929. * @param source The source sprite that triggered the event
  80930. * @param scene Scene associated with the sprite
  80931. * @param evt The original (browser) event
  80932. * @param additionalData additional data for the event
  80933. * @returns the new ActionEvent
  80934. */
  80935. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  80936. /**
  80937. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  80938. * @param scene the scene where the event occurred
  80939. * @param evt The original (browser) event
  80940. * @returns the new ActionEvent
  80941. */
  80942. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  80943. /**
  80944. * Helper function to auto-create an ActionEvent from a primitive
  80945. * @param prim defines the target primitive
  80946. * @param pointerPos defines the pointer position
  80947. * @param evt The original (browser) event
  80948. * @param additionalData additional data for the event
  80949. * @returns the new ActionEvent
  80950. */
  80951. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  80952. }
  80953. }
  80954. declare module BABYLON {
  80955. /**
  80956. * Abstract class used to decouple action Manager from scene and meshes.
  80957. * Do not instantiate.
  80958. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  80959. */
  80960. export abstract class AbstractActionManager implements IDisposable {
  80961. /** Gets the list of active triggers */
  80962. static Triggers: {
  80963. [key: string]: number;
  80964. };
  80965. /** Gets the cursor to use when hovering items */
  80966. hoverCursor: string;
  80967. /** Gets the list of actions */
  80968. actions: IAction[];
  80969. /**
  80970. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  80971. */
  80972. isRecursive: boolean;
  80973. /**
  80974. * Releases all associated resources
  80975. */
  80976. abstract dispose(): void;
  80977. /**
  80978. * Does this action manager has pointer triggers
  80979. */
  80980. abstract readonly hasPointerTriggers: boolean;
  80981. /**
  80982. * Does this action manager has pick triggers
  80983. */
  80984. abstract readonly hasPickTriggers: boolean;
  80985. /**
  80986. * Process a specific trigger
  80987. * @param trigger defines the trigger to process
  80988. * @param evt defines the event details to be processed
  80989. */
  80990. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  80991. /**
  80992. * Does this action manager handles actions of any of the given triggers
  80993. * @param triggers defines the triggers to be tested
  80994. * @return a boolean indicating whether one (or more) of the triggers is handled
  80995. */
  80996. abstract hasSpecificTriggers(triggers: number[]): boolean;
  80997. /**
  80998. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  80999. * speed.
  81000. * @param triggerA defines the trigger to be tested
  81001. * @param triggerB defines the trigger to be tested
  81002. * @return a boolean indicating whether one (or more) of the triggers is handled
  81003. */
  81004. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  81005. /**
  81006. * Does this action manager handles actions of a given trigger
  81007. * @param trigger defines the trigger to be tested
  81008. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  81009. * @return whether the trigger is handled
  81010. */
  81011. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  81012. /**
  81013. * Serialize this manager to a JSON object
  81014. * @param name defines the property name to store this manager
  81015. * @returns a JSON representation of this manager
  81016. */
  81017. abstract serialize(name: string): any;
  81018. /**
  81019. * Does exist one action manager with at least one trigger
  81020. **/
  81021. static readonly HasTriggers: boolean;
  81022. /**
  81023. * Does exist one action manager with at least one pick trigger
  81024. **/
  81025. static readonly HasPickTriggers: boolean;
  81026. /**
  81027. * Does exist one action manager that handles actions of a given trigger
  81028. * @param trigger defines the trigger to be tested
  81029. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  81030. **/
  81031. static HasSpecificTrigger(trigger: number): boolean;
  81032. }
  81033. }
  81034. declare module BABYLON {
  81035. /**
  81036. * Defines how a node can be built from a string name.
  81037. */
  81038. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  81039. /**
  81040. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  81041. */
  81042. export class Node implements IBehaviorAware<Node> {
  81043. /** @hidden */
  81044. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  81045. private static _NodeConstructors;
  81046. /**
  81047. * Add a new node constructor
  81048. * @param type defines the type name of the node to construct
  81049. * @param constructorFunc defines the constructor function
  81050. */
  81051. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  81052. /**
  81053. * Returns a node constructor based on type name
  81054. * @param type defines the type name
  81055. * @param name defines the new node name
  81056. * @param scene defines the hosting scene
  81057. * @param options defines optional options to transmit to constructors
  81058. * @returns the new constructor or null
  81059. */
  81060. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  81061. /**
  81062. * Gets or sets the name of the node
  81063. */
  81064. name: string;
  81065. /**
  81066. * Gets or sets the id of the node
  81067. */
  81068. id: string;
  81069. /**
  81070. * Gets or sets the unique id of the node
  81071. */
  81072. uniqueId: number;
  81073. /**
  81074. * Gets or sets a string used to store user defined state for the node
  81075. */
  81076. state: string;
  81077. /**
  81078. * Gets or sets an object used to store user defined information for the node
  81079. */
  81080. metadata: any;
  81081. /**
  81082. * For internal use only. Please do not use.
  81083. */
  81084. reservedDataStore: any;
  81085. /**
  81086. * Gets or sets a boolean used to define if the node must be serialized
  81087. */
  81088. doNotSerialize: boolean;
  81089. /** @hidden */
  81090. _isDisposed: boolean;
  81091. /**
  81092. * Gets a list of Animations associated with the node
  81093. */
  81094. animations: Animation[];
  81095. protected _ranges: {
  81096. [name: string]: Nullable<AnimationRange>;
  81097. };
  81098. /**
  81099. * Callback raised when the node is ready to be used
  81100. */
  81101. onReady: (node: Node) => void;
  81102. private _isEnabled;
  81103. private _isParentEnabled;
  81104. private _isReady;
  81105. /** @hidden */
  81106. _currentRenderId: number;
  81107. private _parentRenderId;
  81108. protected _childRenderId: number;
  81109. /** @hidden */
  81110. _waitingParentId: Nullable<string>;
  81111. /** @hidden */
  81112. _scene: Scene;
  81113. /** @hidden */
  81114. _cache: any;
  81115. private _parentNode;
  81116. private _children;
  81117. /** @hidden */
  81118. _worldMatrix: Matrix;
  81119. /** @hidden */
  81120. _worldMatrixDeterminant: number;
  81121. /** @hidden */
  81122. private _sceneRootNodesIndex;
  81123. /**
  81124. * Gets a boolean indicating if the node has been disposed
  81125. * @returns true if the node was disposed
  81126. */
  81127. isDisposed(): boolean;
  81128. /**
  81129. * Gets or sets the parent of the node
  81130. */
  81131. parent: Nullable<Node>;
  81132. private addToSceneRootNodes;
  81133. private removeFromSceneRootNodes;
  81134. private _animationPropertiesOverride;
  81135. /**
  81136. * Gets or sets the animation properties override
  81137. */
  81138. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  81139. /**
  81140. * Gets a string idenfifying the name of the class
  81141. * @returns "Node" string
  81142. */
  81143. getClassName(): string;
  81144. /** @hidden */
  81145. readonly _isNode: boolean;
  81146. /**
  81147. * An event triggered when the mesh is disposed
  81148. */
  81149. onDisposeObservable: Observable<Node>;
  81150. private _onDisposeObserver;
  81151. /**
  81152. * Sets a callback that will be raised when the node will be disposed
  81153. */
  81154. onDispose: () => void;
  81155. /**
  81156. * Creates a new Node
  81157. * @param name the name and id to be given to this node
  81158. * @param scene the scene this node will be added to
  81159. * @param addToRootNodes the node will be added to scene.rootNodes
  81160. */
  81161. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  81162. /**
  81163. * Gets the scene of the node
  81164. * @returns a scene
  81165. */
  81166. getScene(): Scene;
  81167. /**
  81168. * Gets the engine of the node
  81169. * @returns a Engine
  81170. */
  81171. getEngine(): Engine;
  81172. private _behaviors;
  81173. /**
  81174. * Attach a behavior to the node
  81175. * @see http://doc.babylonjs.com/features/behaviour
  81176. * @param behavior defines the behavior to attach
  81177. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  81178. * @returns the current Node
  81179. */
  81180. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  81181. /**
  81182. * Remove an attached behavior
  81183. * @see http://doc.babylonjs.com/features/behaviour
  81184. * @param behavior defines the behavior to attach
  81185. * @returns the current Node
  81186. */
  81187. removeBehavior(behavior: Behavior<Node>): Node;
  81188. /**
  81189. * Gets the list of attached behaviors
  81190. * @see http://doc.babylonjs.com/features/behaviour
  81191. */
  81192. readonly behaviors: Behavior<Node>[];
  81193. /**
  81194. * Gets an attached behavior by name
  81195. * @param name defines the name of the behavior to look for
  81196. * @see http://doc.babylonjs.com/features/behaviour
  81197. * @returns null if behavior was not found else the requested behavior
  81198. */
  81199. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  81200. /**
  81201. * Returns the latest update of the World matrix
  81202. * @returns a Matrix
  81203. */
  81204. getWorldMatrix(): Matrix;
  81205. /** @hidden */
  81206. _getWorldMatrixDeterminant(): number;
  81207. /**
  81208. * Returns directly the latest state of the mesh World matrix.
  81209. * A Matrix is returned.
  81210. */
  81211. readonly worldMatrixFromCache: Matrix;
  81212. /** @hidden */
  81213. _initCache(): void;
  81214. /** @hidden */
  81215. updateCache(force?: boolean): void;
  81216. /** @hidden */
  81217. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  81218. /** @hidden */
  81219. _updateCache(ignoreParentClass?: boolean): void;
  81220. /** @hidden */
  81221. _isSynchronized(): boolean;
  81222. /** @hidden */
  81223. _markSyncedWithParent(): void;
  81224. /** @hidden */
  81225. isSynchronizedWithParent(): boolean;
  81226. /** @hidden */
  81227. isSynchronized(): boolean;
  81228. /**
  81229. * Is this node ready to be used/rendered
  81230. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  81231. * @return true if the node is ready
  81232. */
  81233. isReady(completeCheck?: boolean): boolean;
  81234. /**
  81235. * Is this node enabled?
  81236. * 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
  81237. * @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
  81238. * @return whether this node (and its parent) is enabled
  81239. */
  81240. isEnabled(checkAncestors?: boolean): boolean;
  81241. /** @hidden */
  81242. protected _syncParentEnabledState(): void;
  81243. /**
  81244. * Set the enabled state of this node
  81245. * @param value defines the new enabled state
  81246. */
  81247. setEnabled(value: boolean): void;
  81248. /**
  81249. * Is this node a descendant of the given node?
  81250. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  81251. * @param ancestor defines the parent node to inspect
  81252. * @returns a boolean indicating if this node is a descendant of the given node
  81253. */
  81254. isDescendantOf(ancestor: Node): boolean;
  81255. /** @hidden */
  81256. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  81257. /**
  81258. * Will return all nodes that have this node as ascendant
  81259. * @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
  81260. * @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
  81261. * @return all children nodes of all types
  81262. */
  81263. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  81264. /**
  81265. * Get all child-meshes of this node
  81266. * @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)
  81267. * @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
  81268. * @returns an array of AbstractMesh
  81269. */
  81270. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  81271. /**
  81272. * Get all direct children of this node
  81273. * @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
  81274. * @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)
  81275. * @returns an array of Node
  81276. */
  81277. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  81278. /** @hidden */
  81279. _setReady(state: boolean): void;
  81280. /**
  81281. * Get an animation by name
  81282. * @param name defines the name of the animation to look for
  81283. * @returns null if not found else the requested animation
  81284. */
  81285. getAnimationByName(name: string): Nullable<Animation>;
  81286. /**
  81287. * Creates an animation range for this node
  81288. * @param name defines the name of the range
  81289. * @param from defines the starting key
  81290. * @param to defines the end key
  81291. */
  81292. createAnimationRange(name: string, from: number, to: number): void;
  81293. /**
  81294. * Delete a specific animation range
  81295. * @param name defines the name of the range to delete
  81296. * @param deleteFrames defines if animation frames from the range must be deleted as well
  81297. */
  81298. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  81299. /**
  81300. * Get an animation range by name
  81301. * @param name defines the name of the animation range to look for
  81302. * @returns null if not found else the requested animation range
  81303. */
  81304. getAnimationRange(name: string): Nullable<AnimationRange>;
  81305. /**
  81306. * Will start the animation sequence
  81307. * @param name defines the range frames for animation sequence
  81308. * @param loop defines if the animation should loop (false by default)
  81309. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  81310. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  81311. * @returns the object created for this animation. If range does not exist, it will return null
  81312. */
  81313. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  81314. /**
  81315. * Serialize animation ranges into a JSON compatible object
  81316. * @returns serialization object
  81317. */
  81318. serializeAnimationRanges(): any;
  81319. /**
  81320. * Computes the world matrix of the node
  81321. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  81322. * @returns the world matrix
  81323. */
  81324. computeWorldMatrix(force?: boolean): Matrix;
  81325. /**
  81326. * Releases resources associated with this node.
  81327. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81328. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81329. */
  81330. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81331. /**
  81332. * Parse animation range data from a serialization object and store them into a given node
  81333. * @param node defines where to store the animation ranges
  81334. * @param parsedNode defines the serialization object to read data from
  81335. * @param scene defines the hosting scene
  81336. */
  81337. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  81338. }
  81339. }
  81340. declare module BABYLON {
  81341. /**
  81342. * Class used to store any kind of animation
  81343. */
  81344. export class Animation {
  81345. /**Name of the animation */
  81346. name: string;
  81347. /**Property to animate */
  81348. targetProperty: string;
  81349. /**The frames per second of the animation */
  81350. framePerSecond: number;
  81351. /**The data type of the animation */
  81352. dataType: number;
  81353. /**The loop mode of the animation */
  81354. loopMode?: number | undefined;
  81355. /**Specifies if blending should be enabled */
  81356. enableBlending?: boolean | undefined;
  81357. /**
  81358. * Use matrix interpolation instead of using direct key value when animating matrices
  81359. */
  81360. static AllowMatricesInterpolation: boolean;
  81361. /**
  81362. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  81363. */
  81364. static AllowMatrixDecomposeForInterpolation: boolean;
  81365. /**
  81366. * Stores the key frames of the animation
  81367. */
  81368. private _keys;
  81369. /**
  81370. * Stores the easing function of the animation
  81371. */
  81372. private _easingFunction;
  81373. /**
  81374. * @hidden Internal use only
  81375. */
  81376. _runtimeAnimations: RuntimeAnimation[];
  81377. /**
  81378. * The set of event that will be linked to this animation
  81379. */
  81380. private _events;
  81381. /**
  81382. * Stores an array of target property paths
  81383. */
  81384. targetPropertyPath: string[];
  81385. /**
  81386. * Stores the blending speed of the animation
  81387. */
  81388. blendingSpeed: number;
  81389. /**
  81390. * Stores the animation ranges for the animation
  81391. */
  81392. private _ranges;
  81393. /**
  81394. * @hidden Internal use
  81395. */
  81396. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  81397. /**
  81398. * Sets up an animation
  81399. * @param property The property to animate
  81400. * @param animationType The animation type to apply
  81401. * @param framePerSecond The frames per second of the animation
  81402. * @param easingFunction The easing function used in the animation
  81403. * @returns The created animation
  81404. */
  81405. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  81406. /**
  81407. * Create and start an animation on a node
  81408. * @param name defines the name of the global animation that will be run on all nodes
  81409. * @param node defines the root node where the animation will take place
  81410. * @param targetProperty defines property to animate
  81411. * @param framePerSecond defines the number of frame per second yo use
  81412. * @param totalFrame defines the number of frames in total
  81413. * @param from defines the initial value
  81414. * @param to defines the final value
  81415. * @param loopMode defines which loop mode you want to use (off by default)
  81416. * @param easingFunction defines the easing function to use (linear by default)
  81417. * @param onAnimationEnd defines the callback to call when animation end
  81418. * @returns the animatable created for this animation
  81419. */
  81420. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  81421. /**
  81422. * Create and start an animation on a node and its descendants
  81423. * @param name defines the name of the global animation that will be run on all nodes
  81424. * @param node defines the root node where the animation will take place
  81425. * @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
  81426. * @param targetProperty defines property to animate
  81427. * @param framePerSecond defines the number of frame per second to use
  81428. * @param totalFrame defines the number of frames in total
  81429. * @param from defines the initial value
  81430. * @param to defines the final value
  81431. * @param loopMode defines which loop mode you want to use (off by default)
  81432. * @param easingFunction defines the easing function to use (linear by default)
  81433. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  81434. * @returns the list of animatables created for all nodes
  81435. * @example https://www.babylonjs-playground.com/#MH0VLI
  81436. */
  81437. 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[]>;
  81438. /**
  81439. * Creates a new animation, merges it with the existing animations and starts it
  81440. * @param name Name of the animation
  81441. * @param node Node which contains the scene that begins the animations
  81442. * @param targetProperty Specifies which property to animate
  81443. * @param framePerSecond The frames per second of the animation
  81444. * @param totalFrame The total number of frames
  81445. * @param from The frame at the beginning of the animation
  81446. * @param to The frame at the end of the animation
  81447. * @param loopMode Specifies the loop mode of the animation
  81448. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  81449. * @param onAnimationEnd Callback to run once the animation is complete
  81450. * @returns Nullable animation
  81451. */
  81452. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  81453. /**
  81454. * Transition property of an host to the target Value
  81455. * @param property The property to transition
  81456. * @param targetValue The target Value of the property
  81457. * @param host The object where the property to animate belongs
  81458. * @param scene Scene used to run the animation
  81459. * @param frameRate Framerate (in frame/s) to use
  81460. * @param transition The transition type we want to use
  81461. * @param duration The duration of the animation, in milliseconds
  81462. * @param onAnimationEnd Callback trigger at the end of the animation
  81463. * @returns Nullable animation
  81464. */
  81465. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  81466. /**
  81467. * Return the array of runtime animations currently using this animation
  81468. */
  81469. readonly runtimeAnimations: RuntimeAnimation[];
  81470. /**
  81471. * Specifies if any of the runtime animations are currently running
  81472. */
  81473. readonly hasRunningRuntimeAnimations: boolean;
  81474. /**
  81475. * Initializes the animation
  81476. * @param name Name of the animation
  81477. * @param targetProperty Property to animate
  81478. * @param framePerSecond The frames per second of the animation
  81479. * @param dataType The data type of the animation
  81480. * @param loopMode The loop mode of the animation
  81481. * @param enableBlending Specifies if blending should be enabled
  81482. */
  81483. constructor(
  81484. /**Name of the animation */
  81485. name: string,
  81486. /**Property to animate */
  81487. targetProperty: string,
  81488. /**The frames per second of the animation */
  81489. framePerSecond: number,
  81490. /**The data type of the animation */
  81491. dataType: number,
  81492. /**The loop mode of the animation */
  81493. loopMode?: number | undefined,
  81494. /**Specifies if blending should be enabled */
  81495. enableBlending?: boolean | undefined);
  81496. /**
  81497. * Converts the animation to a string
  81498. * @param fullDetails support for multiple levels of logging within scene loading
  81499. * @returns String form of the animation
  81500. */
  81501. toString(fullDetails?: boolean): string;
  81502. /**
  81503. * Add an event to this animation
  81504. * @param event Event to add
  81505. */
  81506. addEvent(event: AnimationEvent): void;
  81507. /**
  81508. * Remove all events found at the given frame
  81509. * @param frame The frame to remove events from
  81510. */
  81511. removeEvents(frame: number): void;
  81512. /**
  81513. * Retrieves all the events from the animation
  81514. * @returns Events from the animation
  81515. */
  81516. getEvents(): AnimationEvent[];
  81517. /**
  81518. * Creates an animation range
  81519. * @param name Name of the animation range
  81520. * @param from Starting frame of the animation range
  81521. * @param to Ending frame of the animation
  81522. */
  81523. createRange(name: string, from: number, to: number): void;
  81524. /**
  81525. * Deletes an animation range by name
  81526. * @param name Name of the animation range to delete
  81527. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  81528. */
  81529. deleteRange(name: string, deleteFrames?: boolean): void;
  81530. /**
  81531. * Gets the animation range by name, or null if not defined
  81532. * @param name Name of the animation range
  81533. * @returns Nullable animation range
  81534. */
  81535. getRange(name: string): Nullable<AnimationRange>;
  81536. /**
  81537. * Gets the key frames from the animation
  81538. * @returns The key frames of the animation
  81539. */
  81540. getKeys(): Array<IAnimationKey>;
  81541. /**
  81542. * Gets the highest frame rate of the animation
  81543. * @returns Highest frame rate of the animation
  81544. */
  81545. getHighestFrame(): number;
  81546. /**
  81547. * Gets the easing function of the animation
  81548. * @returns Easing function of the animation
  81549. */
  81550. getEasingFunction(): IEasingFunction;
  81551. /**
  81552. * Sets the easing function of the animation
  81553. * @param easingFunction A custom mathematical formula for animation
  81554. */
  81555. setEasingFunction(easingFunction: EasingFunction): void;
  81556. /**
  81557. * Interpolates a scalar linearly
  81558. * @param startValue Start value of the animation curve
  81559. * @param endValue End value of the animation curve
  81560. * @param gradient Scalar amount to interpolate
  81561. * @returns Interpolated scalar value
  81562. */
  81563. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  81564. /**
  81565. * Interpolates a scalar cubically
  81566. * @param startValue Start value of the animation curve
  81567. * @param outTangent End tangent of the animation
  81568. * @param endValue End value of the animation curve
  81569. * @param inTangent Start tangent of the animation curve
  81570. * @param gradient Scalar amount to interpolate
  81571. * @returns Interpolated scalar value
  81572. */
  81573. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  81574. /**
  81575. * Interpolates a quaternion using a spherical linear interpolation
  81576. * @param startValue Start value of the animation curve
  81577. * @param endValue End value of the animation curve
  81578. * @param gradient Scalar amount to interpolate
  81579. * @returns Interpolated quaternion value
  81580. */
  81581. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  81582. /**
  81583. * Interpolates a quaternion cubically
  81584. * @param startValue Start value of the animation curve
  81585. * @param outTangent End tangent of the animation curve
  81586. * @param endValue End value of the animation curve
  81587. * @param inTangent Start tangent of the animation curve
  81588. * @param gradient Scalar amount to interpolate
  81589. * @returns Interpolated quaternion value
  81590. */
  81591. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  81592. /**
  81593. * Interpolates a Vector3 linearl
  81594. * @param startValue Start value of the animation curve
  81595. * @param endValue End value of the animation curve
  81596. * @param gradient Scalar amount to interpolate
  81597. * @returns Interpolated scalar value
  81598. */
  81599. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  81600. /**
  81601. * Interpolates a Vector3 cubically
  81602. * @param startValue Start value of the animation curve
  81603. * @param outTangent End tangent of the animation
  81604. * @param endValue End value of the animation curve
  81605. * @param inTangent Start tangent of the animation curve
  81606. * @param gradient Scalar amount to interpolate
  81607. * @returns InterpolatedVector3 value
  81608. */
  81609. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  81610. /**
  81611. * Interpolates a Vector2 linearly
  81612. * @param startValue Start value of the animation curve
  81613. * @param endValue End value of the animation curve
  81614. * @param gradient Scalar amount to interpolate
  81615. * @returns Interpolated Vector2 value
  81616. */
  81617. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  81618. /**
  81619. * Interpolates a Vector2 cubically
  81620. * @param startValue Start value of the animation curve
  81621. * @param outTangent End tangent of the animation
  81622. * @param endValue End value of the animation curve
  81623. * @param inTangent Start tangent of the animation curve
  81624. * @param gradient Scalar amount to interpolate
  81625. * @returns Interpolated Vector2 value
  81626. */
  81627. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  81628. /**
  81629. * Interpolates a size linearly
  81630. * @param startValue Start value of the animation curve
  81631. * @param endValue End value of the animation curve
  81632. * @param gradient Scalar amount to interpolate
  81633. * @returns Interpolated Size value
  81634. */
  81635. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  81636. /**
  81637. * Interpolates a Color3 linearly
  81638. * @param startValue Start value of the animation curve
  81639. * @param endValue End value of the animation curve
  81640. * @param gradient Scalar amount to interpolate
  81641. * @returns Interpolated Color3 value
  81642. */
  81643. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  81644. /**
  81645. * @hidden Internal use only
  81646. */
  81647. _getKeyValue(value: any): any;
  81648. /**
  81649. * @hidden Internal use only
  81650. */
  81651. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  81652. /**
  81653. * Defines the function to use to interpolate matrices
  81654. * @param startValue defines the start matrix
  81655. * @param endValue defines the end matrix
  81656. * @param gradient defines the gradient between both matrices
  81657. * @param result defines an optional target matrix where to store the interpolation
  81658. * @returns the interpolated matrix
  81659. */
  81660. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  81661. /**
  81662. * Makes a copy of the animation
  81663. * @returns Cloned animation
  81664. */
  81665. clone(): Animation;
  81666. /**
  81667. * Sets the key frames of the animation
  81668. * @param values The animation key frames to set
  81669. */
  81670. setKeys(values: Array<IAnimationKey>): void;
  81671. /**
  81672. * Serializes the animation to an object
  81673. * @returns Serialized object
  81674. */
  81675. serialize(): any;
  81676. /**
  81677. * Float animation type
  81678. */
  81679. private static _ANIMATIONTYPE_FLOAT;
  81680. /**
  81681. * Vector3 animation type
  81682. */
  81683. private static _ANIMATIONTYPE_VECTOR3;
  81684. /**
  81685. * Quaternion animation type
  81686. */
  81687. private static _ANIMATIONTYPE_QUATERNION;
  81688. /**
  81689. * Matrix animation type
  81690. */
  81691. private static _ANIMATIONTYPE_MATRIX;
  81692. /**
  81693. * Color3 animation type
  81694. */
  81695. private static _ANIMATIONTYPE_COLOR3;
  81696. /**
  81697. * Vector2 animation type
  81698. */
  81699. private static _ANIMATIONTYPE_VECTOR2;
  81700. /**
  81701. * Size animation type
  81702. */
  81703. private static _ANIMATIONTYPE_SIZE;
  81704. /**
  81705. * Relative Loop Mode
  81706. */
  81707. private static _ANIMATIONLOOPMODE_RELATIVE;
  81708. /**
  81709. * Cycle Loop Mode
  81710. */
  81711. private static _ANIMATIONLOOPMODE_CYCLE;
  81712. /**
  81713. * Constant Loop Mode
  81714. */
  81715. private static _ANIMATIONLOOPMODE_CONSTANT;
  81716. /**
  81717. * Get the float animation type
  81718. */
  81719. static readonly ANIMATIONTYPE_FLOAT: number;
  81720. /**
  81721. * Get the Vector3 animation type
  81722. */
  81723. static readonly ANIMATIONTYPE_VECTOR3: number;
  81724. /**
  81725. * Get the Vector2 animation type
  81726. */
  81727. static readonly ANIMATIONTYPE_VECTOR2: number;
  81728. /**
  81729. * Get the Size animation type
  81730. */
  81731. static readonly ANIMATIONTYPE_SIZE: number;
  81732. /**
  81733. * Get the Quaternion animation type
  81734. */
  81735. static readonly ANIMATIONTYPE_QUATERNION: number;
  81736. /**
  81737. * Get the Matrix animation type
  81738. */
  81739. static readonly ANIMATIONTYPE_MATRIX: number;
  81740. /**
  81741. * Get the Color3 animation type
  81742. */
  81743. static readonly ANIMATIONTYPE_COLOR3: number;
  81744. /**
  81745. * Get the Relative Loop Mode
  81746. */
  81747. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  81748. /**
  81749. * Get the Cycle Loop Mode
  81750. */
  81751. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  81752. /**
  81753. * Get the Constant Loop Mode
  81754. */
  81755. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  81756. /** @hidden */
  81757. static _UniversalLerp(left: any, right: any, amount: number): any;
  81758. /**
  81759. * Parses an animation object and creates an animation
  81760. * @param parsedAnimation Parsed animation object
  81761. * @returns Animation object
  81762. */
  81763. static Parse(parsedAnimation: any): Animation;
  81764. /**
  81765. * Appends the serialized animations from the source animations
  81766. * @param source Source containing the animations
  81767. * @param destination Target to store the animations
  81768. */
  81769. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  81770. }
  81771. }
  81772. declare module BABYLON {
  81773. /**
  81774. * Base class of all the textures in babylon.
  81775. * It groups all the common properties the materials, post process, lights... might need
  81776. * in order to make a correct use of the texture.
  81777. */
  81778. export class BaseTexture implements IAnimatable {
  81779. /**
  81780. * Default anisotropic filtering level for the application.
  81781. * It is set to 4 as a good tradeoff between perf and quality.
  81782. */
  81783. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  81784. /**
  81785. * Gets or sets the unique id of the texture
  81786. */
  81787. uniqueId: number;
  81788. /**
  81789. * Define the name of the texture.
  81790. */
  81791. name: string;
  81792. /**
  81793. * Gets or sets an object used to store user defined information.
  81794. */
  81795. metadata: any;
  81796. /**
  81797. * For internal use only. Please do not use.
  81798. */
  81799. reservedDataStore: any;
  81800. private _hasAlpha;
  81801. /**
  81802. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  81803. */
  81804. hasAlpha: boolean;
  81805. /**
  81806. * Defines if the alpha value should be determined via the rgb values.
  81807. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  81808. */
  81809. getAlphaFromRGB: boolean;
  81810. /**
  81811. * Intensity or strength of the texture.
  81812. * It is commonly used by materials to fine tune the intensity of the texture
  81813. */
  81814. level: number;
  81815. /**
  81816. * Define the UV chanel to use starting from 0 and defaulting to 0.
  81817. * This is part of the texture as textures usually maps to one uv set.
  81818. */
  81819. coordinatesIndex: number;
  81820. private _coordinatesMode;
  81821. /**
  81822. * How a texture is mapped.
  81823. *
  81824. * | Value | Type | Description |
  81825. * | ----- | ----------------------------------- | ----------- |
  81826. * | 0 | EXPLICIT_MODE | |
  81827. * | 1 | SPHERICAL_MODE | |
  81828. * | 2 | PLANAR_MODE | |
  81829. * | 3 | CUBIC_MODE | |
  81830. * | 4 | PROJECTION_MODE | |
  81831. * | 5 | SKYBOX_MODE | |
  81832. * | 6 | INVCUBIC_MODE | |
  81833. * | 7 | EQUIRECTANGULAR_MODE | |
  81834. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  81835. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  81836. */
  81837. coordinatesMode: number;
  81838. /**
  81839. * | Value | Type | Description |
  81840. * | ----- | ------------------ | ----------- |
  81841. * | 0 | CLAMP_ADDRESSMODE | |
  81842. * | 1 | WRAP_ADDRESSMODE | |
  81843. * | 2 | MIRROR_ADDRESSMODE | |
  81844. */
  81845. wrapU: number;
  81846. /**
  81847. * | Value | Type | Description |
  81848. * | ----- | ------------------ | ----------- |
  81849. * | 0 | CLAMP_ADDRESSMODE | |
  81850. * | 1 | WRAP_ADDRESSMODE | |
  81851. * | 2 | MIRROR_ADDRESSMODE | |
  81852. */
  81853. wrapV: number;
  81854. /**
  81855. * | Value | Type | Description |
  81856. * | ----- | ------------------ | ----------- |
  81857. * | 0 | CLAMP_ADDRESSMODE | |
  81858. * | 1 | WRAP_ADDRESSMODE | |
  81859. * | 2 | MIRROR_ADDRESSMODE | |
  81860. */
  81861. wrapR: number;
  81862. /**
  81863. * With compliant hardware and browser (supporting anisotropic filtering)
  81864. * this defines the level of anisotropic filtering in the texture.
  81865. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  81866. */
  81867. anisotropicFilteringLevel: number;
  81868. /**
  81869. * Define if the texture is a cube texture or if false a 2d texture.
  81870. */
  81871. isCube: boolean;
  81872. /**
  81873. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  81874. */
  81875. is3D: boolean;
  81876. /**
  81877. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  81878. * HDR texture are usually stored in linear space.
  81879. * This only impacts the PBR and Background materials
  81880. */
  81881. gammaSpace: boolean;
  81882. /**
  81883. * Gets whether or not the texture contains RGBD data.
  81884. */
  81885. readonly isRGBD: boolean;
  81886. /**
  81887. * Is Z inverted in the texture (useful in a cube texture).
  81888. */
  81889. invertZ: boolean;
  81890. /**
  81891. * Are mip maps generated for this texture or not.
  81892. */
  81893. readonly noMipmap: boolean;
  81894. /**
  81895. * @hidden
  81896. */
  81897. lodLevelInAlpha: boolean;
  81898. /**
  81899. * With prefiltered texture, defined the offset used during the prefiltering steps.
  81900. */
  81901. lodGenerationOffset: number;
  81902. /**
  81903. * With prefiltered texture, defined the scale used during the prefiltering steps.
  81904. */
  81905. lodGenerationScale: number;
  81906. /**
  81907. * Define if the texture is a render target.
  81908. */
  81909. isRenderTarget: boolean;
  81910. /**
  81911. * Define the unique id of the texture in the scene.
  81912. */
  81913. readonly uid: string;
  81914. /**
  81915. * Return a string representation of the texture.
  81916. * @returns the texture as a string
  81917. */
  81918. toString(): string;
  81919. /**
  81920. * Get the class name of the texture.
  81921. * @returns "BaseTexture"
  81922. */
  81923. getClassName(): string;
  81924. /**
  81925. * Define the list of animation attached to the texture.
  81926. */
  81927. animations: Animation[];
  81928. /**
  81929. * An event triggered when the texture is disposed.
  81930. */
  81931. onDisposeObservable: Observable<BaseTexture>;
  81932. private _onDisposeObserver;
  81933. /**
  81934. * Callback triggered when the texture has been disposed.
  81935. * Kept for back compatibility, you can use the onDisposeObservable instead.
  81936. */
  81937. onDispose: () => void;
  81938. /**
  81939. * Define the current state of the loading sequence when in delayed load mode.
  81940. */
  81941. delayLoadState: number;
  81942. private _scene;
  81943. /** @hidden */
  81944. _texture: Nullable<InternalTexture>;
  81945. private _uid;
  81946. /**
  81947. * Define if the texture is preventinga material to render or not.
  81948. * If not and the texture is not ready, the engine will use a default black texture instead.
  81949. */
  81950. readonly isBlocking: boolean;
  81951. /**
  81952. * Instantiates a new BaseTexture.
  81953. * Base class of all the textures in babylon.
  81954. * It groups all the common properties the materials, post process, lights... might need
  81955. * in order to make a correct use of the texture.
  81956. * @param scene Define the scene the texture blongs to
  81957. */
  81958. constructor(scene: Nullable<Scene>);
  81959. /**
  81960. * Get the scene the texture belongs to.
  81961. * @returns the scene or null if undefined
  81962. */
  81963. getScene(): Nullable<Scene>;
  81964. /**
  81965. * Get the texture transform matrix used to offset tile the texture for istance.
  81966. * @returns the transformation matrix
  81967. */
  81968. getTextureMatrix(): Matrix;
  81969. /**
  81970. * Get the texture reflection matrix used to rotate/transform the reflection.
  81971. * @returns the reflection matrix
  81972. */
  81973. getReflectionTextureMatrix(): Matrix;
  81974. /**
  81975. * Get the underlying lower level texture from Babylon.
  81976. * @returns the insternal texture
  81977. */
  81978. getInternalTexture(): Nullable<InternalTexture>;
  81979. /**
  81980. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  81981. * @returns true if ready or not blocking
  81982. */
  81983. isReadyOrNotBlocking(): boolean;
  81984. /**
  81985. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  81986. * @returns true if fully ready
  81987. */
  81988. isReady(): boolean;
  81989. private _cachedSize;
  81990. /**
  81991. * Get the size of the texture.
  81992. * @returns the texture size.
  81993. */
  81994. getSize(): ISize;
  81995. /**
  81996. * Get the base size of the texture.
  81997. * It can be different from the size if the texture has been resized for POT for instance
  81998. * @returns the base size
  81999. */
  82000. getBaseSize(): ISize;
  82001. /**
  82002. * Update the sampling mode of the texture.
  82003. * Default is Trilinear mode.
  82004. *
  82005. * | Value | Type | Description |
  82006. * | ----- | ------------------ | ----------- |
  82007. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  82008. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  82009. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  82010. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  82011. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  82012. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  82013. * | 7 | NEAREST_LINEAR | |
  82014. * | 8 | NEAREST_NEAREST | |
  82015. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  82016. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  82017. * | 11 | LINEAR_LINEAR | |
  82018. * | 12 | LINEAR_NEAREST | |
  82019. *
  82020. * > _mag_: magnification filter (close to the viewer)
  82021. * > _min_: minification filter (far from the viewer)
  82022. * > _mip_: filter used between mip map levels
  82023. *@param samplingMode Define the new sampling mode of the texture
  82024. */
  82025. updateSamplingMode(samplingMode: number): void;
  82026. /**
  82027. * Scales the texture if is `canRescale()`
  82028. * @param ratio the resize factor we want to use to rescale
  82029. */
  82030. scale(ratio: number): void;
  82031. /**
  82032. * Get if the texture can rescale.
  82033. */
  82034. readonly canRescale: boolean;
  82035. /** @hidden */
  82036. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  82037. /** @hidden */
  82038. _rebuild(): void;
  82039. /**
  82040. * Triggers the load sequence in delayed load mode.
  82041. */
  82042. delayLoad(): void;
  82043. /**
  82044. * Clones the texture.
  82045. * @returns the cloned texture
  82046. */
  82047. clone(): Nullable<BaseTexture>;
  82048. /**
  82049. * Get the texture underlying type (INT, FLOAT...)
  82050. */
  82051. readonly textureType: number;
  82052. /**
  82053. * Get the texture underlying format (RGB, RGBA...)
  82054. */
  82055. readonly textureFormat: number;
  82056. /**
  82057. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  82058. * This will returns an RGBA array buffer containing either in values (0-255) or
  82059. * float values (0-1) depending of the underlying buffer type.
  82060. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  82061. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  82062. * @param buffer defines a user defined buffer to fill with data (can be null)
  82063. * @returns The Array buffer containing the pixels data.
  82064. */
  82065. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  82066. /**
  82067. * Release and destroy the underlying lower level texture aka internalTexture.
  82068. */
  82069. releaseInternalTexture(): void;
  82070. /**
  82071. * Get the polynomial representation of the texture data.
  82072. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  82073. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  82074. */
  82075. sphericalPolynomial: Nullable<SphericalPolynomial>;
  82076. /** @hidden */
  82077. readonly _lodTextureHigh: Nullable<BaseTexture>;
  82078. /** @hidden */
  82079. readonly _lodTextureMid: Nullable<BaseTexture>;
  82080. /** @hidden */
  82081. readonly _lodTextureLow: Nullable<BaseTexture>;
  82082. /**
  82083. * Dispose the texture and release its associated resources.
  82084. */
  82085. dispose(): void;
  82086. /**
  82087. * Serialize the texture into a JSON representation that can be parsed later on.
  82088. * @returns the JSON representation of the texture
  82089. */
  82090. serialize(): any;
  82091. /**
  82092. * Helper function to be called back once a list of texture contains only ready textures.
  82093. * @param textures Define the list of textures to wait for
  82094. * @param callback Define the callback triggered once the entire list will be ready
  82095. */
  82096. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  82097. }
  82098. }
  82099. declare module BABYLON {
  82100. /**
  82101. * Uniform buffer objects.
  82102. *
  82103. * Handles blocks of uniform on the GPU.
  82104. *
  82105. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  82106. *
  82107. * For more information, please refer to :
  82108. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  82109. */
  82110. export class UniformBuffer {
  82111. private _engine;
  82112. private _buffer;
  82113. private _data;
  82114. private _bufferData;
  82115. private _dynamic?;
  82116. private _uniformLocations;
  82117. private _uniformSizes;
  82118. private _uniformLocationPointer;
  82119. private _needSync;
  82120. private _noUBO;
  82121. private _currentEffect;
  82122. private static _MAX_UNIFORM_SIZE;
  82123. private static _tempBuffer;
  82124. /**
  82125. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  82126. * This is dynamic to allow compat with webgl 1 and 2.
  82127. * You will need to pass the name of the uniform as well as the value.
  82128. */
  82129. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  82130. /**
  82131. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  82132. * This is dynamic to allow compat with webgl 1 and 2.
  82133. * You will need to pass the name of the uniform as well as the value.
  82134. */
  82135. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  82136. /**
  82137. * Lambda to Update a single float in a uniform buffer.
  82138. * This is dynamic to allow compat with webgl 1 and 2.
  82139. * You will need to pass the name of the uniform as well as the value.
  82140. */
  82141. updateFloat: (name: string, x: number) => void;
  82142. /**
  82143. * Lambda to Update a vec2 of float in a uniform buffer.
  82144. * This is dynamic to allow compat with webgl 1 and 2.
  82145. * You will need to pass the name of the uniform as well as the value.
  82146. */
  82147. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  82148. /**
  82149. * Lambda to Update a vec3 of float in a uniform buffer.
  82150. * This is dynamic to allow compat with webgl 1 and 2.
  82151. * You will need to pass the name of the uniform as well as the value.
  82152. */
  82153. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  82154. /**
  82155. * Lambda to Update a vec4 of float in a uniform buffer.
  82156. * This is dynamic to allow compat with webgl 1 and 2.
  82157. * You will need to pass the name of the uniform as well as the value.
  82158. */
  82159. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  82160. /**
  82161. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  82162. * This is dynamic to allow compat with webgl 1 and 2.
  82163. * You will need to pass the name of the uniform as well as the value.
  82164. */
  82165. updateMatrix: (name: string, mat: Matrix) => void;
  82166. /**
  82167. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  82168. * This is dynamic to allow compat with webgl 1 and 2.
  82169. * You will need to pass the name of the uniform as well as the value.
  82170. */
  82171. updateVector3: (name: string, vector: Vector3) => void;
  82172. /**
  82173. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  82174. * This is dynamic to allow compat with webgl 1 and 2.
  82175. * You will need to pass the name of the uniform as well as the value.
  82176. */
  82177. updateVector4: (name: string, vector: Vector4) => void;
  82178. /**
  82179. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  82180. * This is dynamic to allow compat with webgl 1 and 2.
  82181. * You will need to pass the name of the uniform as well as the value.
  82182. */
  82183. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  82184. /**
  82185. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  82186. * This is dynamic to allow compat with webgl 1 and 2.
  82187. * You will need to pass the name of the uniform as well as the value.
  82188. */
  82189. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  82190. /**
  82191. * Instantiates a new Uniform buffer objects.
  82192. *
  82193. * Handles blocks of uniform on the GPU.
  82194. *
  82195. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  82196. *
  82197. * For more information, please refer to :
  82198. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  82199. * @param engine Define the engine the buffer is associated with
  82200. * @param data Define the data contained in the buffer
  82201. * @param dynamic Define if the buffer is updatable
  82202. */
  82203. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  82204. /**
  82205. * Indicates if the buffer is using the WebGL2 UBO implementation,
  82206. * or just falling back on setUniformXXX calls.
  82207. */
  82208. readonly useUbo: boolean;
  82209. /**
  82210. * Indicates if the WebGL underlying uniform buffer is in sync
  82211. * with the javascript cache data.
  82212. */
  82213. readonly isSync: boolean;
  82214. /**
  82215. * Indicates if the WebGL underlying uniform buffer is dynamic.
  82216. * Also, a dynamic UniformBuffer will disable cache verification and always
  82217. * update the underlying WebGL uniform buffer to the GPU.
  82218. * @returns if Dynamic, otherwise false
  82219. */
  82220. isDynamic(): boolean;
  82221. /**
  82222. * The data cache on JS side.
  82223. * @returns the underlying data as a float array
  82224. */
  82225. getData(): Float32Array;
  82226. /**
  82227. * The underlying WebGL Uniform buffer.
  82228. * @returns the webgl buffer
  82229. */
  82230. getBuffer(): Nullable<WebGLBuffer>;
  82231. /**
  82232. * std140 layout specifies how to align data within an UBO structure.
  82233. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  82234. * for specs.
  82235. */
  82236. private _fillAlignment;
  82237. /**
  82238. * Adds an uniform in the buffer.
  82239. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  82240. * for the layout to be correct !
  82241. * @param name Name of the uniform, as used in the uniform block in the shader.
  82242. * @param size Data size, or data directly.
  82243. */
  82244. addUniform(name: string, size: number | number[]): void;
  82245. /**
  82246. * Adds a Matrix 4x4 to the uniform buffer.
  82247. * @param name Name of the uniform, as used in the uniform block in the shader.
  82248. * @param mat A 4x4 matrix.
  82249. */
  82250. addMatrix(name: string, mat: Matrix): void;
  82251. /**
  82252. * Adds a vec2 to the uniform buffer.
  82253. * @param name Name of the uniform, as used in the uniform block in the shader.
  82254. * @param x Define the x component value of the vec2
  82255. * @param y Define the y component value of the vec2
  82256. */
  82257. addFloat2(name: string, x: number, y: number): void;
  82258. /**
  82259. * Adds a vec3 to the uniform buffer.
  82260. * @param name Name of the uniform, as used in the uniform block in the shader.
  82261. * @param x Define the x component value of the vec3
  82262. * @param y Define the y component value of the vec3
  82263. * @param z Define the z component value of the vec3
  82264. */
  82265. addFloat3(name: string, x: number, y: number, z: number): void;
  82266. /**
  82267. * Adds a vec3 to the uniform buffer.
  82268. * @param name Name of the uniform, as used in the uniform block in the shader.
  82269. * @param color Define the vec3 from a Color
  82270. */
  82271. addColor3(name: string, color: Color3): void;
  82272. /**
  82273. * Adds a vec4 to the uniform buffer.
  82274. * @param name Name of the uniform, as used in the uniform block in the shader.
  82275. * @param color Define the rgb components from a Color
  82276. * @param alpha Define the a component of the vec4
  82277. */
  82278. addColor4(name: string, color: Color3, alpha: number): void;
  82279. /**
  82280. * Adds a vec3 to the uniform buffer.
  82281. * @param name Name of the uniform, as used in the uniform block in the shader.
  82282. * @param vector Define the vec3 components from a Vector
  82283. */
  82284. addVector3(name: string, vector: Vector3): void;
  82285. /**
  82286. * Adds a Matrix 3x3 to the uniform buffer.
  82287. * @param name Name of the uniform, as used in the uniform block in the shader.
  82288. */
  82289. addMatrix3x3(name: string): void;
  82290. /**
  82291. * Adds a Matrix 2x2 to the uniform buffer.
  82292. * @param name Name of the uniform, as used in the uniform block in the shader.
  82293. */
  82294. addMatrix2x2(name: string): void;
  82295. /**
  82296. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  82297. */
  82298. create(): void;
  82299. /** @hidden */
  82300. _rebuild(): void;
  82301. /**
  82302. * Updates the WebGL Uniform Buffer on the GPU.
  82303. * If the `dynamic` flag is set to true, no cache comparison is done.
  82304. * Otherwise, the buffer will be updated only if the cache differs.
  82305. */
  82306. update(): void;
  82307. /**
  82308. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  82309. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  82310. * @param data Define the flattened data
  82311. * @param size Define the size of the data.
  82312. */
  82313. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  82314. private _updateMatrix3x3ForUniform;
  82315. private _updateMatrix3x3ForEffect;
  82316. private _updateMatrix2x2ForEffect;
  82317. private _updateMatrix2x2ForUniform;
  82318. private _updateFloatForEffect;
  82319. private _updateFloatForUniform;
  82320. private _updateFloat2ForEffect;
  82321. private _updateFloat2ForUniform;
  82322. private _updateFloat3ForEffect;
  82323. private _updateFloat3ForUniform;
  82324. private _updateFloat4ForEffect;
  82325. private _updateFloat4ForUniform;
  82326. private _updateMatrixForEffect;
  82327. private _updateMatrixForUniform;
  82328. private _updateVector3ForEffect;
  82329. private _updateVector3ForUniform;
  82330. private _updateVector4ForEffect;
  82331. private _updateVector4ForUniform;
  82332. private _updateColor3ForEffect;
  82333. private _updateColor3ForUniform;
  82334. private _updateColor4ForEffect;
  82335. private _updateColor4ForUniform;
  82336. /**
  82337. * Sets a sampler uniform on the effect.
  82338. * @param name Define the name of the sampler.
  82339. * @param texture Define the texture to set in the sampler
  82340. */
  82341. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  82342. /**
  82343. * Directly updates the value of the uniform in the cache AND on the GPU.
  82344. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  82345. * @param data Define the flattened data
  82346. */
  82347. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  82348. /**
  82349. * Binds this uniform buffer to an effect.
  82350. * @param effect Define the effect to bind the buffer to
  82351. * @param name Name of the uniform block in the shader.
  82352. */
  82353. bindToEffect(effect: Effect, name: string): void;
  82354. /**
  82355. * Disposes the uniform buffer.
  82356. */
  82357. dispose(): void;
  82358. }
  82359. }
  82360. declare module BABYLON {
  82361. /**
  82362. * This represents the required contract to create a new type of texture loader.
  82363. */
  82364. export interface IInternalTextureLoader {
  82365. /**
  82366. * Defines wether the loader supports cascade loading the different faces.
  82367. */
  82368. supportCascades: boolean;
  82369. /**
  82370. * This returns if the loader support the current file information.
  82371. * @param extension defines the file extension of the file being loaded
  82372. * @param textureFormatInUse defines the current compressed format in use iun the engine
  82373. * @param fallback defines the fallback internal texture if any
  82374. * @param isBase64 defines whether the texture is encoded as a base64
  82375. * @param isBuffer defines whether the texture data are stored as a buffer
  82376. * @returns true if the loader can load the specified file
  82377. */
  82378. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  82379. /**
  82380. * Transform the url before loading if required.
  82381. * @param rootUrl the url of the texture
  82382. * @param textureFormatInUse defines the current compressed format in use iun the engine
  82383. * @returns the transformed texture
  82384. */
  82385. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  82386. /**
  82387. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  82388. * @param rootUrl the url of the texture
  82389. * @param textureFormatInUse defines the current compressed format in use iun the engine
  82390. * @returns the fallback texture
  82391. */
  82392. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  82393. /**
  82394. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  82395. * @param data contains the texture data
  82396. * @param texture defines the BabylonJS internal texture
  82397. * @param createPolynomials will be true if polynomials have been requested
  82398. * @param onLoad defines the callback to trigger once the texture is ready
  82399. * @param onError defines the callback to trigger in case of error
  82400. */
  82401. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  82402. /**
  82403. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  82404. * @param data contains the texture data
  82405. * @param texture defines the BabylonJS internal texture
  82406. * @param callback defines the method to call once ready to upload
  82407. */
  82408. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  82409. }
  82410. }
  82411. declare module BABYLON {
  82412. /**
  82413. * Creation options of the multi render target texture.
  82414. */
  82415. export interface IMultiRenderTargetOptions {
  82416. /**
  82417. * Define if the texture needs to create mip maps after render.
  82418. */
  82419. generateMipMaps?: boolean;
  82420. /**
  82421. * Define the types of all the draw buffers we want to create
  82422. */
  82423. types?: number[];
  82424. /**
  82425. * Define the sampling modes of all the draw buffers we want to create
  82426. */
  82427. samplingModes?: number[];
  82428. /**
  82429. * Define if a depth buffer is required
  82430. */
  82431. generateDepthBuffer?: boolean;
  82432. /**
  82433. * Define if a stencil buffer is required
  82434. */
  82435. generateStencilBuffer?: boolean;
  82436. /**
  82437. * Define if a depth texture is required instead of a depth buffer
  82438. */
  82439. generateDepthTexture?: boolean;
  82440. /**
  82441. * Define the number of desired draw buffers
  82442. */
  82443. textureCount?: number;
  82444. /**
  82445. * Define if aspect ratio should be adapted to the texture or stay the scene one
  82446. */
  82447. doNotChangeAspectRatio?: boolean;
  82448. /**
  82449. * Define the default type of the buffers we are creating
  82450. */
  82451. defaultType?: number;
  82452. }
  82453. /**
  82454. * A multi render target, like a render target provides the ability to render to a texture.
  82455. * Unlike the render target, it can render to several draw buffers in one draw.
  82456. * This is specially interesting in deferred rendering or for any effects requiring more than
  82457. * just one color from a single pass.
  82458. */
  82459. export class MultiRenderTarget extends RenderTargetTexture {
  82460. private _internalTextures;
  82461. private _textures;
  82462. private _multiRenderTargetOptions;
  82463. /**
  82464. * Get if draw buffers are currently supported by the used hardware and browser.
  82465. */
  82466. readonly isSupported: boolean;
  82467. /**
  82468. * Get the list of textures generated by the multi render target.
  82469. */
  82470. readonly textures: Texture[];
  82471. /**
  82472. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  82473. */
  82474. readonly depthTexture: Texture;
  82475. /**
  82476. * Set the wrapping mode on U of all the textures we are rendering to.
  82477. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  82478. */
  82479. wrapU: number;
  82480. /**
  82481. * Set the wrapping mode on V of all the textures we are rendering to.
  82482. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  82483. */
  82484. wrapV: number;
  82485. /**
  82486. * Instantiate a new multi render target texture.
  82487. * A multi render target, like a render target provides the ability to render to a texture.
  82488. * Unlike the render target, it can render to several draw buffers in one draw.
  82489. * This is specially interesting in deferred rendering or for any effects requiring more than
  82490. * just one color from a single pass.
  82491. * @param name Define the name of the texture
  82492. * @param size Define the size of the buffers to render to
  82493. * @param count Define the number of target we are rendering into
  82494. * @param scene Define the scene the texture belongs to
  82495. * @param options Define the options used to create the multi render target
  82496. */
  82497. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  82498. /** @hidden */
  82499. _rebuild(): void;
  82500. private _createInternalTextures;
  82501. private _createTextures;
  82502. /**
  82503. * Define the number of samples used if MSAA is enabled.
  82504. */
  82505. samples: number;
  82506. /**
  82507. * Resize all the textures in the multi render target.
  82508. * Be carrefull as it will recreate all the data in the new texture.
  82509. * @param size Define the new size
  82510. */
  82511. resize(size: any): void;
  82512. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  82513. /**
  82514. * Dispose the render targets and their associated resources
  82515. */
  82516. dispose(): void;
  82517. /**
  82518. * Release all the underlying texture used as draw buffers.
  82519. */
  82520. releaseInternalTextures(): void;
  82521. }
  82522. }
  82523. declare module BABYLON {
  82524. /**
  82525. * Class used to work with sound analyzer using fast fourier transform (FFT)
  82526. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  82527. */
  82528. export class Analyser {
  82529. /**
  82530. * Gets or sets the smoothing
  82531. * @ignorenaming
  82532. */
  82533. SMOOTHING: number;
  82534. /**
  82535. * Gets or sets the FFT table size
  82536. * @ignorenaming
  82537. */
  82538. FFT_SIZE: number;
  82539. /**
  82540. * Gets or sets the bar graph amplitude
  82541. * @ignorenaming
  82542. */
  82543. BARGRAPHAMPLITUDE: number;
  82544. /**
  82545. * Gets or sets the position of the debug canvas
  82546. * @ignorenaming
  82547. */
  82548. DEBUGCANVASPOS: {
  82549. x: number;
  82550. y: number;
  82551. };
  82552. /**
  82553. * Gets or sets the debug canvas size
  82554. * @ignorenaming
  82555. */
  82556. DEBUGCANVASSIZE: {
  82557. width: number;
  82558. height: number;
  82559. };
  82560. private _byteFreqs;
  82561. private _byteTime;
  82562. private _floatFreqs;
  82563. private _webAudioAnalyser;
  82564. private _debugCanvas;
  82565. private _debugCanvasContext;
  82566. private _scene;
  82567. private _registerFunc;
  82568. private _audioEngine;
  82569. /**
  82570. * Creates a new analyser
  82571. * @param scene defines hosting scene
  82572. */
  82573. constructor(scene: Scene);
  82574. /**
  82575. * Get the number of data values you will have to play with for the visualization
  82576. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  82577. * @returns a number
  82578. */
  82579. getFrequencyBinCount(): number;
  82580. /**
  82581. * Gets the current frequency data as a byte array
  82582. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  82583. * @returns a Uint8Array
  82584. */
  82585. getByteFrequencyData(): Uint8Array;
  82586. /**
  82587. * Gets the current waveform as a byte array
  82588. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  82589. * @returns a Uint8Array
  82590. */
  82591. getByteTimeDomainData(): Uint8Array;
  82592. /**
  82593. * Gets the current frequency data as a float array
  82594. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  82595. * @returns a Float32Array
  82596. */
  82597. getFloatFrequencyData(): Float32Array;
  82598. /**
  82599. * Renders the debug canvas
  82600. */
  82601. drawDebugCanvas(): void;
  82602. /**
  82603. * Stops rendering the debug canvas and removes it
  82604. */
  82605. stopDebugCanvas(): void;
  82606. /**
  82607. * Connects two audio nodes
  82608. * @param inputAudioNode defines first node to connect
  82609. * @param outputAudioNode defines second node to connect
  82610. */
  82611. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  82612. /**
  82613. * Releases all associated resources
  82614. */
  82615. dispose(): void;
  82616. }
  82617. }
  82618. declare module BABYLON {
  82619. /**
  82620. * This represents an audio engine and it is responsible
  82621. * to play, synchronize and analyse sounds throughout the application.
  82622. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  82623. */
  82624. export interface IAudioEngine extends IDisposable {
  82625. /**
  82626. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  82627. */
  82628. readonly canUseWebAudio: boolean;
  82629. /**
  82630. * Gets the current AudioContext if available.
  82631. */
  82632. readonly audioContext: Nullable<AudioContext>;
  82633. /**
  82634. * The master gain node defines the global audio volume of your audio engine.
  82635. */
  82636. readonly masterGain: GainNode;
  82637. /**
  82638. * Gets whether or not mp3 are supported by your browser.
  82639. */
  82640. readonly isMP3supported: boolean;
  82641. /**
  82642. * Gets whether or not ogg are supported by your browser.
  82643. */
  82644. readonly isOGGsupported: boolean;
  82645. /**
  82646. * Defines if Babylon should emit a warning if WebAudio is not supported.
  82647. * @ignoreNaming
  82648. */
  82649. WarnedWebAudioUnsupported: boolean;
  82650. /**
  82651. * Defines if the audio engine relies on a custom unlocked button.
  82652. * In this case, the embedded button will not be displayed.
  82653. */
  82654. useCustomUnlockedButton: boolean;
  82655. /**
  82656. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  82657. */
  82658. readonly unlocked: boolean;
  82659. /**
  82660. * Event raised when audio has been unlocked on the browser.
  82661. */
  82662. onAudioUnlockedObservable: Observable<AudioEngine>;
  82663. /**
  82664. * Event raised when audio has been locked on the browser.
  82665. */
  82666. onAudioLockedObservable: Observable<AudioEngine>;
  82667. /**
  82668. * Flags the audio engine in Locked state.
  82669. * This happens due to new browser policies preventing audio to autoplay.
  82670. */
  82671. lock(): void;
  82672. /**
  82673. * Unlocks the audio engine once a user action has been done on the dom.
  82674. * This is helpful to resume play once browser policies have been satisfied.
  82675. */
  82676. unlock(): void;
  82677. }
  82678. /**
  82679. * This represents the default audio engine used in babylon.
  82680. * It is responsible to play, synchronize and analyse sounds throughout the application.
  82681. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  82682. */
  82683. export class AudioEngine implements IAudioEngine {
  82684. private _audioContext;
  82685. private _audioContextInitialized;
  82686. private _muteButton;
  82687. private _hostElement;
  82688. /**
  82689. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  82690. */
  82691. canUseWebAudio: boolean;
  82692. /**
  82693. * The master gain node defines the global audio volume of your audio engine.
  82694. */
  82695. masterGain: GainNode;
  82696. /**
  82697. * Defines if Babylon should emit a warning if WebAudio is not supported.
  82698. * @ignoreNaming
  82699. */
  82700. WarnedWebAudioUnsupported: boolean;
  82701. /**
  82702. * Gets whether or not mp3 are supported by your browser.
  82703. */
  82704. isMP3supported: boolean;
  82705. /**
  82706. * Gets whether or not ogg are supported by your browser.
  82707. */
  82708. isOGGsupported: boolean;
  82709. /**
  82710. * Gets whether audio has been unlocked on the device.
  82711. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  82712. * a user interaction has happened.
  82713. */
  82714. unlocked: boolean;
  82715. /**
  82716. * Defines if the audio engine relies on a custom unlocked button.
  82717. * In this case, the embedded button will not be displayed.
  82718. */
  82719. useCustomUnlockedButton: boolean;
  82720. /**
  82721. * Event raised when audio has been unlocked on the browser.
  82722. */
  82723. onAudioUnlockedObservable: Observable<AudioEngine>;
  82724. /**
  82725. * Event raised when audio has been locked on the browser.
  82726. */
  82727. onAudioLockedObservable: Observable<AudioEngine>;
  82728. /**
  82729. * Gets the current AudioContext if available.
  82730. */
  82731. readonly audioContext: Nullable<AudioContext>;
  82732. private _connectedAnalyser;
  82733. /**
  82734. * Instantiates a new audio engine.
  82735. *
  82736. * There should be only one per page as some browsers restrict the number
  82737. * of audio contexts you can create.
  82738. * @param hostElement defines the host element where to display the mute icon if necessary
  82739. */
  82740. constructor(hostElement?: Nullable<HTMLElement>);
  82741. /**
  82742. * Flags the audio engine in Locked state.
  82743. * This happens due to new browser policies preventing audio to autoplay.
  82744. */
  82745. lock(): void;
  82746. /**
  82747. * Unlocks the audio engine once a user action has been done on the dom.
  82748. * This is helpful to resume play once browser policies have been satisfied.
  82749. */
  82750. unlock(): void;
  82751. private _resumeAudioContext;
  82752. private _initializeAudioContext;
  82753. private _tryToRun;
  82754. private _triggerRunningState;
  82755. private _triggerSuspendedState;
  82756. private _displayMuteButton;
  82757. private _moveButtonToTopLeft;
  82758. private _onResize;
  82759. private _hideMuteButton;
  82760. /**
  82761. * Destroy and release the resources associated with the audio ccontext.
  82762. */
  82763. dispose(): void;
  82764. /**
  82765. * Gets the global volume sets on the master gain.
  82766. * @returns the global volume if set or -1 otherwise
  82767. */
  82768. getGlobalVolume(): number;
  82769. /**
  82770. * Sets the global volume of your experience (sets on the master gain).
  82771. * @param newVolume Defines the new global volume of the application
  82772. */
  82773. setGlobalVolume(newVolume: number): void;
  82774. /**
  82775. * Connect the audio engine to an audio analyser allowing some amazing
  82776. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  82777. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  82778. * @param analyser The analyser to connect to the engine
  82779. */
  82780. connectToAnalyser(analyser: Analyser): void;
  82781. }
  82782. }
  82783. declare module BABYLON {
  82784. /**
  82785. * Interface used to present a loading screen while loading a scene
  82786. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  82787. */
  82788. export interface ILoadingScreen {
  82789. /**
  82790. * Function called to display the loading screen
  82791. */
  82792. displayLoadingUI: () => void;
  82793. /**
  82794. * Function called to hide the loading screen
  82795. */
  82796. hideLoadingUI: () => void;
  82797. /**
  82798. * Gets or sets the color to use for the background
  82799. */
  82800. loadingUIBackgroundColor: string;
  82801. /**
  82802. * Gets or sets the text to display while loading
  82803. */
  82804. loadingUIText: string;
  82805. }
  82806. /**
  82807. * Class used for the default loading screen
  82808. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  82809. */
  82810. export class DefaultLoadingScreen implements ILoadingScreen {
  82811. private _renderingCanvas;
  82812. private _loadingText;
  82813. private _loadingDivBackgroundColor;
  82814. private _loadingDiv;
  82815. private _loadingTextDiv;
  82816. /**
  82817. * Creates a new default loading screen
  82818. * @param _renderingCanvas defines the canvas used to render the scene
  82819. * @param _loadingText defines the default text to display
  82820. * @param _loadingDivBackgroundColor defines the default background color
  82821. */
  82822. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  82823. /**
  82824. * Function called to display the loading screen
  82825. */
  82826. displayLoadingUI(): void;
  82827. /**
  82828. * Function called to hide the loading screen
  82829. */
  82830. hideLoadingUI(): void;
  82831. /**
  82832. * Gets or sets the text to display while loading
  82833. */
  82834. loadingUIText: string;
  82835. /**
  82836. * Gets or sets the color to use for the background
  82837. */
  82838. loadingUIBackgroundColor: string;
  82839. private _resizeLoadingUI;
  82840. }
  82841. }
  82842. declare module BABYLON {
  82843. /**
  82844. * Settings for finer control over video usage
  82845. */
  82846. export interface VideoTextureSettings {
  82847. /**
  82848. * Applies `autoplay` to video, if specified
  82849. */
  82850. autoPlay?: boolean;
  82851. /**
  82852. * Applies `loop` to video, if specified
  82853. */
  82854. loop?: boolean;
  82855. /**
  82856. * Automatically updates internal texture from video at every frame in the render loop
  82857. */
  82858. autoUpdateTexture: boolean;
  82859. /**
  82860. * Image src displayed during the video loading or until the user interacts with the video.
  82861. */
  82862. poster?: string;
  82863. }
  82864. /**
  82865. * If you want to display a video in your scene, this is the special texture for that.
  82866. * This special texture works similar to other textures, with the exception of a few parameters.
  82867. * @see https://doc.babylonjs.com/how_to/video_texture
  82868. */
  82869. export class VideoTexture extends Texture {
  82870. /**
  82871. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  82872. */
  82873. readonly autoUpdateTexture: boolean;
  82874. /**
  82875. * The video instance used by the texture internally
  82876. */
  82877. readonly video: HTMLVideoElement;
  82878. private _onUserActionRequestedObservable;
  82879. /**
  82880. * Event triggerd when a dom action is required by the user to play the video.
  82881. * This happens due to recent changes in browser policies preventing video to auto start.
  82882. */
  82883. readonly onUserActionRequestedObservable: Observable<Texture>;
  82884. private _generateMipMaps;
  82885. private _engine;
  82886. private _stillImageCaptured;
  82887. private _displayingPosterTexture;
  82888. private _settings;
  82889. private _createInternalTextureOnEvent;
  82890. /**
  82891. * Creates a video texture.
  82892. * If you want to display a video in your scene, this is the special texture for that.
  82893. * This special texture works similar to other textures, with the exception of a few parameters.
  82894. * @see https://doc.babylonjs.com/how_to/video_texture
  82895. * @param name optional name, will detect from video source, if not defined
  82896. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  82897. * @param scene is obviously the current scene.
  82898. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  82899. * @param invertY is false by default but can be used to invert video on Y axis
  82900. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  82901. * @param settings allows finer control over video usage
  82902. */
  82903. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  82904. private _getName;
  82905. private _getVideo;
  82906. private _createInternalTexture;
  82907. private reset;
  82908. /**
  82909. * @hidden Internal method to initiate `update`.
  82910. */
  82911. _rebuild(): void;
  82912. /**
  82913. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  82914. */
  82915. update(): void;
  82916. /**
  82917. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  82918. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  82919. */
  82920. updateTexture(isVisible: boolean): void;
  82921. protected _updateInternalTexture: () => void;
  82922. /**
  82923. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  82924. * @param url New url.
  82925. */
  82926. updateURL(url: string): void;
  82927. /**
  82928. * Dispose the texture and release its associated resources.
  82929. */
  82930. dispose(): void;
  82931. /**
  82932. * Creates a video texture straight from a stream.
  82933. * @param scene Define the scene the texture should be created in
  82934. * @param stream Define the stream the texture should be created from
  82935. * @returns The created video texture as a promise
  82936. */
  82937. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  82938. /**
  82939. * Creates a video texture straight from your WebCam video feed.
  82940. * @param scene Define the scene the texture should be created in
  82941. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  82942. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  82943. * @returns The created video texture as a promise
  82944. */
  82945. static CreateFromWebCamAsync(scene: Scene, constraints: {
  82946. minWidth: number;
  82947. maxWidth: number;
  82948. minHeight: number;
  82949. maxHeight: number;
  82950. deviceId: string;
  82951. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  82952. /**
  82953. * Creates a video texture straight from your WebCam video feed.
  82954. * @param scene Define the scene the texture should be created in
  82955. * @param onReady Define a callback to triggered once the texture will be ready
  82956. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  82957. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  82958. */
  82959. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  82960. minWidth: number;
  82961. maxWidth: number;
  82962. minHeight: number;
  82963. maxHeight: number;
  82964. deviceId: string;
  82965. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  82966. }
  82967. }
  82968. declare module BABYLON {
  82969. /**
  82970. * Interface for attribute information associated with buffer instanciation
  82971. */
  82972. export class InstancingAttributeInfo {
  82973. /**
  82974. * Index/offset of the attribute in the vertex shader
  82975. */
  82976. index: number;
  82977. /**
  82978. * size of the attribute, 1, 2, 3 or 4
  82979. */
  82980. attributeSize: number;
  82981. /**
  82982. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  82983. * default is FLOAT
  82984. */
  82985. attribyteType: number;
  82986. /**
  82987. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  82988. */
  82989. normalized: boolean;
  82990. /**
  82991. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  82992. */
  82993. offset: number;
  82994. /**
  82995. * Name of the GLSL attribute, for debugging purpose only
  82996. */
  82997. attributeName: string;
  82998. }
  82999. /**
  83000. * Define options used to create a depth texture
  83001. */
  83002. export class DepthTextureCreationOptions {
  83003. /** Specifies whether or not a stencil should be allocated in the texture */
  83004. generateStencil?: boolean;
  83005. /** Specifies whether or not bilinear filtering is enable on the texture */
  83006. bilinearFiltering?: boolean;
  83007. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  83008. comparisonFunction?: number;
  83009. /** Specifies if the created texture is a cube texture */
  83010. isCube?: boolean;
  83011. }
  83012. /**
  83013. * Class used to describe the capabilities of the engine relatively to the current browser
  83014. */
  83015. export class EngineCapabilities {
  83016. /** Maximum textures units per fragment shader */
  83017. maxTexturesImageUnits: number;
  83018. /** Maximum texture units per vertex shader */
  83019. maxVertexTextureImageUnits: number;
  83020. /** Maximum textures units in the entire pipeline */
  83021. maxCombinedTexturesImageUnits: number;
  83022. /** Maximum texture size */
  83023. maxTextureSize: number;
  83024. /** Maximum cube texture size */
  83025. maxCubemapTextureSize: number;
  83026. /** Maximum render texture size */
  83027. maxRenderTextureSize: number;
  83028. /** Maximum number of vertex attributes */
  83029. maxVertexAttribs: number;
  83030. /** Maximum number of varyings */
  83031. maxVaryingVectors: number;
  83032. /** Maximum number of uniforms per vertex shader */
  83033. maxVertexUniformVectors: number;
  83034. /** Maximum number of uniforms per fragment shader */
  83035. maxFragmentUniformVectors: number;
  83036. /** Defines if standard derivates (dx/dy) are supported */
  83037. standardDerivatives: boolean;
  83038. /** Defines if s3tc texture compression is supported */
  83039. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  83040. /** Defines if pvrtc texture compression is supported */
  83041. pvrtc: any;
  83042. /** Defines if etc1 texture compression is supported */
  83043. etc1: any;
  83044. /** Defines if etc2 texture compression is supported */
  83045. etc2: any;
  83046. /** Defines if astc texture compression is supported */
  83047. astc: any;
  83048. /** Defines if float textures are supported */
  83049. textureFloat: boolean;
  83050. /** Defines if vertex array objects are supported */
  83051. vertexArrayObject: boolean;
  83052. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  83053. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  83054. /** Gets the maximum level of anisotropy supported */
  83055. maxAnisotropy: number;
  83056. /** Defines if instancing is supported */
  83057. instancedArrays: boolean;
  83058. /** Defines if 32 bits indices are supported */
  83059. uintIndices: boolean;
  83060. /** Defines if high precision shaders are supported */
  83061. highPrecisionShaderSupported: boolean;
  83062. /** Defines if depth reading in the fragment shader is supported */
  83063. fragmentDepthSupported: boolean;
  83064. /** Defines if float texture linear filtering is supported*/
  83065. textureFloatLinearFiltering: boolean;
  83066. /** Defines if rendering to float textures is supported */
  83067. textureFloatRender: boolean;
  83068. /** Defines if half float textures are supported*/
  83069. textureHalfFloat: boolean;
  83070. /** Defines if half float texture linear filtering is supported*/
  83071. textureHalfFloatLinearFiltering: boolean;
  83072. /** Defines if rendering to half float textures is supported */
  83073. textureHalfFloatRender: boolean;
  83074. /** Defines if textureLOD shader command is supported */
  83075. textureLOD: boolean;
  83076. /** Defines if draw buffers extension is supported */
  83077. drawBuffersExtension: boolean;
  83078. /** Defines if depth textures are supported */
  83079. depthTextureExtension: boolean;
  83080. /** Defines if float color buffer are supported */
  83081. colorBufferFloat: boolean;
  83082. /** Gets disjoint timer query extension (null if not supported) */
  83083. timerQuery: EXT_disjoint_timer_query;
  83084. /** Defines if timestamp can be used with timer query */
  83085. canUseTimestampForTimerQuery: boolean;
  83086. /** Function used to let the system compiles shaders in background */
  83087. parallelShaderCompile: {
  83088. MAX_SHADER_COMPILER_THREADS_KHR: number;
  83089. maxShaderCompilerThreadsKHR: (thread: number) => void;
  83090. COMPLETION_STATUS_KHR: number;
  83091. };
  83092. }
  83093. /** Interface defining initialization parameters for Engine class */
  83094. export interface EngineOptions extends WebGLContextAttributes {
  83095. /**
  83096. * Defines if the engine should no exceed a specified device ratio
  83097. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  83098. */
  83099. limitDeviceRatio?: number;
  83100. /**
  83101. * Defines if webvr should be enabled automatically
  83102. * @see http://doc.babylonjs.com/how_to/webvr_camera
  83103. */
  83104. autoEnableWebVR?: boolean;
  83105. /**
  83106. * Defines if webgl2 should be turned off even if supported
  83107. * @see http://doc.babylonjs.com/features/webgl2
  83108. */
  83109. disableWebGL2Support?: boolean;
  83110. /**
  83111. * Defines if webaudio should be initialized as well
  83112. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83113. */
  83114. audioEngine?: boolean;
  83115. /**
  83116. * Defines if animations should run using a deterministic lock step
  83117. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  83118. */
  83119. deterministicLockstep?: boolean;
  83120. /** Defines the maximum steps to use with deterministic lock step mode */
  83121. lockstepMaxSteps?: number;
  83122. /**
  83123. * Defines that engine should ignore context lost events
  83124. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  83125. */
  83126. doNotHandleContextLost?: boolean;
  83127. /**
  83128. * Defines that engine should ignore modifying touch action attribute and style
  83129. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  83130. */
  83131. doNotHandleTouchAction?: boolean;
  83132. }
  83133. /**
  83134. * Defines the interface used by display changed events
  83135. */
  83136. export interface IDisplayChangedEventArgs {
  83137. /** Gets the vrDisplay object (if any) */
  83138. vrDisplay: Nullable<any>;
  83139. /** Gets a boolean indicating if webVR is supported */
  83140. vrSupported: boolean;
  83141. }
  83142. /**
  83143. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  83144. */
  83145. export class Engine {
  83146. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  83147. static ExceptionList: ({
  83148. key: string;
  83149. capture: string;
  83150. captureConstraint: number;
  83151. targets: string[];
  83152. } | {
  83153. key: string;
  83154. capture: null;
  83155. captureConstraint: null;
  83156. targets: string[];
  83157. })[];
  83158. /** Gets the list of created engines */
  83159. static readonly Instances: Engine[];
  83160. /**
  83161. * Gets the latest created engine
  83162. */
  83163. static readonly LastCreatedEngine: Nullable<Engine>;
  83164. /**
  83165. * Gets the latest created scene
  83166. */
  83167. static readonly LastCreatedScene: Nullable<Scene>;
  83168. /**
  83169. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  83170. * @param flag defines which part of the materials must be marked as dirty
  83171. * @param predicate defines a predicate used to filter which materials should be affected
  83172. */
  83173. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  83174. /**
  83175. * Hidden
  83176. */
  83177. static _TextureLoaders: IInternalTextureLoader[];
  83178. /** Defines that alpha blending is disabled */
  83179. static readonly ALPHA_DISABLE: number;
  83180. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  83181. static readonly ALPHA_ADD: number;
  83182. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  83183. static readonly ALPHA_COMBINE: number;
  83184. /** Defines that alpha blending to DEST - SRC * DEST */
  83185. static readonly ALPHA_SUBTRACT: number;
  83186. /** Defines that alpha blending to SRC * DEST */
  83187. static readonly ALPHA_MULTIPLY: number;
  83188. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  83189. static readonly ALPHA_MAXIMIZED: number;
  83190. /** Defines that alpha blending to SRC + DEST */
  83191. static readonly ALPHA_ONEONE: number;
  83192. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  83193. static readonly ALPHA_PREMULTIPLIED: number;
  83194. /**
  83195. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  83196. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  83197. */
  83198. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  83199. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  83200. static readonly ALPHA_INTERPOLATE: number;
  83201. /**
  83202. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  83203. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  83204. */
  83205. static readonly ALPHA_SCREENMODE: number;
  83206. /** Defines that the ressource is not delayed*/
  83207. static readonly DELAYLOADSTATE_NONE: number;
  83208. /** Defines that the ressource was successfully delay loaded */
  83209. static readonly DELAYLOADSTATE_LOADED: number;
  83210. /** Defines that the ressource is currently delay loading */
  83211. static readonly DELAYLOADSTATE_LOADING: number;
  83212. /** Defines that the ressource is delayed and has not started loading */
  83213. static readonly DELAYLOADSTATE_NOTLOADED: number;
  83214. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  83215. static readonly NEVER: number;
  83216. /** 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 */
  83217. static readonly ALWAYS: number;
  83218. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  83219. static readonly LESS: number;
  83220. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  83221. static readonly EQUAL: number;
  83222. /** 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 */
  83223. static readonly LEQUAL: number;
  83224. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  83225. static readonly GREATER: number;
  83226. /** 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 */
  83227. static readonly GEQUAL: number;
  83228. /** 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 */
  83229. static readonly NOTEQUAL: number;
  83230. /** Passed to stencilOperation to specify that stencil value must be kept */
  83231. static readonly KEEP: number;
  83232. /** Passed to stencilOperation to specify that stencil value must be replaced */
  83233. static readonly REPLACE: number;
  83234. /** Passed to stencilOperation to specify that stencil value must be incremented */
  83235. static readonly INCR: number;
  83236. /** Passed to stencilOperation to specify that stencil value must be decremented */
  83237. static readonly DECR: number;
  83238. /** Passed to stencilOperation to specify that stencil value must be inverted */
  83239. static readonly INVERT: number;
  83240. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  83241. static readonly INCR_WRAP: number;
  83242. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  83243. static readonly DECR_WRAP: number;
  83244. /** Texture is not repeating outside of 0..1 UVs */
  83245. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  83246. /** Texture is repeating outside of 0..1 UVs */
  83247. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  83248. /** Texture is repeating and mirrored */
  83249. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  83250. /** ALPHA */
  83251. static readonly TEXTUREFORMAT_ALPHA: number;
  83252. /** LUMINANCE */
  83253. static readonly TEXTUREFORMAT_LUMINANCE: number;
  83254. /** LUMINANCE_ALPHA */
  83255. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  83256. /** RGB */
  83257. static readonly TEXTUREFORMAT_RGB: number;
  83258. /** RGBA */
  83259. static readonly TEXTUREFORMAT_RGBA: number;
  83260. /** RED */
  83261. static readonly TEXTUREFORMAT_RED: number;
  83262. /** RED (2nd reference) */
  83263. static readonly TEXTUREFORMAT_R: number;
  83264. /** RG */
  83265. static readonly TEXTUREFORMAT_RG: number;
  83266. /** RED_INTEGER */
  83267. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  83268. /** RED_INTEGER (2nd reference) */
  83269. static readonly TEXTUREFORMAT_R_INTEGER: number;
  83270. /** RG_INTEGER */
  83271. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  83272. /** RGB_INTEGER */
  83273. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  83274. /** RGBA_INTEGER */
  83275. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  83276. /** UNSIGNED_BYTE */
  83277. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  83278. /** UNSIGNED_BYTE (2nd reference) */
  83279. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  83280. /** FLOAT */
  83281. static readonly TEXTURETYPE_FLOAT: number;
  83282. /** HALF_FLOAT */
  83283. static readonly TEXTURETYPE_HALF_FLOAT: number;
  83284. /** BYTE */
  83285. static readonly TEXTURETYPE_BYTE: number;
  83286. /** SHORT */
  83287. static readonly TEXTURETYPE_SHORT: number;
  83288. /** UNSIGNED_SHORT */
  83289. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  83290. /** INT */
  83291. static readonly TEXTURETYPE_INT: number;
  83292. /** UNSIGNED_INT */
  83293. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  83294. /** UNSIGNED_SHORT_4_4_4_4 */
  83295. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  83296. /** UNSIGNED_SHORT_5_5_5_1 */
  83297. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  83298. /** UNSIGNED_SHORT_5_6_5 */
  83299. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  83300. /** UNSIGNED_INT_2_10_10_10_REV */
  83301. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  83302. /** UNSIGNED_INT_24_8 */
  83303. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  83304. /** UNSIGNED_INT_10F_11F_11F_REV */
  83305. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  83306. /** UNSIGNED_INT_5_9_9_9_REV */
  83307. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  83308. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  83309. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  83310. /** nearest is mag = nearest and min = nearest and mip = linear */
  83311. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  83312. /** Bilinear is mag = linear and min = linear and mip = nearest */
  83313. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  83314. /** Trilinear is mag = linear and min = linear and mip = linear */
  83315. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  83316. /** nearest is mag = nearest and min = nearest and mip = linear */
  83317. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  83318. /** Bilinear is mag = linear and min = linear and mip = nearest */
  83319. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  83320. /** Trilinear is mag = linear and min = linear and mip = linear */
  83321. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  83322. /** mag = nearest and min = nearest and mip = nearest */
  83323. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  83324. /** mag = nearest and min = linear and mip = nearest */
  83325. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  83326. /** mag = nearest and min = linear and mip = linear */
  83327. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  83328. /** mag = nearest and min = linear and mip = none */
  83329. static readonly TEXTURE_NEAREST_LINEAR: number;
  83330. /** mag = nearest and min = nearest and mip = none */
  83331. static readonly TEXTURE_NEAREST_NEAREST: number;
  83332. /** mag = linear and min = nearest and mip = nearest */
  83333. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  83334. /** mag = linear and min = nearest and mip = linear */
  83335. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  83336. /** mag = linear and min = linear and mip = none */
  83337. static readonly TEXTURE_LINEAR_LINEAR: number;
  83338. /** mag = linear and min = nearest and mip = none */
  83339. static readonly TEXTURE_LINEAR_NEAREST: number;
  83340. /** Explicit coordinates mode */
  83341. static readonly TEXTURE_EXPLICIT_MODE: number;
  83342. /** Spherical coordinates mode */
  83343. static readonly TEXTURE_SPHERICAL_MODE: number;
  83344. /** Planar coordinates mode */
  83345. static readonly TEXTURE_PLANAR_MODE: number;
  83346. /** Cubic coordinates mode */
  83347. static readonly TEXTURE_CUBIC_MODE: number;
  83348. /** Projection coordinates mode */
  83349. static readonly TEXTURE_PROJECTION_MODE: number;
  83350. /** Skybox coordinates mode */
  83351. static readonly TEXTURE_SKYBOX_MODE: number;
  83352. /** Inverse Cubic coordinates mode */
  83353. static readonly TEXTURE_INVCUBIC_MODE: number;
  83354. /** Equirectangular coordinates mode */
  83355. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  83356. /** Equirectangular Fixed coordinates mode */
  83357. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  83358. /** Equirectangular Fixed Mirrored coordinates mode */
  83359. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  83360. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  83361. static readonly SCALEMODE_FLOOR: number;
  83362. /** Defines that texture rescaling will look for the nearest power of 2 size */
  83363. static readonly SCALEMODE_NEAREST: number;
  83364. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  83365. static readonly SCALEMODE_CEILING: number;
  83366. /**
  83367. * Returns the current version of the framework
  83368. */
  83369. static readonly Version: string;
  83370. /**
  83371. * Returns a string describing the current engine
  83372. */
  83373. readonly description: string;
  83374. /**
  83375. * Gets or sets the epsilon value used by collision engine
  83376. */
  83377. static CollisionsEpsilon: number;
  83378. /**
  83379. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  83380. */
  83381. static ShadersRepository: string;
  83382. /**
  83383. * Method called to create the default loading screen.
  83384. * This can be overriden in your own app.
  83385. * @param canvas The rendering canvas element
  83386. * @returns The loading screen
  83387. */
  83388. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  83389. /**
  83390. * Method called to create the default rescale post process on each engine.
  83391. */
  83392. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  83393. /**
  83394. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  83395. */
  83396. forcePOTTextures: boolean;
  83397. /**
  83398. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  83399. */
  83400. isFullscreen: boolean;
  83401. /**
  83402. * Gets a boolean indicating if the pointer is currently locked
  83403. */
  83404. isPointerLock: boolean;
  83405. /**
  83406. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  83407. */
  83408. cullBackFaces: boolean;
  83409. /**
  83410. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  83411. */
  83412. renderEvenInBackground: boolean;
  83413. /**
  83414. * Gets or sets a boolean indicating that cache can be kept between frames
  83415. */
  83416. preventCacheWipeBetweenFrames: boolean;
  83417. /**
  83418. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  83419. **/
  83420. enableOfflineSupport: boolean;
  83421. /**
  83422. * 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)
  83423. **/
  83424. disableManifestCheck: boolean;
  83425. /**
  83426. * Gets the list of created scenes
  83427. */
  83428. scenes: Scene[];
  83429. /**
  83430. * Event raised when a new scene is created
  83431. */
  83432. onNewSceneAddedObservable: Observable<Scene>;
  83433. /**
  83434. * Gets the list of created postprocesses
  83435. */
  83436. postProcesses: PostProcess[];
  83437. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  83438. validateShaderPrograms: boolean;
  83439. /**
  83440. * Observable event triggered each time the rendering canvas is resized
  83441. */
  83442. onResizeObservable: Observable<Engine>;
  83443. /**
  83444. * Observable event triggered each time the canvas loses focus
  83445. */
  83446. onCanvasBlurObservable: Observable<Engine>;
  83447. /**
  83448. * Observable event triggered each time the canvas gains focus
  83449. */
  83450. onCanvasFocusObservable: Observable<Engine>;
  83451. /**
  83452. * Observable event triggered each time the canvas receives pointerout event
  83453. */
  83454. onCanvasPointerOutObservable: Observable<PointerEvent>;
  83455. /**
  83456. * Observable event triggered before each texture is initialized
  83457. */
  83458. onBeforeTextureInitObservable: Observable<Texture>;
  83459. private _vrDisplay;
  83460. private _vrSupported;
  83461. private _oldSize;
  83462. private _oldHardwareScaleFactor;
  83463. private _vrExclusivePointerMode;
  83464. private _webVRInitPromise;
  83465. /**
  83466. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  83467. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  83468. */
  83469. readonly isInVRExclusivePointerMode: boolean;
  83470. /**
  83471. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  83472. */
  83473. disableUniformBuffers: boolean;
  83474. /** @hidden */
  83475. _uniformBuffers: UniformBuffer[];
  83476. /**
  83477. * Gets a boolean indicating that the engine supports uniform buffers
  83478. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  83479. */
  83480. readonly supportsUniformBuffers: boolean;
  83481. /**
  83482. * Observable raised when the engine begins a new frame
  83483. */
  83484. onBeginFrameObservable: Observable<Engine>;
  83485. /**
  83486. * If set, will be used to request the next animation frame for the render loop
  83487. */
  83488. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  83489. /**
  83490. * Observable raised when the engine ends the current frame
  83491. */
  83492. onEndFrameObservable: Observable<Engine>;
  83493. /**
  83494. * Observable raised when the engine is about to compile a shader
  83495. */
  83496. onBeforeShaderCompilationObservable: Observable<Engine>;
  83497. /**
  83498. * Observable raised when the engine has jsut compiled a shader
  83499. */
  83500. onAfterShaderCompilationObservable: Observable<Engine>;
  83501. /** @hidden */
  83502. _gl: WebGLRenderingContext;
  83503. private _renderingCanvas;
  83504. private _windowIsBackground;
  83505. private _webGLVersion;
  83506. /**
  83507. * Gets a boolean indicating that only power of 2 textures are supported
  83508. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  83509. */
  83510. readonly needPOTTextures: boolean;
  83511. /** @hidden */
  83512. _badOS: boolean;
  83513. /** @hidden */
  83514. _badDesktopOS: boolean;
  83515. /**
  83516. * Gets or sets a value indicating if we want to disable texture binding optimization.
  83517. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  83518. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  83519. */
  83520. disableTextureBindingOptimization: boolean;
  83521. /**
  83522. * Gets the audio engine
  83523. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83524. * @ignorenaming
  83525. */
  83526. static audioEngine: IAudioEngine;
  83527. /**
  83528. * Default AudioEngine factory responsible of creating the Audio Engine.
  83529. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  83530. */
  83531. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  83532. /**
  83533. * Default offline support factory responsible of creating a tool used to store data locally.
  83534. * By default, this will create a Database object if the workload has been embedded.
  83535. */
  83536. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  83537. private _onFocus;
  83538. private _onBlur;
  83539. private _onCanvasPointerOut;
  83540. private _onCanvasBlur;
  83541. private _onCanvasFocus;
  83542. private _onFullscreenChange;
  83543. private _onPointerLockChange;
  83544. private _onVRDisplayPointerRestricted;
  83545. private _onVRDisplayPointerUnrestricted;
  83546. private _onVrDisplayConnect;
  83547. private _onVrDisplayDisconnect;
  83548. private _onVrDisplayPresentChange;
  83549. /**
  83550. * Observable signaled when VR display mode changes
  83551. */
  83552. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  83553. /**
  83554. * Observable signaled when VR request present is complete
  83555. */
  83556. onVRRequestPresentComplete: Observable<boolean>;
  83557. /**
  83558. * Observable signaled when VR request present starts
  83559. */
  83560. onVRRequestPresentStart: Observable<Engine>;
  83561. private _hardwareScalingLevel;
  83562. /** @hidden */
  83563. protected _caps: EngineCapabilities;
  83564. private _pointerLockRequested;
  83565. private _isStencilEnable;
  83566. private _colorWrite;
  83567. private _loadingScreen;
  83568. /** @hidden */
  83569. _drawCalls: PerfCounter;
  83570. /** @hidden */
  83571. _textureCollisions: PerfCounter;
  83572. private _glVersion;
  83573. private _glRenderer;
  83574. private _glVendor;
  83575. private _videoTextureSupported;
  83576. private _renderingQueueLaunched;
  83577. private _activeRenderLoops;
  83578. private _deterministicLockstep;
  83579. private _lockstepMaxSteps;
  83580. /**
  83581. * Observable signaled when a context lost event is raised
  83582. */
  83583. onContextLostObservable: Observable<Engine>;
  83584. /**
  83585. * Observable signaled when a context restored event is raised
  83586. */
  83587. onContextRestoredObservable: Observable<Engine>;
  83588. private _onContextLost;
  83589. private _onContextRestored;
  83590. private _contextWasLost;
  83591. private _doNotHandleContextLost;
  83592. /**
  83593. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  83594. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  83595. */
  83596. doNotHandleContextLost: boolean;
  83597. private _performanceMonitor;
  83598. private _fps;
  83599. private _deltaTime;
  83600. /**
  83601. * Turn this value on if you want to pause FPS computation when in background
  83602. */
  83603. disablePerformanceMonitorInBackground: boolean;
  83604. /**
  83605. * Gets the performance monitor attached to this engine
  83606. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  83607. */
  83608. readonly performanceMonitor: PerformanceMonitor;
  83609. /** @hidden */
  83610. protected _depthCullingState: _DepthCullingState;
  83611. /** @hidden */
  83612. protected _stencilState: _StencilState;
  83613. /** @hidden */
  83614. protected _alphaState: _AlphaState;
  83615. /** @hidden */
  83616. protected _alphaMode: number;
  83617. protected _internalTexturesCache: InternalTexture[];
  83618. /** @hidden */
  83619. protected _activeChannel: number;
  83620. private _currentTextureChannel;
  83621. /** @hidden */
  83622. protected _boundTexturesCache: {
  83623. [key: string]: Nullable<InternalTexture>;
  83624. };
  83625. /** @hidden */
  83626. protected _currentEffect: Nullable<Effect>;
  83627. /** @hidden */
  83628. protected _currentProgram: Nullable<WebGLProgram>;
  83629. private _compiledEffects;
  83630. private _vertexAttribArraysEnabled;
  83631. /** @hidden */
  83632. protected _cachedViewport: Nullable<Viewport>;
  83633. private _cachedVertexArrayObject;
  83634. /** @hidden */
  83635. protected _cachedVertexBuffers: any;
  83636. /** @hidden */
  83637. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  83638. /** @hidden */
  83639. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  83640. /** @hidden */
  83641. protected _currentRenderTarget: Nullable<InternalTexture>;
  83642. private _uintIndicesCurrentlySet;
  83643. private _currentBoundBuffer;
  83644. /** @hidden */
  83645. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  83646. private _currentBufferPointers;
  83647. private _currentInstanceLocations;
  83648. private _currentInstanceBuffers;
  83649. private _textureUnits;
  83650. private _firstBoundInternalTextureTracker;
  83651. private _lastBoundInternalTextureTracker;
  83652. private _workingCanvas;
  83653. private _workingContext;
  83654. private _rescalePostProcess;
  83655. private _dummyFramebuffer;
  83656. private _externalData;
  83657. private _bindedRenderFunction;
  83658. private _vaoRecordInProgress;
  83659. private _mustWipeVertexAttributes;
  83660. private _emptyTexture;
  83661. private _emptyCubeTexture;
  83662. private _emptyTexture3D;
  83663. /** @hidden */
  83664. _frameHandler: number;
  83665. private _nextFreeTextureSlots;
  83666. private _maxSimultaneousTextures;
  83667. private _activeRequests;
  83668. private _texturesSupported;
  83669. private _textureFormatInUse;
  83670. /**
  83671. * Gets the list of texture formats supported
  83672. */
  83673. readonly texturesSupported: Array<string>;
  83674. /**
  83675. * Gets the list of texture formats in use
  83676. */
  83677. readonly textureFormatInUse: Nullable<string>;
  83678. /**
  83679. * Gets the current viewport
  83680. */
  83681. readonly currentViewport: Nullable<Viewport>;
  83682. /**
  83683. * Gets the default empty texture
  83684. */
  83685. readonly emptyTexture: InternalTexture;
  83686. /**
  83687. * Gets the default empty 3D texture
  83688. */
  83689. readonly emptyTexture3D: InternalTexture;
  83690. /**
  83691. * Gets the default empty cube texture
  83692. */
  83693. readonly emptyCubeTexture: InternalTexture;
  83694. /**
  83695. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  83696. */
  83697. readonly premultipliedAlpha: boolean;
  83698. /**
  83699. * Creates a new engine
  83700. * @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
  83701. * @param antialias defines enable antialiasing (default: false)
  83702. * @param options defines further options to be sent to the getContext() function
  83703. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  83704. */
  83705. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  83706. private _disableTouchAction;
  83707. private _rebuildInternalTextures;
  83708. private _rebuildEffects;
  83709. /**
  83710. * Gets a boolean indicating if all created effects are ready
  83711. * @returns true if all effects are ready
  83712. */
  83713. areAllEffectsReady(): boolean;
  83714. private _rebuildBuffers;
  83715. private _initGLContext;
  83716. /**
  83717. * Gets version of the current webGL context
  83718. */
  83719. readonly webGLVersion: number;
  83720. /**
  83721. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  83722. */
  83723. readonly isStencilEnable: boolean;
  83724. private _prepareWorkingCanvas;
  83725. /**
  83726. * Reset the texture cache to empty state
  83727. */
  83728. resetTextureCache(): void;
  83729. /**
  83730. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  83731. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  83732. * @returns true if engine is in deterministic lock step mode
  83733. */
  83734. isDeterministicLockStep(): boolean;
  83735. /**
  83736. * Gets the max steps when engine is running in deterministic lock step
  83737. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  83738. * @returns the max steps
  83739. */
  83740. getLockstepMaxSteps(): number;
  83741. /**
  83742. * Gets an object containing information about the current webGL context
  83743. * @returns an object containing the vender, the renderer and the version of the current webGL context
  83744. */
  83745. getGlInfo(): {
  83746. vendor: string;
  83747. renderer: string;
  83748. version: string;
  83749. };
  83750. /**
  83751. * Gets current aspect ratio
  83752. * @param camera defines the camera to use to get the aspect ratio
  83753. * @param useScreen defines if screen size must be used (or the current render target if any)
  83754. * @returns a number defining the aspect ratio
  83755. */
  83756. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  83757. /**
  83758. * Gets current screen aspect ratio
  83759. * @returns a number defining the aspect ratio
  83760. */
  83761. getScreenAspectRatio(): number;
  83762. /**
  83763. * Gets the current render width
  83764. * @param useScreen defines if screen size must be used (or the current render target if any)
  83765. * @returns a number defining the current render width
  83766. */
  83767. getRenderWidth(useScreen?: boolean): number;
  83768. /**
  83769. * Gets the current render height
  83770. * @param useScreen defines if screen size must be used (or the current render target if any)
  83771. * @returns a number defining the current render height
  83772. */
  83773. getRenderHeight(useScreen?: boolean): number;
  83774. /**
  83775. * Gets the HTML canvas attached with the current webGL context
  83776. * @returns a HTML canvas
  83777. */
  83778. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  83779. /**
  83780. * Gets the client rect of the HTML canvas attached with the current webGL context
  83781. * @returns a client rectanglee
  83782. */
  83783. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  83784. /**
  83785. * Defines the hardware scaling level.
  83786. * By default the hardware scaling level is computed from the window device ratio.
  83787. * 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.
  83788. * @param level defines the level to use
  83789. */
  83790. setHardwareScalingLevel(level: number): void;
  83791. /**
  83792. * Gets the current hardware scaling level.
  83793. * By default the hardware scaling level is computed from the window device ratio.
  83794. * 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.
  83795. * @returns a number indicating the current hardware scaling level
  83796. */
  83797. getHardwareScalingLevel(): number;
  83798. /**
  83799. * Gets the list of loaded textures
  83800. * @returns an array containing all loaded textures
  83801. */
  83802. getLoadedTexturesCache(): InternalTexture[];
  83803. /**
  83804. * Gets the object containing all engine capabilities
  83805. * @returns the EngineCapabilities object
  83806. */
  83807. getCaps(): EngineCapabilities;
  83808. /**
  83809. * Gets the current depth function
  83810. * @returns a number defining the depth function
  83811. */
  83812. getDepthFunction(): Nullable<number>;
  83813. /**
  83814. * Sets the current depth function
  83815. * @param depthFunc defines the function to use
  83816. */
  83817. setDepthFunction(depthFunc: number): void;
  83818. /**
  83819. * Sets the current depth function to GREATER
  83820. */
  83821. setDepthFunctionToGreater(): void;
  83822. /**
  83823. * Sets the current depth function to GEQUAL
  83824. */
  83825. setDepthFunctionToGreaterOrEqual(): void;
  83826. /**
  83827. * Sets the current depth function to LESS
  83828. */
  83829. setDepthFunctionToLess(): void;
  83830. /**
  83831. * Sets the current depth function to LEQUAL
  83832. */
  83833. setDepthFunctionToLessOrEqual(): void;
  83834. /**
  83835. * Gets a boolean indicating if stencil buffer is enabled
  83836. * @returns the current stencil buffer state
  83837. */
  83838. getStencilBuffer(): boolean;
  83839. /**
  83840. * Enable or disable the stencil buffer
  83841. * @param enable defines if the stencil buffer must be enabled or disabled
  83842. */
  83843. setStencilBuffer(enable: boolean): void;
  83844. /**
  83845. * Gets the current stencil mask
  83846. * @returns a number defining the new stencil mask to use
  83847. */
  83848. getStencilMask(): number;
  83849. /**
  83850. * Sets the current stencil mask
  83851. * @param mask defines the new stencil mask to use
  83852. */
  83853. setStencilMask(mask: number): void;
  83854. /**
  83855. * Gets the current stencil function
  83856. * @returns a number defining the stencil function to use
  83857. */
  83858. getStencilFunction(): number;
  83859. /**
  83860. * Gets the current stencil reference value
  83861. * @returns a number defining the stencil reference value to use
  83862. */
  83863. getStencilFunctionReference(): number;
  83864. /**
  83865. * Gets the current stencil mask
  83866. * @returns a number defining the stencil mask to use
  83867. */
  83868. getStencilFunctionMask(): number;
  83869. /**
  83870. * Sets the current stencil function
  83871. * @param stencilFunc defines the new stencil function to use
  83872. */
  83873. setStencilFunction(stencilFunc: number): void;
  83874. /**
  83875. * Sets the current stencil reference
  83876. * @param reference defines the new stencil reference to use
  83877. */
  83878. setStencilFunctionReference(reference: number): void;
  83879. /**
  83880. * Sets the current stencil mask
  83881. * @param mask defines the new stencil mask to use
  83882. */
  83883. setStencilFunctionMask(mask: number): void;
  83884. /**
  83885. * Gets the current stencil operation when stencil fails
  83886. * @returns a number defining stencil operation to use when stencil fails
  83887. */
  83888. getStencilOperationFail(): number;
  83889. /**
  83890. * Gets the current stencil operation when depth fails
  83891. * @returns a number defining stencil operation to use when depth fails
  83892. */
  83893. getStencilOperationDepthFail(): number;
  83894. /**
  83895. * Gets the current stencil operation when stencil passes
  83896. * @returns a number defining stencil operation to use when stencil passes
  83897. */
  83898. getStencilOperationPass(): number;
  83899. /**
  83900. * Sets the stencil operation to use when stencil fails
  83901. * @param operation defines the stencil operation to use when stencil fails
  83902. */
  83903. setStencilOperationFail(operation: number): void;
  83904. /**
  83905. * Sets the stencil operation to use when depth fails
  83906. * @param operation defines the stencil operation to use when depth fails
  83907. */
  83908. setStencilOperationDepthFail(operation: number): void;
  83909. /**
  83910. * Sets the stencil operation to use when stencil passes
  83911. * @param operation defines the stencil operation to use when stencil passes
  83912. */
  83913. setStencilOperationPass(operation: number): void;
  83914. /**
  83915. * Sets a boolean indicating if the dithering state is enabled or disabled
  83916. * @param value defines the dithering state
  83917. */
  83918. setDitheringState(value: boolean): void;
  83919. /**
  83920. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  83921. * @param value defines the rasterizer state
  83922. */
  83923. setRasterizerState(value: boolean): void;
  83924. /**
  83925. * stop executing a render loop function and remove it from the execution array
  83926. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  83927. */
  83928. stopRenderLoop(renderFunction?: () => void): void;
  83929. /** @hidden */
  83930. _renderLoop(): void;
  83931. /**
  83932. * Register and execute a render loop. The engine can have more than one render function
  83933. * @param renderFunction defines the function to continuously execute
  83934. */
  83935. runRenderLoop(renderFunction: () => void): void;
  83936. /**
  83937. * Toggle full screen mode
  83938. * @param requestPointerLock defines if a pointer lock should be requested from the user
  83939. */
  83940. switchFullscreen(requestPointerLock: boolean): void;
  83941. /**
  83942. * Enters full screen mode
  83943. * @param requestPointerLock defines if a pointer lock should be requested from the user
  83944. */
  83945. enterFullscreen(requestPointerLock: boolean): void;
  83946. /**
  83947. * Exits full screen mode
  83948. */
  83949. exitFullscreen(): void;
  83950. /**
  83951. * Clear the current render buffer or the current render target (if any is set up)
  83952. * @param color defines the color to use
  83953. * @param backBuffer defines if the back buffer must be cleared
  83954. * @param depth defines if the depth buffer must be cleared
  83955. * @param stencil defines if the stencil buffer must be cleared
  83956. */
  83957. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  83958. /**
  83959. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  83960. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  83961. * @param y defines the y-coordinate of the corner of the clear rectangle
  83962. * @param width defines the width of the clear rectangle
  83963. * @param height defines the height of the clear rectangle
  83964. * @param clearColor defines the clear color
  83965. */
  83966. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  83967. /**
  83968. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  83969. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  83970. * @param y defines the y-coordinate of the corner of the clear rectangle
  83971. * @param width defines the width of the clear rectangle
  83972. * @param height defines the height of the clear rectangle
  83973. */
  83974. enableScissor(x: number, y: number, width: number, height: number): void;
  83975. /**
  83976. * Disable previously set scissor test rectangle
  83977. */
  83978. disableScissor(): void;
  83979. private _viewportCached;
  83980. /** @hidden */
  83981. _viewport(x: number, y: number, width: number, height: number): void;
  83982. /**
  83983. * Set the WebGL's viewport
  83984. * @param viewport defines the viewport element to be used
  83985. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  83986. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  83987. */
  83988. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  83989. /**
  83990. * Directly set the WebGL Viewport
  83991. * @param x defines the x coordinate of the viewport (in screen space)
  83992. * @param y defines the y coordinate of the viewport (in screen space)
  83993. * @param width defines the width of the viewport (in screen space)
  83994. * @param height defines the height of the viewport (in screen space)
  83995. * @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
  83996. */
  83997. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  83998. /**
  83999. * Begin a new frame
  84000. */
  84001. beginFrame(): void;
  84002. /**
  84003. * Enf the current frame
  84004. */
  84005. endFrame(): void;
  84006. /**
  84007. * Resize the view according to the canvas' size
  84008. */
  84009. resize(): void;
  84010. /**
  84011. * Force a specific size of the canvas
  84012. * @param width defines the new canvas' width
  84013. * @param height defines the new canvas' height
  84014. */
  84015. setSize(width: number, height: number): void;
  84016. /**
  84017. * Gets a boolean indicating if a webVR device was detected
  84018. * @returns true if a webVR device was detected
  84019. */
  84020. isVRDevicePresent(): boolean;
  84021. /**
  84022. * Gets the current webVR device
  84023. * @returns the current webVR device (or null)
  84024. */
  84025. getVRDevice(): any;
  84026. /**
  84027. * Initializes a webVR display and starts listening to display change events
  84028. * The onVRDisplayChangedObservable will be notified upon these changes
  84029. * @returns The onVRDisplayChangedObservable
  84030. */
  84031. initWebVR(): Observable<IDisplayChangedEventArgs>;
  84032. /**
  84033. * Initializes a webVR display and starts listening to display change events
  84034. * The onVRDisplayChangedObservable will be notified upon these changes
  84035. * @returns A promise containing a VRDisplay and if vr is supported
  84036. */
  84037. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  84038. /**
  84039. * Call this function to switch to webVR mode
  84040. * Will do nothing if webVR is not supported or if there is no webVR device
  84041. * @see http://doc.babylonjs.com/how_to/webvr_camera
  84042. */
  84043. enableVR(): void;
  84044. /**
  84045. * Call this function to leave webVR mode
  84046. * Will do nothing if webVR is not supported or if there is no webVR device
  84047. * @see http://doc.babylonjs.com/how_to/webvr_camera
  84048. */
  84049. disableVR(): void;
  84050. private _onVRFullScreenTriggered;
  84051. private _getVRDisplaysAsync;
  84052. /**
  84053. * Binds the frame buffer to the specified texture.
  84054. * @param texture The texture to render to or null for the default canvas
  84055. * @param faceIndex The face of the texture to render to in case of cube texture
  84056. * @param requiredWidth The width of the target to render to
  84057. * @param requiredHeight The height of the target to render to
  84058. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  84059. * @param depthStencilTexture The depth stencil texture to use to render
  84060. * @param lodLevel defines le lod level to bind to the frame buffer
  84061. */
  84062. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  84063. private bindUnboundFramebuffer;
  84064. /**
  84065. * Unbind the current render target texture from the webGL context
  84066. * @param texture defines the render target texture to unbind
  84067. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  84068. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  84069. */
  84070. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  84071. /**
  84072. * Unbind a list of render target textures from the webGL context
  84073. * This is used only when drawBuffer extension or webGL2 are active
  84074. * @param textures defines the render target textures to unbind
  84075. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  84076. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  84077. */
  84078. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  84079. /**
  84080. * Force the mipmap generation for the given render target texture
  84081. * @param texture defines the render target texture to use
  84082. */
  84083. generateMipMapsForCubemap(texture: InternalTexture): void;
  84084. /**
  84085. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  84086. */
  84087. flushFramebuffer(): void;
  84088. /**
  84089. * Unbind the current render target and bind the default framebuffer
  84090. */
  84091. restoreDefaultFramebuffer(): void;
  84092. /**
  84093. * Create an uniform buffer
  84094. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84095. * @param elements defines the content of the uniform buffer
  84096. * @returns the webGL uniform buffer
  84097. */
  84098. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  84099. /**
  84100. * Create a dynamic uniform buffer
  84101. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84102. * @param elements defines the content of the uniform buffer
  84103. * @returns the webGL uniform buffer
  84104. */
  84105. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  84106. /**
  84107. * Update an existing uniform buffer
  84108. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84109. * @param uniformBuffer defines the target uniform buffer
  84110. * @param elements defines the content to update
  84111. * @param offset defines the offset in the uniform buffer where update should start
  84112. * @param count defines the size of the data to update
  84113. */
  84114. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  84115. private _resetVertexBufferBinding;
  84116. /**
  84117. * Creates a vertex buffer
  84118. * @param data the data for the vertex buffer
  84119. * @returns the new WebGL static buffer
  84120. */
  84121. createVertexBuffer(data: DataArray): WebGLBuffer;
  84122. /**
  84123. * Creates a dynamic vertex buffer
  84124. * @param data the data for the dynamic vertex buffer
  84125. * @returns the new WebGL dynamic buffer
  84126. */
  84127. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  84128. /**
  84129. * Update a dynamic index buffer
  84130. * @param indexBuffer defines the target index buffer
  84131. * @param indices defines the data to update
  84132. * @param offset defines the offset in the target index buffer where update should start
  84133. */
  84134. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  84135. /**
  84136. * Updates a dynamic vertex buffer.
  84137. * @param vertexBuffer the vertex buffer to update
  84138. * @param data the data used to update the vertex buffer
  84139. * @param byteOffset the byte offset of the data
  84140. * @param byteLength the byte length of the data
  84141. */
  84142. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  84143. private _resetIndexBufferBinding;
  84144. /**
  84145. * Creates a new index buffer
  84146. * @param indices defines the content of the index buffer
  84147. * @param updatable defines if the index buffer must be updatable
  84148. * @returns a new webGL buffer
  84149. */
  84150. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  84151. /**
  84152. * Bind a webGL buffer to the webGL context
  84153. * @param buffer defines the buffer to bind
  84154. */
  84155. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  84156. /**
  84157. * Bind an uniform buffer to the current webGL context
  84158. * @param buffer defines the buffer to bind
  84159. */
  84160. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  84161. /**
  84162. * Bind a buffer to the current webGL context at a given location
  84163. * @param buffer defines the buffer to bind
  84164. * @param location defines the index where to bind the buffer
  84165. */
  84166. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  84167. /**
  84168. * Bind a specific block at a given index in a specific shader program
  84169. * @param shaderProgram defines the shader program
  84170. * @param blockName defines the block name
  84171. * @param index defines the index where to bind the block
  84172. */
  84173. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  84174. private bindIndexBuffer;
  84175. private bindBuffer;
  84176. /**
  84177. * update the bound buffer with the given data
  84178. * @param data defines the data to update
  84179. */
  84180. updateArrayBuffer(data: Float32Array): void;
  84181. private _vertexAttribPointer;
  84182. private _bindIndexBufferWithCache;
  84183. private _bindVertexBuffersAttributes;
  84184. /**
  84185. * Records a vertex array object
  84186. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  84187. * @param vertexBuffers defines the list of vertex buffers to store
  84188. * @param indexBuffer defines the index buffer to store
  84189. * @param effect defines the effect to store
  84190. * @returns the new vertex array object
  84191. */
  84192. recordVertexArrayObject(vertexBuffers: {
  84193. [key: string]: VertexBuffer;
  84194. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  84195. /**
  84196. * Bind a specific vertex array object
  84197. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  84198. * @param vertexArrayObject defines the vertex array object to bind
  84199. * @param indexBuffer defines the index buffer to bind
  84200. */
  84201. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  84202. /**
  84203. * Bind webGl buffers directly to the webGL context
  84204. * @param vertexBuffer defines the vertex buffer to bind
  84205. * @param indexBuffer defines the index buffer to bind
  84206. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  84207. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  84208. * @param effect defines the effect associated with the vertex buffer
  84209. */
  84210. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  84211. private _unbindVertexArrayObject;
  84212. /**
  84213. * Bind a list of vertex buffers to the webGL context
  84214. * @param vertexBuffers defines the list of vertex buffers to bind
  84215. * @param indexBuffer defines the index buffer to bind
  84216. * @param effect defines the effect associated with the vertex buffers
  84217. */
  84218. bindBuffers(vertexBuffers: {
  84219. [key: string]: Nullable<VertexBuffer>;
  84220. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  84221. /**
  84222. * Unbind all instance attributes
  84223. */
  84224. unbindInstanceAttributes(): void;
  84225. /**
  84226. * Release and free the memory of a vertex array object
  84227. * @param vao defines the vertex array object to delete
  84228. */
  84229. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  84230. /** @hidden */
  84231. _releaseBuffer(buffer: WebGLBuffer): boolean;
  84232. /**
  84233. * Creates a webGL buffer to use with instanciation
  84234. * @param capacity defines the size of the buffer
  84235. * @returns the webGL buffer
  84236. */
  84237. createInstancesBuffer(capacity: number): WebGLBuffer;
  84238. /**
  84239. * Delete a webGL buffer used with instanciation
  84240. * @param buffer defines the webGL buffer to delete
  84241. */
  84242. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  84243. /**
  84244. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  84245. * @param instancesBuffer defines the webGL buffer to update and bind
  84246. * @param data defines the data to store in the buffer
  84247. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  84248. */
  84249. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  84250. /**
  84251. * Apply all cached states (depth, culling, stencil and alpha)
  84252. */
  84253. applyStates(): void;
  84254. /**
  84255. * Send a draw order
  84256. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  84257. * @param indexStart defines the starting index
  84258. * @param indexCount defines the number of index to draw
  84259. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  84260. */
  84261. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  84262. /**
  84263. * Draw a list of points
  84264. * @param verticesStart defines the index of first vertex to draw
  84265. * @param verticesCount defines the count of vertices to draw
  84266. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  84267. */
  84268. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  84269. /**
  84270. * Draw a list of unindexed primitives
  84271. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  84272. * @param verticesStart defines the index of first vertex to draw
  84273. * @param verticesCount defines the count of vertices to draw
  84274. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  84275. */
  84276. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  84277. /**
  84278. * Draw a list of indexed primitives
  84279. * @param fillMode defines the primitive to use
  84280. * @param indexStart defines the starting index
  84281. * @param indexCount defines the number of index to draw
  84282. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  84283. */
  84284. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  84285. /**
  84286. * Draw a list of unindexed primitives
  84287. * @param fillMode defines the primitive to use
  84288. * @param verticesStart defines the index of first vertex to draw
  84289. * @param verticesCount defines the count of vertices to draw
  84290. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  84291. */
  84292. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  84293. private _drawMode;
  84294. /** @hidden */
  84295. _releaseEffect(effect: Effect): void;
  84296. /** @hidden */
  84297. _deleteProgram(program: WebGLProgram): void;
  84298. /**
  84299. * Create a new effect (used to store vertex/fragment shaders)
  84300. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  84301. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  84302. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  84303. * @param samplers defines an array of string used to represent textures
  84304. * @param defines defines the string containing the defines to use to compile the shaders
  84305. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  84306. * @param onCompiled defines a function to call when the effect creation is successful
  84307. * @param onError defines a function to call when the effect creation has failed
  84308. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  84309. * @returns the new Effect
  84310. */
  84311. 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;
  84312. private _compileShader;
  84313. private _compileRawShader;
  84314. /**
  84315. * Directly creates a webGL program
  84316. * @param vertexCode defines the vertex shader code to use
  84317. * @param fragmentCode defines the fragment shader code to use
  84318. * @param context defines the webGL context to use (if not set, the current one will be used)
  84319. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  84320. * @returns the new webGL program
  84321. */
  84322. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  84323. /**
  84324. * Creates a webGL program
  84325. * @param vertexCode defines the vertex shader code to use
  84326. * @param fragmentCode defines the fragment shader code to use
  84327. * @param defines defines the string containing the defines to use to compile the shaders
  84328. * @param context defines the webGL context to use (if not set, the current one will be used)
  84329. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  84330. * @returns the new webGL program
  84331. */
  84332. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  84333. private _createShaderProgram;
  84334. private _finalizeProgram;
  84335. /** @hidden */
  84336. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  84337. /** @hidden */
  84338. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  84339. /**
  84340. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  84341. * @param shaderProgram defines the webGL program to use
  84342. * @param uniformsNames defines the list of uniform names
  84343. * @returns an array of webGL uniform locations
  84344. */
  84345. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  84346. /**
  84347. * Gets the lsit of active attributes for a given webGL program
  84348. * @param shaderProgram defines the webGL program to use
  84349. * @param attributesNames defines the list of attribute names to get
  84350. * @returns an array of indices indicating the offset of each attribute
  84351. */
  84352. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  84353. /**
  84354. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  84355. * @param effect defines the effect to activate
  84356. */
  84357. enableEffect(effect: Nullable<Effect>): void;
  84358. /**
  84359. * Set the value of an uniform to an array of int32
  84360. * @param uniform defines the webGL uniform location where to store the value
  84361. * @param array defines the array of int32 to store
  84362. */
  84363. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  84364. /**
  84365. * Set the value of an uniform to an array of int32 (stored as vec2)
  84366. * @param uniform defines the webGL uniform location where to store the value
  84367. * @param array defines the array of int32 to store
  84368. */
  84369. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  84370. /**
  84371. * Set the value of an uniform to an array of int32 (stored as vec3)
  84372. * @param uniform defines the webGL uniform location where to store the value
  84373. * @param array defines the array of int32 to store
  84374. */
  84375. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  84376. /**
  84377. * Set the value of an uniform to an array of int32 (stored as vec4)
  84378. * @param uniform defines the webGL uniform location where to store the value
  84379. * @param array defines the array of int32 to store
  84380. */
  84381. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  84382. /**
  84383. * Set the value of an uniform to an array of float32
  84384. * @param uniform defines the webGL uniform location where to store the value
  84385. * @param array defines the array of float32 to store
  84386. */
  84387. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  84388. /**
  84389. * Set the value of an uniform to an array of float32 (stored as vec2)
  84390. * @param uniform defines the webGL uniform location where to store the value
  84391. * @param array defines the array of float32 to store
  84392. */
  84393. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  84394. /**
  84395. * Set the value of an uniform to an array of float32 (stored as vec3)
  84396. * @param uniform defines the webGL uniform location where to store the value
  84397. * @param array defines the array of float32 to store
  84398. */
  84399. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  84400. /**
  84401. * Set the value of an uniform to an array of float32 (stored as vec4)
  84402. * @param uniform defines the webGL uniform location where to store the value
  84403. * @param array defines the array of float32 to store
  84404. */
  84405. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  84406. /**
  84407. * Set the value of an uniform to an array of number
  84408. * @param uniform defines the webGL uniform location where to store the value
  84409. * @param array defines the array of number to store
  84410. */
  84411. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  84412. /**
  84413. * Set the value of an uniform to an array of number (stored as vec2)
  84414. * @param uniform defines the webGL uniform location where to store the value
  84415. * @param array defines the array of number to store
  84416. */
  84417. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  84418. /**
  84419. * Set the value of an uniform to an array of number (stored as vec3)
  84420. * @param uniform defines the webGL uniform location where to store the value
  84421. * @param array defines the array of number to store
  84422. */
  84423. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  84424. /**
  84425. * Set the value of an uniform to an array of number (stored as vec4)
  84426. * @param uniform defines the webGL uniform location where to store the value
  84427. * @param array defines the array of number to store
  84428. */
  84429. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  84430. /**
  84431. * Set the value of an uniform to an array of float32 (stored as matrices)
  84432. * @param uniform defines the webGL uniform location where to store the value
  84433. * @param matrices defines the array of float32 to store
  84434. */
  84435. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  84436. /**
  84437. * Set the value of an uniform to a matrix
  84438. * @param uniform defines the webGL uniform location where to store the value
  84439. * @param matrix defines the matrix to store
  84440. */
  84441. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  84442. /**
  84443. * Set the value of an uniform to a matrix (3x3)
  84444. * @param uniform defines the webGL uniform location where to store the value
  84445. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  84446. */
  84447. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  84448. /**
  84449. * Set the value of an uniform to a matrix (2x2)
  84450. * @param uniform defines the webGL uniform location where to store the value
  84451. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  84452. */
  84453. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  84454. /**
  84455. * Set the value of an uniform to a number (int)
  84456. * @param uniform defines the webGL uniform location where to store the value
  84457. * @param value defines the int number to store
  84458. */
  84459. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  84460. /**
  84461. * Set the value of an uniform to a number (float)
  84462. * @param uniform defines the webGL uniform location where to store the value
  84463. * @param value defines the float number to store
  84464. */
  84465. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  84466. /**
  84467. * Set the value of an uniform to a vec2
  84468. * @param uniform defines the webGL uniform location where to store the value
  84469. * @param x defines the 1st component of the value
  84470. * @param y defines the 2nd component of the value
  84471. */
  84472. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  84473. /**
  84474. * Set the value of an uniform to a vec3
  84475. * @param uniform defines the webGL uniform location where to store the value
  84476. * @param x defines the 1st component of the value
  84477. * @param y defines the 2nd component of the value
  84478. * @param z defines the 3rd component of the value
  84479. */
  84480. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  84481. /**
  84482. * Set the value of an uniform to a boolean
  84483. * @param uniform defines the webGL uniform location where to store the value
  84484. * @param bool defines the boolean to store
  84485. */
  84486. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  84487. /**
  84488. * Set the value of an uniform to a vec4
  84489. * @param uniform defines the webGL uniform location where to store the value
  84490. * @param x defines the 1st component of the value
  84491. * @param y defines the 2nd component of the value
  84492. * @param z defines the 3rd component of the value
  84493. * @param w defines the 4th component of the value
  84494. */
  84495. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  84496. /**
  84497. * Set the value of an uniform to a Color3
  84498. * @param uniform defines the webGL uniform location where to store the value
  84499. * @param color3 defines the color to store
  84500. */
  84501. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  84502. /**
  84503. * Set the value of an uniform to a Color3 and an alpha value
  84504. * @param uniform defines the webGL uniform location where to store the value
  84505. * @param color3 defines the color to store
  84506. * @param alpha defines the alpha component to store
  84507. */
  84508. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  84509. /**
  84510. * Sets a Color4 on a uniform variable
  84511. * @param uniform defines the uniform location
  84512. * @param color4 defines the value to be set
  84513. */
  84514. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  84515. /**
  84516. * Set various states to the webGL context
  84517. * @param culling defines backface culling state
  84518. * @param zOffset defines the value to apply to zOffset (0 by default)
  84519. * @param force defines if states must be applied even if cache is up to date
  84520. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  84521. */
  84522. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  84523. /**
  84524. * Set the z offset to apply to current rendering
  84525. * @param value defines the offset to apply
  84526. */
  84527. setZOffset(value: number): void;
  84528. /**
  84529. * Gets the current value of the zOffset
  84530. * @returns the current zOffset state
  84531. */
  84532. getZOffset(): number;
  84533. /**
  84534. * Enable or disable depth buffering
  84535. * @param enable defines the state to set
  84536. */
  84537. setDepthBuffer(enable: boolean): void;
  84538. /**
  84539. * Gets a boolean indicating if depth writing is enabled
  84540. * @returns the current depth writing state
  84541. */
  84542. getDepthWrite(): boolean;
  84543. /**
  84544. * Enable or disable depth writing
  84545. * @param enable defines the state to set
  84546. */
  84547. setDepthWrite(enable: boolean): void;
  84548. /**
  84549. * Enable or disable color writing
  84550. * @param enable defines the state to set
  84551. */
  84552. setColorWrite(enable: boolean): void;
  84553. /**
  84554. * Gets a boolean indicating if color writing is enabled
  84555. * @returns the current color writing state
  84556. */
  84557. getColorWrite(): boolean;
  84558. /**
  84559. * Sets alpha constants used by some alpha blending modes
  84560. * @param r defines the red component
  84561. * @param g defines the green component
  84562. * @param b defines the blue component
  84563. * @param a defines the alpha component
  84564. */
  84565. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  84566. /**
  84567. * Sets the current alpha mode
  84568. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  84569. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  84570. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  84571. */
  84572. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  84573. /**
  84574. * Gets the current alpha mode
  84575. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  84576. * @returns the current alpha mode
  84577. */
  84578. getAlphaMode(): number;
  84579. /**
  84580. * Clears the list of texture accessible through engine.
  84581. * This can help preventing texture load conflict due to name collision.
  84582. */
  84583. clearInternalTexturesCache(): void;
  84584. /**
  84585. * Force the entire cache to be cleared
  84586. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  84587. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  84588. */
  84589. wipeCaches(bruteForce?: boolean): void;
  84590. /**
  84591. * Set the compressed texture format to use, based on the formats you have, and the formats
  84592. * supported by the hardware / browser.
  84593. *
  84594. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  84595. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  84596. * to API arguments needed to compressed textures. This puts the burden on the container
  84597. * generator to house the arcane code for determining these for current & future formats.
  84598. *
  84599. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  84600. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  84601. *
  84602. * Note: The result of this call is not taken into account when a texture is base64.
  84603. *
  84604. * @param formatsAvailable defines the list of those format families you have created
  84605. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  84606. *
  84607. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  84608. * @returns The extension selected.
  84609. */
  84610. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  84611. private _getSamplingParameters;
  84612. private _partialLoadImg;
  84613. private _cascadeLoadImgs;
  84614. /** @hidden */
  84615. _createTexture(): WebGLTexture;
  84616. /**
  84617. * Usually called from Texture.ts.
  84618. * Passed information to create a WebGLTexture
  84619. * @param urlArg defines a value which contains one of the following:
  84620. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  84621. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  84622. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  84623. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  84624. * @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)
  84625. * @param scene needed for loading to the correct scene
  84626. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  84627. * @param onLoad optional callback to be called upon successful completion
  84628. * @param onError optional callback to be called upon failure
  84629. * @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
  84630. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  84631. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  84632. * @param forcedExtension defines the extension to use to pick the right loader
  84633. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  84634. * @returns a InternalTexture for assignment back into BABYLON.Texture
  84635. */
  84636. 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;
  84637. private _rescaleTexture;
  84638. /**
  84639. * Update a raw texture
  84640. * @param texture defines the texture to update
  84641. * @param data defines the data to store in the texture
  84642. * @param format defines the format of the data
  84643. * @param invertY defines if data must be stored with Y axis inverted
  84644. * @param compression defines the compression used (null by default)
  84645. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84646. */
  84647. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  84648. /**
  84649. * Creates a raw texture
  84650. * @param data defines the data to store in the texture
  84651. * @param width defines the width of the texture
  84652. * @param height defines the height of the texture
  84653. * @param format defines the format of the data
  84654. * @param generateMipMaps defines if the engine should generate the mip levels
  84655. * @param invertY defines if data must be stored with Y axis inverted
  84656. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  84657. * @param compression defines the compression used (null by default)
  84658. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84659. * @returns the raw texture inside an InternalTexture
  84660. */
  84661. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  84662. private _unpackFlipYCached;
  84663. /**
  84664. * In case you are sharing the context with other applications, it might
  84665. * be interested to not cache the unpack flip y state to ensure a consistent
  84666. * value would be set.
  84667. */
  84668. enableUnpackFlipYCached: boolean;
  84669. /** @hidden */
  84670. _unpackFlipY(value: boolean): void;
  84671. /** @hidden */
  84672. _getUnpackAlignement(): number;
  84673. /**
  84674. * Creates a dynamic texture
  84675. * @param width defines the width of the texture
  84676. * @param height defines the height of the texture
  84677. * @param generateMipMaps defines if the engine should generate the mip levels
  84678. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  84679. * @returns the dynamic texture inside an InternalTexture
  84680. */
  84681. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  84682. /**
  84683. * Update the sampling mode of a given texture
  84684. * @param samplingMode defines the required sampling mode
  84685. * @param texture defines the texture to update
  84686. */
  84687. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  84688. /**
  84689. * Update the content of a dynamic texture
  84690. * @param texture defines the texture to update
  84691. * @param canvas defines the canvas containing the source
  84692. * @param invertY defines if data must be stored with Y axis inverted
  84693. * @param premulAlpha defines if alpha is stored as premultiplied
  84694. * @param format defines the format of the data
  84695. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  84696. */
  84697. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  84698. /**
  84699. * Update a video texture
  84700. * @param texture defines the texture to update
  84701. * @param video defines the video element to use
  84702. * @param invertY defines if data must be stored with Y axis inverted
  84703. */
  84704. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  84705. /**
  84706. * Updates a depth texture Comparison Mode and Function.
  84707. * If the comparison Function is equal to 0, the mode will be set to none.
  84708. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  84709. * @param texture The texture to set the comparison function for
  84710. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  84711. */
  84712. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  84713. private _setupDepthStencilTexture;
  84714. /**
  84715. * Creates a depth stencil texture.
  84716. * This is only available in WebGL 2 or with the depth texture extension available.
  84717. * @param size The size of face edge in the texture.
  84718. * @param options The options defining the texture.
  84719. * @returns The texture
  84720. */
  84721. createDepthStencilTexture(size: number | {
  84722. width: number;
  84723. height: number;
  84724. }, options: DepthTextureCreationOptions): InternalTexture;
  84725. /**
  84726. * Creates a depth stencil texture.
  84727. * This is only available in WebGL 2 or with the depth texture extension available.
  84728. * @param size The size of face edge in the texture.
  84729. * @param options The options defining the texture.
  84730. * @returns The texture
  84731. */
  84732. private _createDepthStencilTexture;
  84733. /**
  84734. * Creates a depth stencil cube texture.
  84735. * This is only available in WebGL 2.
  84736. * @param size The size of face edge in the cube texture.
  84737. * @param options The options defining the cube texture.
  84738. * @returns The cube texture
  84739. */
  84740. private _createDepthStencilCubeTexture;
  84741. /**
  84742. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  84743. * @param renderTarget The render target to set the frame buffer for
  84744. */
  84745. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  84746. /**
  84747. * Creates a new render target texture
  84748. * @param size defines the size of the texture
  84749. * @param options defines the options used to create the texture
  84750. * @returns a new render target texture stored in an InternalTexture
  84751. */
  84752. createRenderTargetTexture(size: number | {
  84753. width: number;
  84754. height: number;
  84755. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  84756. /**
  84757. * Create a multi render target texture
  84758. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  84759. * @param size defines the size of the texture
  84760. * @param options defines the creation options
  84761. * @returns the cube texture as an InternalTexture
  84762. */
  84763. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  84764. private _setupFramebufferDepthAttachments;
  84765. /**
  84766. * Updates the sample count of a render target texture
  84767. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  84768. * @param texture defines the texture to update
  84769. * @param samples defines the sample count to set
  84770. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  84771. */
  84772. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  84773. /**
  84774. * Update the sample count for a given multiple render target texture
  84775. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  84776. * @param textures defines the textures to update
  84777. * @param samples defines the sample count to set
  84778. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  84779. */
  84780. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  84781. /** @hidden */
  84782. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  84783. /** @hidden */
  84784. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  84785. /** @hidden */
  84786. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  84787. /** @hidden */
  84788. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  84789. /**
  84790. * Creates a new render target cube texture
  84791. * @param size defines the size of the texture
  84792. * @param options defines the options used to create the texture
  84793. * @returns a new render target cube texture stored in an InternalTexture
  84794. */
  84795. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  84796. /**
  84797. * Creates a cube texture
  84798. * @param rootUrl defines the url where the files to load is located
  84799. * @param scene defines the current scene
  84800. * @param files defines the list of files to load (1 per face)
  84801. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  84802. * @param onLoad defines an optional callback raised when the texture is loaded
  84803. * @param onError defines an optional callback raised if there is an issue to load the texture
  84804. * @param format defines the format of the data
  84805. * @param forcedExtension defines the extension to use to pick the right loader
  84806. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  84807. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  84808. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  84809. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  84810. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  84811. * @returns the cube texture as an InternalTexture
  84812. */
  84813. 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;
  84814. /**
  84815. * @hidden
  84816. */
  84817. _setCubeMapTextureParams(loadMipmap: boolean): void;
  84818. /**
  84819. * Update a raw cube texture
  84820. * @param texture defines the texture to udpdate
  84821. * @param data defines the data to store
  84822. * @param format defines the data format
  84823. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84824. * @param invertY defines if data must be stored with Y axis inverted
  84825. * @param compression defines the compression used (null by default)
  84826. * @param level defines which level of the texture to update
  84827. */
  84828. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  84829. /**
  84830. * Creates a new raw cube texture
  84831. * @param data defines the array of data to use to create each face
  84832. * @param size defines the size of the textures
  84833. * @param format defines the format of the data
  84834. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84835. * @param generateMipMaps defines if the engine should generate the mip levels
  84836. * @param invertY defines if data must be stored with Y axis inverted
  84837. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84838. * @param compression defines the compression used (null by default)
  84839. * @returns the cube texture as an InternalTexture
  84840. */
  84841. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  84842. /**
  84843. * Creates a new raw cube texture from a specified url
  84844. * @param url defines the url where the data is located
  84845. * @param scene defines the current scene
  84846. * @param size defines the size of the textures
  84847. * @param format defines the format of the data
  84848. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84849. * @param noMipmap defines if the engine should avoid generating the mip levels
  84850. * @param callback defines a callback used to extract texture data from loaded data
  84851. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  84852. * @param onLoad defines a callback called when texture is loaded
  84853. * @param onError defines a callback called if there is an error
  84854. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84855. * @param invertY defines if data must be stored with Y axis inverted
  84856. * @returns the cube texture as an InternalTexture
  84857. */
  84858. 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;
  84859. /**
  84860. * Update a raw 3D texture
  84861. * @param texture defines the texture to update
  84862. * @param data defines the data to store
  84863. * @param format defines the data format
  84864. * @param invertY defines if data must be stored with Y axis inverted
  84865. * @param compression defines the used compression (can be null)
  84866. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  84867. */
  84868. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  84869. /**
  84870. * Creates a new raw 3D texture
  84871. * @param data defines the data used to create the texture
  84872. * @param width defines the width of the texture
  84873. * @param height defines the height of the texture
  84874. * @param depth defines the depth of the texture
  84875. * @param format defines the format of the texture
  84876. * @param generateMipMaps defines if the engine must generate mip levels
  84877. * @param invertY defines if data must be stored with Y axis inverted
  84878. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84879. * @param compression defines the compressed used (can be null)
  84880. * @param textureType defines the compressed used (can be null)
  84881. * @returns a new raw 3D texture (stored in an InternalTexture)
  84882. */
  84883. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  84884. private _prepareWebGLTextureContinuation;
  84885. private _prepareWebGLTexture;
  84886. private _convertRGBtoRGBATextureData;
  84887. /** @hidden */
  84888. _releaseFramebufferObjects(texture: InternalTexture): void;
  84889. /** @hidden */
  84890. _releaseTexture(texture: InternalTexture): void;
  84891. private setProgram;
  84892. private _boundUniforms;
  84893. /**
  84894. * Binds an effect to the webGL context
  84895. * @param effect defines the effect to bind
  84896. */
  84897. bindSamplers(effect: Effect): void;
  84898. private _moveBoundTextureOnTop;
  84899. private _getCorrectTextureChannel;
  84900. private _linkTrackers;
  84901. private _removeDesignatedSlot;
  84902. private _activateCurrentTexture;
  84903. /** @hidden */
  84904. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  84905. /** @hidden */
  84906. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  84907. /**
  84908. * Sets a texture to the webGL context from a postprocess
  84909. * @param channel defines the channel to use
  84910. * @param postProcess defines the source postprocess
  84911. */
  84912. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  84913. /**
  84914. * Binds the output of the passed in post process to the texture channel specified
  84915. * @param channel The channel the texture should be bound to
  84916. * @param postProcess The post process which's output should be bound
  84917. */
  84918. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  84919. /**
  84920. * Unbind all textures from the webGL context
  84921. */
  84922. unbindAllTextures(): void;
  84923. /**
  84924. * Sets a texture to the according uniform.
  84925. * @param channel The texture channel
  84926. * @param uniform The uniform to set
  84927. * @param texture The texture to apply
  84928. */
  84929. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  84930. /**
  84931. * Sets a depth stencil texture from a render target to the according uniform.
  84932. * @param channel The texture channel
  84933. * @param uniform The uniform to set
  84934. * @param texture The render target texture containing the depth stencil texture to apply
  84935. */
  84936. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  84937. private _bindSamplerUniformToChannel;
  84938. private _getTextureWrapMode;
  84939. private _setTexture;
  84940. /**
  84941. * Sets an array of texture to the webGL context
  84942. * @param channel defines the channel where the texture array must be set
  84943. * @param uniform defines the associated uniform location
  84944. * @param textures defines the array of textures to bind
  84945. */
  84946. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  84947. /** @hidden */
  84948. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  84949. private _setTextureParameterFloat;
  84950. private _setTextureParameterInteger;
  84951. /**
  84952. * Reads pixels from the current frame buffer. Please note that this function can be slow
  84953. * @param x defines the x coordinate of the rectangle where pixels must be read
  84954. * @param y defines the y coordinate of the rectangle where pixels must be read
  84955. * @param width defines the width of the rectangle where pixels must be read
  84956. * @param height defines the height of the rectangle where pixels must be read
  84957. * @returns a Uint8Array containing RGBA colors
  84958. */
  84959. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  84960. /**
  84961. * Add an externaly attached data from its key.
  84962. * This method call will fail and return false, if such key already exists.
  84963. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  84964. * @param key the unique key that identifies the data
  84965. * @param data the data object to associate to the key for this Engine instance
  84966. * @return true if no such key were already present and the data was added successfully, false otherwise
  84967. */
  84968. addExternalData<T>(key: string, data: T): boolean;
  84969. /**
  84970. * Get an externaly attached data from its key
  84971. * @param key the unique key that identifies the data
  84972. * @return the associated data, if present (can be null), or undefined if not present
  84973. */
  84974. getExternalData<T>(key: string): T;
  84975. /**
  84976. * Get an externaly attached data from its key, create it using a factory if it's not already present
  84977. * @param key the unique key that identifies the data
  84978. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  84979. * @return the associated data, can be null if the factory returned null.
  84980. */
  84981. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  84982. /**
  84983. * Remove an externaly attached data from the Engine instance
  84984. * @param key the unique key that identifies the data
  84985. * @return true if the data was successfully removed, false if it doesn't exist
  84986. */
  84987. removeExternalData(key: string): boolean;
  84988. /**
  84989. * Unbind all vertex attributes from the webGL context
  84990. */
  84991. unbindAllAttributes(): void;
  84992. /**
  84993. * 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
  84994. */
  84995. releaseEffects(): void;
  84996. /**
  84997. * Dispose and release all associated resources
  84998. */
  84999. dispose(): void;
  85000. /**
  85001. * Display the loading screen
  85002. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85003. */
  85004. displayLoadingUI(): void;
  85005. /**
  85006. * Hide the loading screen
  85007. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85008. */
  85009. hideLoadingUI(): void;
  85010. /**
  85011. * Gets the current loading screen object
  85012. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85013. */
  85014. /**
  85015. * Sets the current loading screen object
  85016. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85017. */
  85018. loadingScreen: ILoadingScreen;
  85019. /**
  85020. * Sets the current loading screen text
  85021. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85022. */
  85023. loadingUIText: string;
  85024. /**
  85025. * Sets the current loading screen background color
  85026. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85027. */
  85028. loadingUIBackgroundColor: string;
  85029. /**
  85030. * Attach a new callback raised when context lost event is fired
  85031. * @param callback defines the callback to call
  85032. */
  85033. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  85034. /**
  85035. * Attach a new callback raised when context restored event is fired
  85036. * @param callback defines the callback to call
  85037. */
  85038. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  85039. /**
  85040. * Gets the source code of the vertex shader associated with a specific webGL program
  85041. * @param program defines the program to use
  85042. * @returns a string containing the source code of the vertex shader associated with the program
  85043. */
  85044. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  85045. /**
  85046. * Gets the source code of the fragment shader associated with a specific webGL program
  85047. * @param program defines the program to use
  85048. * @returns a string containing the source code of the fragment shader associated with the program
  85049. */
  85050. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  85051. /**
  85052. * Get the current error code of the webGL context
  85053. * @returns the error code
  85054. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  85055. */
  85056. getError(): number;
  85057. /**
  85058. * Gets the current framerate
  85059. * @returns a number representing the framerate
  85060. */
  85061. getFps(): number;
  85062. /**
  85063. * Gets the time spent between current and previous frame
  85064. * @returns a number representing the delta time in ms
  85065. */
  85066. getDeltaTime(): number;
  85067. private _measureFps;
  85068. /** @hidden */
  85069. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  85070. private _canRenderToFloatFramebuffer;
  85071. private _canRenderToHalfFloatFramebuffer;
  85072. private _canRenderToFramebuffer;
  85073. /** @hidden */
  85074. _getWebGLTextureType(type: number): number;
  85075. private _getInternalFormat;
  85076. /** @hidden */
  85077. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  85078. /** @hidden */
  85079. _getRGBAMultiSampleBufferFormat(type: number): number;
  85080. /** @hidden */
  85081. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  85082. /** @hidden */
  85083. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  85084. private _partialLoadFile;
  85085. private _cascadeLoadFiles;
  85086. /**
  85087. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  85088. * @returns true if the engine can be created
  85089. * @ignorenaming
  85090. */
  85091. static isSupported(): boolean;
  85092. }
  85093. }
  85094. declare module BABYLON {
  85095. /**
  85096. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  85097. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  85098. */
  85099. export class EffectFallbacks {
  85100. private _defines;
  85101. private _currentRank;
  85102. private _maxRank;
  85103. private _mesh;
  85104. /**
  85105. * Removes the fallback from the bound mesh.
  85106. */
  85107. unBindMesh(): void;
  85108. /**
  85109. * Adds a fallback on the specified property.
  85110. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  85111. * @param define The name of the define in the shader
  85112. */
  85113. addFallback(rank: number, define: string): void;
  85114. /**
  85115. * Sets the mesh to use CPU skinning when needing to fallback.
  85116. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  85117. * @param mesh The mesh to use the fallbacks.
  85118. */
  85119. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  85120. /**
  85121. * Checks to see if more fallbacks are still availible.
  85122. */
  85123. readonly isMoreFallbacks: boolean;
  85124. /**
  85125. * Removes the defines that shoould be removed when falling back.
  85126. * @param currentDefines defines the current define statements for the shader.
  85127. * @param effect defines the current effect we try to compile
  85128. * @returns The resulting defines with defines of the current rank removed.
  85129. */
  85130. reduce(currentDefines: string, effect: Effect): string;
  85131. }
  85132. /**
  85133. * Options to be used when creating an effect.
  85134. */
  85135. export class EffectCreationOptions {
  85136. /**
  85137. * Atrributes that will be used in the shader.
  85138. */
  85139. attributes: string[];
  85140. /**
  85141. * Uniform varible names that will be set in the shader.
  85142. */
  85143. uniformsNames: string[];
  85144. /**
  85145. * Uniform buffer varible names that will be set in the shader.
  85146. */
  85147. uniformBuffersNames: string[];
  85148. /**
  85149. * Sampler texture variable names that will be set in the shader.
  85150. */
  85151. samplers: string[];
  85152. /**
  85153. * Define statements that will be set in the shader.
  85154. */
  85155. defines: any;
  85156. /**
  85157. * Possible fallbacks for this effect to improve performance when needed.
  85158. */
  85159. fallbacks: Nullable<EffectFallbacks>;
  85160. /**
  85161. * Callback that will be called when the shader is compiled.
  85162. */
  85163. onCompiled: Nullable<(effect: Effect) => void>;
  85164. /**
  85165. * Callback that will be called if an error occurs during shader compilation.
  85166. */
  85167. onError: Nullable<(effect: Effect, errors: string) => void>;
  85168. /**
  85169. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  85170. */
  85171. indexParameters: any;
  85172. /**
  85173. * Max number of lights that can be used in the shader.
  85174. */
  85175. maxSimultaneousLights: number;
  85176. /**
  85177. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  85178. */
  85179. transformFeedbackVaryings: Nullable<string[]>;
  85180. }
  85181. /**
  85182. * Effect containing vertex and fragment shader that can be executed on an object.
  85183. */
  85184. export class Effect {
  85185. /**
  85186. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  85187. */
  85188. static ShadersRepository: string;
  85189. /**
  85190. * Name of the effect.
  85191. */
  85192. name: any;
  85193. /**
  85194. * String container all the define statements that should be set on the shader.
  85195. */
  85196. defines: string;
  85197. /**
  85198. * Callback that will be called when the shader is compiled.
  85199. */
  85200. onCompiled: Nullable<(effect: Effect) => void>;
  85201. /**
  85202. * Callback that will be called if an error occurs during shader compilation.
  85203. */
  85204. onError: Nullable<(effect: Effect, errors: string) => void>;
  85205. /**
  85206. * Callback that will be called when effect is bound.
  85207. */
  85208. onBind: Nullable<(effect: Effect) => void>;
  85209. /**
  85210. * Unique ID of the effect.
  85211. */
  85212. uniqueId: number;
  85213. /**
  85214. * Observable that will be called when the shader is compiled.
  85215. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  85216. */
  85217. onCompileObservable: Observable<Effect>;
  85218. /**
  85219. * Observable that will be called if an error occurs during shader compilation.
  85220. */
  85221. onErrorObservable: Observable<Effect>;
  85222. /** @hidden */
  85223. _onBindObservable: Nullable<Observable<Effect>>;
  85224. /**
  85225. * Observable that will be called when effect is bound.
  85226. */
  85227. readonly onBindObservable: Observable<Effect>;
  85228. /** @hidden */
  85229. _bonesComputationForcedToCPU: boolean;
  85230. private static _uniqueIdSeed;
  85231. private _engine;
  85232. private _uniformBuffersNames;
  85233. private _uniformsNames;
  85234. private _samplers;
  85235. private _isReady;
  85236. private _compilationError;
  85237. private _attributesNames;
  85238. private _attributes;
  85239. private _uniforms;
  85240. /**
  85241. * Key for the effect.
  85242. * @hidden
  85243. */
  85244. _key: string;
  85245. private _indexParameters;
  85246. private _fallbacks;
  85247. private _vertexSourceCode;
  85248. private _fragmentSourceCode;
  85249. private _vertexSourceCodeOverride;
  85250. private _fragmentSourceCodeOverride;
  85251. private _transformFeedbackVaryings;
  85252. /**
  85253. * Compiled shader to webGL program.
  85254. * @hidden
  85255. */
  85256. _program: WebGLProgram;
  85257. private _valueCache;
  85258. private static _baseCache;
  85259. /**
  85260. * Instantiates an effect.
  85261. * An effect can be used to create/manage/execute vertex and fragment shaders.
  85262. * @param baseName Name of the effect.
  85263. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  85264. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  85265. * @param samplers List of sampler variables that will be passed to the shader.
  85266. * @param engine Engine to be used to render the effect
  85267. * @param defines Define statements to be added to the shader.
  85268. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  85269. * @param onCompiled Callback that will be called when the shader is compiled.
  85270. * @param onError Callback that will be called if an error occurs during shader compilation.
  85271. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  85272. */
  85273. 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);
  85274. /**
  85275. * Unique key for this effect
  85276. */
  85277. readonly key: string;
  85278. /**
  85279. * If the effect has been compiled and prepared.
  85280. * @returns if the effect is compiled and prepared.
  85281. */
  85282. isReady(): boolean;
  85283. /**
  85284. * The engine the effect was initialized with.
  85285. * @returns the engine.
  85286. */
  85287. getEngine(): Engine;
  85288. /**
  85289. * The compiled webGL program for the effect
  85290. * @returns the webGL program.
  85291. */
  85292. getProgram(): WebGLProgram;
  85293. /**
  85294. * The set of names of attribute variables for the shader.
  85295. * @returns An array of attribute names.
  85296. */
  85297. getAttributesNames(): string[];
  85298. /**
  85299. * Returns the attribute at the given index.
  85300. * @param index The index of the attribute.
  85301. * @returns The location of the attribute.
  85302. */
  85303. getAttributeLocation(index: number): number;
  85304. /**
  85305. * Returns the attribute based on the name of the variable.
  85306. * @param name of the attribute to look up.
  85307. * @returns the attribute location.
  85308. */
  85309. getAttributeLocationByName(name: string): number;
  85310. /**
  85311. * The number of attributes.
  85312. * @returns the numnber of attributes.
  85313. */
  85314. getAttributesCount(): number;
  85315. /**
  85316. * Gets the index of a uniform variable.
  85317. * @param uniformName of the uniform to look up.
  85318. * @returns the index.
  85319. */
  85320. getUniformIndex(uniformName: string): number;
  85321. /**
  85322. * Returns the attribute based on the name of the variable.
  85323. * @param uniformName of the uniform to look up.
  85324. * @returns the location of the uniform.
  85325. */
  85326. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  85327. /**
  85328. * Returns an array of sampler variable names
  85329. * @returns The array of sampler variable neames.
  85330. */
  85331. getSamplers(): string[];
  85332. /**
  85333. * The error from the last compilation.
  85334. * @returns the error string.
  85335. */
  85336. getCompilationError(): string;
  85337. /**
  85338. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  85339. * @param func The callback to be used.
  85340. */
  85341. executeWhenCompiled(func: (effect: Effect) => void): void;
  85342. private _checkIsReady;
  85343. /** @hidden */
  85344. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  85345. /** @hidden */
  85346. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  85347. /** @hidden */
  85348. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  85349. private _processShaderConversion;
  85350. private _processIncludes;
  85351. private _processPrecision;
  85352. /**
  85353. * Recompiles the webGL program
  85354. * @param vertexSourceCode The source code for the vertex shader.
  85355. * @param fragmentSourceCode The source code for the fragment shader.
  85356. * @param onCompiled Callback called when completed.
  85357. * @param onError Callback called on error.
  85358. * @hidden
  85359. */
  85360. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  85361. /**
  85362. * Gets the uniform locations of the the specified variable names
  85363. * @param names THe names of the variables to lookup.
  85364. * @returns Array of locations in the same order as variable names.
  85365. */
  85366. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  85367. /**
  85368. * Prepares the effect
  85369. * @hidden
  85370. */
  85371. _prepareEffect(): void;
  85372. /**
  85373. * Checks if the effect is supported. (Must be called after compilation)
  85374. */
  85375. readonly isSupported: boolean;
  85376. /**
  85377. * Binds a texture to the engine to be used as output of the shader.
  85378. * @param channel Name of the output variable.
  85379. * @param texture Texture to bind.
  85380. * @hidden
  85381. */
  85382. _bindTexture(channel: string, texture: InternalTexture): void;
  85383. /**
  85384. * Sets a texture on the engine to be used in the shader.
  85385. * @param channel Name of the sampler variable.
  85386. * @param texture Texture to set.
  85387. */
  85388. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  85389. /**
  85390. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  85391. * @param channel Name of the sampler variable.
  85392. * @param texture Texture to set.
  85393. */
  85394. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  85395. /**
  85396. * Sets an array of textures on the engine to be used in the shader.
  85397. * @param channel Name of the variable.
  85398. * @param textures Textures to set.
  85399. */
  85400. setTextureArray(channel: string, textures: BaseTexture[]): void;
  85401. /**
  85402. * 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)
  85403. * @param channel Name of the sampler variable.
  85404. * @param postProcess Post process to get the input texture from.
  85405. */
  85406. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  85407. /**
  85408. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  85409. * 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)
  85410. * @param channel Name of the sampler variable.
  85411. * @param postProcess Post process to get the output texture from.
  85412. */
  85413. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  85414. /** @hidden */
  85415. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  85416. /** @hidden */
  85417. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  85418. /** @hidden */
  85419. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  85420. /** @hidden */
  85421. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  85422. /**
  85423. * Binds a buffer to a uniform.
  85424. * @param buffer Buffer to bind.
  85425. * @param name Name of the uniform variable to bind to.
  85426. */
  85427. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  85428. /**
  85429. * Binds block to a uniform.
  85430. * @param blockName Name of the block to bind.
  85431. * @param index Index to bind.
  85432. */
  85433. bindUniformBlock(blockName: string, index: number): void;
  85434. /**
  85435. * Sets an interger value on a uniform variable.
  85436. * @param uniformName Name of the variable.
  85437. * @param value Value to be set.
  85438. * @returns this effect.
  85439. */
  85440. setInt(uniformName: string, value: number): Effect;
  85441. /**
  85442. * Sets an int array on a uniform variable.
  85443. * @param uniformName Name of the variable.
  85444. * @param array array to be set.
  85445. * @returns this effect.
  85446. */
  85447. setIntArray(uniformName: string, array: Int32Array): Effect;
  85448. /**
  85449. * 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)
  85450. * @param uniformName Name of the variable.
  85451. * @param array array to be set.
  85452. * @returns this effect.
  85453. */
  85454. setIntArray2(uniformName: string, array: Int32Array): Effect;
  85455. /**
  85456. * 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)
  85457. * @param uniformName Name of the variable.
  85458. * @param array array to be set.
  85459. * @returns this effect.
  85460. */
  85461. setIntArray3(uniformName: string, array: Int32Array): Effect;
  85462. /**
  85463. * 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)
  85464. * @param uniformName Name of the variable.
  85465. * @param array array to be set.
  85466. * @returns this effect.
  85467. */
  85468. setIntArray4(uniformName: string, array: Int32Array): Effect;
  85469. /**
  85470. * Sets an float array on a uniform variable.
  85471. * @param uniformName Name of the variable.
  85472. * @param array array to be set.
  85473. * @returns this effect.
  85474. */
  85475. setFloatArray(uniformName: string, array: Float32Array): Effect;
  85476. /**
  85477. * 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)
  85478. * @param uniformName Name of the variable.
  85479. * @param array array to be set.
  85480. * @returns this effect.
  85481. */
  85482. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  85483. /**
  85484. * 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)
  85485. * @param uniformName Name of the variable.
  85486. * @param array array to be set.
  85487. * @returns this effect.
  85488. */
  85489. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  85490. /**
  85491. * 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)
  85492. * @param uniformName Name of the variable.
  85493. * @param array array to be set.
  85494. * @returns this effect.
  85495. */
  85496. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  85497. /**
  85498. * Sets an array on a uniform variable.
  85499. * @param uniformName Name of the variable.
  85500. * @param array array to be set.
  85501. * @returns this effect.
  85502. */
  85503. setArray(uniformName: string, array: number[]): Effect;
  85504. /**
  85505. * 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)
  85506. * @param uniformName Name of the variable.
  85507. * @param array array to be set.
  85508. * @returns this effect.
  85509. */
  85510. setArray2(uniformName: string, array: number[]): Effect;
  85511. /**
  85512. * 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)
  85513. * @param uniformName Name of the variable.
  85514. * @param array array to be set.
  85515. * @returns this effect.
  85516. */
  85517. setArray3(uniformName: string, array: number[]): Effect;
  85518. /**
  85519. * 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)
  85520. * @param uniformName Name of the variable.
  85521. * @param array array to be set.
  85522. * @returns this effect.
  85523. */
  85524. setArray4(uniformName: string, array: number[]): Effect;
  85525. /**
  85526. * Sets matrices on a uniform variable.
  85527. * @param uniformName Name of the variable.
  85528. * @param matrices matrices to be set.
  85529. * @returns this effect.
  85530. */
  85531. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  85532. /**
  85533. * Sets matrix on a uniform variable.
  85534. * @param uniformName Name of the variable.
  85535. * @param matrix matrix to be set.
  85536. * @returns this effect.
  85537. */
  85538. setMatrix(uniformName: string, matrix: Matrix): Effect;
  85539. /**
  85540. * 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)
  85541. * @param uniformName Name of the variable.
  85542. * @param matrix matrix to be set.
  85543. * @returns this effect.
  85544. */
  85545. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  85546. /**
  85547. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  85548. * @param uniformName Name of the variable.
  85549. * @param matrix matrix to be set.
  85550. * @returns this effect.
  85551. */
  85552. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  85553. /**
  85554. * Sets a float on a uniform variable.
  85555. * @param uniformName Name of the variable.
  85556. * @param value value to be set.
  85557. * @returns this effect.
  85558. */
  85559. setFloat(uniformName: string, value: number): Effect;
  85560. /**
  85561. * Sets a boolean on a uniform variable.
  85562. * @param uniformName Name of the variable.
  85563. * @param bool value to be set.
  85564. * @returns this effect.
  85565. */
  85566. setBool(uniformName: string, bool: boolean): Effect;
  85567. /**
  85568. * Sets a Vector2 on a uniform variable.
  85569. * @param uniformName Name of the variable.
  85570. * @param vector2 vector2 to be set.
  85571. * @returns this effect.
  85572. */
  85573. setVector2(uniformName: string, vector2: Vector2): Effect;
  85574. /**
  85575. * Sets a float2 on a uniform variable.
  85576. * @param uniformName Name of the variable.
  85577. * @param x First float in float2.
  85578. * @param y Second float in float2.
  85579. * @returns this effect.
  85580. */
  85581. setFloat2(uniformName: string, x: number, y: number): Effect;
  85582. /**
  85583. * Sets a Vector3 on a uniform variable.
  85584. * @param uniformName Name of the variable.
  85585. * @param vector3 Value to be set.
  85586. * @returns this effect.
  85587. */
  85588. setVector3(uniformName: string, vector3: Vector3): Effect;
  85589. /**
  85590. * Sets a float3 on a uniform variable.
  85591. * @param uniformName Name of the variable.
  85592. * @param x First float in float3.
  85593. * @param y Second float in float3.
  85594. * @param z Third float in float3.
  85595. * @returns this effect.
  85596. */
  85597. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  85598. /**
  85599. * Sets a Vector4 on a uniform variable.
  85600. * @param uniformName Name of the variable.
  85601. * @param vector4 Value to be set.
  85602. * @returns this effect.
  85603. */
  85604. setVector4(uniformName: string, vector4: Vector4): Effect;
  85605. /**
  85606. * Sets a float4 on a uniform variable.
  85607. * @param uniformName Name of the variable.
  85608. * @param x First float in float4.
  85609. * @param y Second float in float4.
  85610. * @param z Third float in float4.
  85611. * @param w Fourth float in float4.
  85612. * @returns this effect.
  85613. */
  85614. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  85615. /**
  85616. * Sets a Color3 on a uniform variable.
  85617. * @param uniformName Name of the variable.
  85618. * @param color3 Value to be set.
  85619. * @returns this effect.
  85620. */
  85621. setColor3(uniformName: string, color3: Color3): Effect;
  85622. /**
  85623. * Sets a Color4 on a uniform variable.
  85624. * @param uniformName Name of the variable.
  85625. * @param color3 Value to be set.
  85626. * @param alpha Alpha value to be set.
  85627. * @returns this effect.
  85628. */
  85629. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  85630. /**
  85631. * Sets a Color4 on a uniform variable
  85632. * @param uniformName defines the name of the variable
  85633. * @param color4 defines the value to be set
  85634. * @returns this effect.
  85635. */
  85636. setDirectColor4(uniformName: string, color4: Color4): Effect;
  85637. /**
  85638. * This function will add a new shader to the shader store
  85639. * @param name the name of the shader
  85640. * @param pixelShader optional pixel shader content
  85641. * @param vertexShader optional vertex shader content
  85642. */
  85643. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  85644. /**
  85645. * Store of each shader (The can be looked up using effect.key)
  85646. */
  85647. static ShadersStore: {
  85648. [key: string]: string;
  85649. };
  85650. /**
  85651. * Store of each included file for a shader (The can be looked up using effect.key)
  85652. */
  85653. static IncludesShadersStore: {
  85654. [key: string]: string;
  85655. };
  85656. /**
  85657. * Resets the cache of effects.
  85658. */
  85659. static ResetCache(): void;
  85660. }
  85661. }
  85662. declare module BABYLON {
  85663. /**
  85664. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  85665. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  85666. * 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;
  85667. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  85668. */
  85669. export class ColorCurves {
  85670. private _dirty;
  85671. private _tempColor;
  85672. private _globalCurve;
  85673. private _highlightsCurve;
  85674. private _midtonesCurve;
  85675. private _shadowsCurve;
  85676. private _positiveCurve;
  85677. private _negativeCurve;
  85678. private _globalHue;
  85679. private _globalDensity;
  85680. private _globalSaturation;
  85681. private _globalExposure;
  85682. /**
  85683. * Gets the global Hue value.
  85684. * 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).
  85685. */
  85686. /**
  85687. * Sets the global Hue value.
  85688. * 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).
  85689. */
  85690. globalHue: number;
  85691. /**
  85692. * Gets the global Density value.
  85693. * 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.
  85694. * Values less than zero provide a filter of opposite hue.
  85695. */
  85696. /**
  85697. * Sets the global Density value.
  85698. * 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.
  85699. * Values less than zero provide a filter of opposite hue.
  85700. */
  85701. globalDensity: number;
  85702. /**
  85703. * Gets the global Saturation value.
  85704. * 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.
  85705. */
  85706. /**
  85707. * Sets the global Saturation value.
  85708. * 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.
  85709. */
  85710. globalSaturation: number;
  85711. /**
  85712. * Gets the global Exposure value.
  85713. * 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.
  85714. */
  85715. /**
  85716. * Sets the global Exposure value.
  85717. * 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.
  85718. */
  85719. globalExposure: number;
  85720. private _highlightsHue;
  85721. private _highlightsDensity;
  85722. private _highlightsSaturation;
  85723. private _highlightsExposure;
  85724. /**
  85725. * Gets the highlights Hue value.
  85726. * 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).
  85727. */
  85728. /**
  85729. * Sets the highlights Hue value.
  85730. * 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).
  85731. */
  85732. highlightsHue: number;
  85733. /**
  85734. * Gets the highlights Density value.
  85735. * 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.
  85736. * Values less than zero provide a filter of opposite hue.
  85737. */
  85738. /**
  85739. * Sets the highlights Density value.
  85740. * 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.
  85741. * Values less than zero provide a filter of opposite hue.
  85742. */
  85743. highlightsDensity: number;
  85744. /**
  85745. * Gets the highlights Saturation value.
  85746. * 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.
  85747. */
  85748. /**
  85749. * Sets the highlights Saturation value.
  85750. * 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.
  85751. */
  85752. highlightsSaturation: number;
  85753. /**
  85754. * Gets the highlights Exposure value.
  85755. * 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.
  85756. */
  85757. /**
  85758. * Sets the highlights Exposure value.
  85759. * 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.
  85760. */
  85761. highlightsExposure: number;
  85762. private _midtonesHue;
  85763. private _midtonesDensity;
  85764. private _midtonesSaturation;
  85765. private _midtonesExposure;
  85766. /**
  85767. * Gets the midtones Hue value.
  85768. * 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).
  85769. */
  85770. /**
  85771. * Sets the midtones Hue value.
  85772. * 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).
  85773. */
  85774. midtonesHue: number;
  85775. /**
  85776. * Gets the midtones Density value.
  85777. * 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.
  85778. * Values less than zero provide a filter of opposite hue.
  85779. */
  85780. /**
  85781. * Sets the midtones Density value.
  85782. * 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.
  85783. * Values less than zero provide a filter of opposite hue.
  85784. */
  85785. midtonesDensity: number;
  85786. /**
  85787. * Gets the midtones Saturation value.
  85788. * 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.
  85789. */
  85790. /**
  85791. * Sets the midtones Saturation value.
  85792. * 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.
  85793. */
  85794. midtonesSaturation: number;
  85795. /**
  85796. * Gets the midtones Exposure value.
  85797. * 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.
  85798. */
  85799. /**
  85800. * Sets the midtones Exposure value.
  85801. * 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.
  85802. */
  85803. midtonesExposure: number;
  85804. private _shadowsHue;
  85805. private _shadowsDensity;
  85806. private _shadowsSaturation;
  85807. private _shadowsExposure;
  85808. /**
  85809. * Gets the shadows Hue value.
  85810. * 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).
  85811. */
  85812. /**
  85813. * Sets the shadows Hue value.
  85814. * 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).
  85815. */
  85816. shadowsHue: number;
  85817. /**
  85818. * Gets the shadows Density value.
  85819. * 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.
  85820. * Values less than zero provide a filter of opposite hue.
  85821. */
  85822. /**
  85823. * Sets the shadows Density value.
  85824. * 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.
  85825. * Values less than zero provide a filter of opposite hue.
  85826. */
  85827. shadowsDensity: number;
  85828. /**
  85829. * Gets the shadows Saturation value.
  85830. * 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.
  85831. */
  85832. /**
  85833. * Sets the shadows Saturation value.
  85834. * 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.
  85835. */
  85836. shadowsSaturation: number;
  85837. /**
  85838. * Gets the shadows Exposure value.
  85839. * 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.
  85840. */
  85841. /**
  85842. * Sets the shadows Exposure value.
  85843. * 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.
  85844. */
  85845. shadowsExposure: number;
  85846. /**
  85847. * Returns the class name
  85848. * @returns The class name
  85849. */
  85850. getClassName(): string;
  85851. /**
  85852. * Binds the color curves to the shader.
  85853. * @param colorCurves The color curve to bind
  85854. * @param effect The effect to bind to
  85855. * @param positiveUniform The positive uniform shader parameter
  85856. * @param neutralUniform The neutral uniform shader parameter
  85857. * @param negativeUniform The negative uniform shader parameter
  85858. */
  85859. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  85860. /**
  85861. * Prepare the list of uniforms associated with the ColorCurves effects.
  85862. * @param uniformsList The list of uniforms used in the effect
  85863. */
  85864. static PrepareUniforms(uniformsList: string[]): void;
  85865. /**
  85866. * Returns color grading data based on a hue, density, saturation and exposure value.
  85867. * @param filterHue The hue of the color filter.
  85868. * @param filterDensity The density of the color filter.
  85869. * @param saturation The saturation.
  85870. * @param exposure The exposure.
  85871. * @param result The result data container.
  85872. */
  85873. private getColorGradingDataToRef;
  85874. /**
  85875. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  85876. * @param value The input slider value in range [-100,100].
  85877. * @returns Adjusted value.
  85878. */
  85879. private static applyColorGradingSliderNonlinear;
  85880. /**
  85881. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  85882. * @param hue The hue (H) input.
  85883. * @param saturation The saturation (S) input.
  85884. * @param brightness The brightness (B) input.
  85885. * @result An RGBA color represented as Vector4.
  85886. */
  85887. private static fromHSBToRef;
  85888. /**
  85889. * Returns a value clamped between min and max
  85890. * @param value The value to clamp
  85891. * @param min The minimum of value
  85892. * @param max The maximum of value
  85893. * @returns The clamped value.
  85894. */
  85895. private static clamp;
  85896. /**
  85897. * Clones the current color curve instance.
  85898. * @return The cloned curves
  85899. */
  85900. clone(): ColorCurves;
  85901. /**
  85902. * Serializes the current color curve instance to a json representation.
  85903. * @return a JSON representation
  85904. */
  85905. serialize(): any;
  85906. /**
  85907. * Parses the color curve from a json representation.
  85908. * @param source the JSON source to parse
  85909. * @return The parsed curves
  85910. */
  85911. static Parse(source: any): ColorCurves;
  85912. }
  85913. }
  85914. declare module BABYLON {
  85915. /**
  85916. * Interface to follow in your material defines to integrate easily the
  85917. * Image proccessing functions.
  85918. * @hidden
  85919. */
  85920. export interface IImageProcessingConfigurationDefines {
  85921. IMAGEPROCESSING: boolean;
  85922. VIGNETTE: boolean;
  85923. VIGNETTEBLENDMODEMULTIPLY: boolean;
  85924. VIGNETTEBLENDMODEOPAQUE: boolean;
  85925. TONEMAPPING: boolean;
  85926. TONEMAPPING_ACES: boolean;
  85927. CONTRAST: boolean;
  85928. EXPOSURE: boolean;
  85929. COLORCURVES: boolean;
  85930. COLORGRADING: boolean;
  85931. COLORGRADING3D: boolean;
  85932. SAMPLER3DGREENDEPTH: boolean;
  85933. SAMPLER3DBGRMAP: boolean;
  85934. IMAGEPROCESSINGPOSTPROCESS: boolean;
  85935. }
  85936. /**
  85937. * @hidden
  85938. */
  85939. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  85940. IMAGEPROCESSING: boolean;
  85941. VIGNETTE: boolean;
  85942. VIGNETTEBLENDMODEMULTIPLY: boolean;
  85943. VIGNETTEBLENDMODEOPAQUE: boolean;
  85944. TONEMAPPING: boolean;
  85945. TONEMAPPING_ACES: boolean;
  85946. CONTRAST: boolean;
  85947. COLORCURVES: boolean;
  85948. COLORGRADING: boolean;
  85949. COLORGRADING3D: boolean;
  85950. SAMPLER3DGREENDEPTH: boolean;
  85951. SAMPLER3DBGRMAP: boolean;
  85952. IMAGEPROCESSINGPOSTPROCESS: boolean;
  85953. EXPOSURE: boolean;
  85954. constructor();
  85955. }
  85956. /**
  85957. * This groups together the common properties used for image processing either in direct forward pass
  85958. * or through post processing effect depending on the use of the image processing pipeline in your scene
  85959. * or not.
  85960. */
  85961. export class ImageProcessingConfiguration {
  85962. /**
  85963. * Default tone mapping applied in BabylonJS.
  85964. */
  85965. static readonly TONEMAPPING_STANDARD: number;
  85966. /**
  85967. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  85968. * to other engines rendering to increase portability.
  85969. */
  85970. static readonly TONEMAPPING_ACES: number;
  85971. /**
  85972. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  85973. */
  85974. colorCurves: Nullable<ColorCurves>;
  85975. private _colorCurvesEnabled;
  85976. /**
  85977. * Gets wether the color curves effect is enabled.
  85978. */
  85979. /**
  85980. * Sets wether the color curves effect is enabled.
  85981. */
  85982. colorCurvesEnabled: boolean;
  85983. private _colorGradingTexture;
  85984. /**
  85985. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  85986. */
  85987. /**
  85988. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  85989. */
  85990. colorGradingTexture: Nullable<BaseTexture>;
  85991. private _colorGradingEnabled;
  85992. /**
  85993. * Gets wether the color grading effect is enabled.
  85994. */
  85995. /**
  85996. * Sets wether the color grading effect is enabled.
  85997. */
  85998. colorGradingEnabled: boolean;
  85999. private _colorGradingWithGreenDepth;
  86000. /**
  86001. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  86002. */
  86003. /**
  86004. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  86005. */
  86006. colorGradingWithGreenDepth: boolean;
  86007. private _colorGradingBGR;
  86008. /**
  86009. * Gets wether the color grading texture contains BGR values.
  86010. */
  86011. /**
  86012. * Sets wether the color grading texture contains BGR values.
  86013. */
  86014. colorGradingBGR: boolean;
  86015. /** @hidden */
  86016. _exposure: number;
  86017. /**
  86018. * Gets the Exposure used in the effect.
  86019. */
  86020. /**
  86021. * Sets the Exposure used in the effect.
  86022. */
  86023. exposure: number;
  86024. private _toneMappingEnabled;
  86025. /**
  86026. * Gets wether the tone mapping effect is enabled.
  86027. */
  86028. /**
  86029. * Sets wether the tone mapping effect is enabled.
  86030. */
  86031. toneMappingEnabled: boolean;
  86032. private _toneMappingType;
  86033. /**
  86034. * Gets the type of tone mapping effect.
  86035. */
  86036. /**
  86037. * Sets the type of tone mapping effect used in BabylonJS.
  86038. */
  86039. toneMappingType: number;
  86040. protected _contrast: number;
  86041. /**
  86042. * Gets the contrast used in the effect.
  86043. */
  86044. /**
  86045. * Sets the contrast used in the effect.
  86046. */
  86047. contrast: number;
  86048. /**
  86049. * Vignette stretch size.
  86050. */
  86051. vignetteStretch: number;
  86052. /**
  86053. * Vignette centre X Offset.
  86054. */
  86055. vignetteCentreX: number;
  86056. /**
  86057. * Vignette centre Y Offset.
  86058. */
  86059. vignetteCentreY: number;
  86060. /**
  86061. * Vignette weight or intensity of the vignette effect.
  86062. */
  86063. vignetteWeight: number;
  86064. /**
  86065. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  86066. * if vignetteEnabled is set to true.
  86067. */
  86068. vignetteColor: Color4;
  86069. /**
  86070. * Camera field of view used by the Vignette effect.
  86071. */
  86072. vignetteCameraFov: number;
  86073. private _vignetteBlendMode;
  86074. /**
  86075. * Gets the vignette blend mode allowing different kind of effect.
  86076. */
  86077. /**
  86078. * Sets the vignette blend mode allowing different kind of effect.
  86079. */
  86080. vignetteBlendMode: number;
  86081. private _vignetteEnabled;
  86082. /**
  86083. * Gets wether the vignette effect is enabled.
  86084. */
  86085. /**
  86086. * Sets wether the vignette effect is enabled.
  86087. */
  86088. vignetteEnabled: boolean;
  86089. private _applyByPostProcess;
  86090. /**
  86091. * Gets wether the image processing is applied through a post process or not.
  86092. */
  86093. /**
  86094. * Sets wether the image processing is applied through a post process or not.
  86095. */
  86096. applyByPostProcess: boolean;
  86097. private _isEnabled;
  86098. /**
  86099. * Gets wether the image processing is enabled or not.
  86100. */
  86101. /**
  86102. * Sets wether the image processing is enabled or not.
  86103. */
  86104. isEnabled: boolean;
  86105. /**
  86106. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  86107. */
  86108. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  86109. /**
  86110. * Method called each time the image processing information changes requires to recompile the effect.
  86111. */
  86112. protected _updateParameters(): void;
  86113. /**
  86114. * Gets the current class name.
  86115. * @return "ImageProcessingConfiguration"
  86116. */
  86117. getClassName(): string;
  86118. /**
  86119. * Prepare the list of uniforms associated with the Image Processing effects.
  86120. * @param uniforms The list of uniforms used in the effect
  86121. * @param defines the list of defines currently in use
  86122. */
  86123. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  86124. /**
  86125. * Prepare the list of samplers associated with the Image Processing effects.
  86126. * @param samplersList The list of uniforms used in the effect
  86127. * @param defines the list of defines currently in use
  86128. */
  86129. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  86130. /**
  86131. * Prepare the list of defines associated to the shader.
  86132. * @param defines the list of defines to complete
  86133. * @param forPostProcess Define if we are currently in post process mode or not
  86134. */
  86135. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  86136. /**
  86137. * Returns true if all the image processing information are ready.
  86138. * @returns True if ready, otherwise, false
  86139. */
  86140. isReady(): boolean;
  86141. /**
  86142. * Binds the image processing to the shader.
  86143. * @param effect The effect to bind to
  86144. * @param aspectRatio Define the current aspect ratio of the effect
  86145. */
  86146. bind(effect: Effect, aspectRatio?: number): void;
  86147. /**
  86148. * Clones the current image processing instance.
  86149. * @return The cloned image processing
  86150. */
  86151. clone(): ImageProcessingConfiguration;
  86152. /**
  86153. * Serializes the current image processing instance to a json representation.
  86154. * @return a JSON representation
  86155. */
  86156. serialize(): any;
  86157. /**
  86158. * Parses the image processing from a json representation.
  86159. * @param source the JSON source to parse
  86160. * @return The parsed image processing
  86161. */
  86162. static Parse(source: any): ImageProcessingConfiguration;
  86163. private static _VIGNETTEMODE_MULTIPLY;
  86164. private static _VIGNETTEMODE_OPAQUE;
  86165. /**
  86166. * Used to apply the vignette as a mix with the pixel color.
  86167. */
  86168. static readonly VIGNETTEMODE_MULTIPLY: number;
  86169. /**
  86170. * Used to apply the vignette as a replacement of the pixel color.
  86171. */
  86172. static readonly VIGNETTEMODE_OPAQUE: number;
  86173. }
  86174. }
  86175. declare module BABYLON {
  86176. /**
  86177. * This represents all the required information to add a fresnel effect on a material:
  86178. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  86179. */
  86180. export class FresnelParameters {
  86181. private _isEnabled;
  86182. /**
  86183. * Define if the fresnel effect is enable or not.
  86184. */
  86185. isEnabled: boolean;
  86186. /**
  86187. * Define the color used on edges (grazing angle)
  86188. */
  86189. leftColor: Color3;
  86190. /**
  86191. * Define the color used on center
  86192. */
  86193. rightColor: Color3;
  86194. /**
  86195. * Define bias applied to computed fresnel term
  86196. */
  86197. bias: number;
  86198. /**
  86199. * Defined the power exponent applied to fresnel term
  86200. */
  86201. power: number;
  86202. /**
  86203. * Clones the current fresnel and its valuues
  86204. * @returns a clone fresnel configuration
  86205. */
  86206. clone(): FresnelParameters;
  86207. /**
  86208. * Serializes the current fresnel parameters to a JSON representation.
  86209. * @return the JSON serialization
  86210. */
  86211. serialize(): any;
  86212. /**
  86213. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  86214. * @param parsedFresnelParameters Define the JSON representation
  86215. * @returns the parsed parameters
  86216. */
  86217. static Parse(parsedFresnelParameters: any): FresnelParameters;
  86218. }
  86219. }
  86220. declare module BABYLON {
  86221. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  86222. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86223. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86224. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86225. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86226. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86227. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86228. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86229. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86230. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86231. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86232. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86233. /**
  86234. * Decorator used to define property that can be serialized as reference to a camera
  86235. * @param sourceName defines the name of the property to decorate
  86236. */
  86237. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86238. /**
  86239. * Class used to help serialization objects
  86240. */
  86241. export class SerializationHelper {
  86242. /** hidden */
  86243. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  86244. /** hidden */
  86245. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  86246. /** hidden */
  86247. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  86248. /** hidden */
  86249. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  86250. /**
  86251. * Appends the serialized animations from the source animations
  86252. * @param source Source containing the animations
  86253. * @param destination Target to store the animations
  86254. */
  86255. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  86256. /**
  86257. * Static function used to serialized a specific entity
  86258. * @param entity defines the entity to serialize
  86259. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  86260. * @returns a JSON compatible object representing the serialization of the entity
  86261. */
  86262. static Serialize<T>(entity: T, serializationObject?: any): any;
  86263. /**
  86264. * Creates a new entity from a serialization data object
  86265. * @param creationFunction defines a function used to instanciated the new entity
  86266. * @param source defines the source serialization data
  86267. * @param scene defines the hosting scene
  86268. * @param rootUrl defines the root url for resources
  86269. * @returns a new entity
  86270. */
  86271. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  86272. /**
  86273. * Clones an object
  86274. * @param creationFunction defines the function used to instanciate the new object
  86275. * @param source defines the source object
  86276. * @returns the cloned object
  86277. */
  86278. static Clone<T>(creationFunction: () => T, source: T): T;
  86279. /**
  86280. * Instanciates a new object based on a source one (some data will be shared between both object)
  86281. * @param creationFunction defines the function used to instanciate the new object
  86282. * @param source defines the source object
  86283. * @returns the new object
  86284. */
  86285. static Instanciate<T>(creationFunction: () => T, source: T): T;
  86286. }
  86287. }
  86288. declare module BABYLON {
  86289. /**
  86290. * This is the base class of all the camera used in the application.
  86291. * @see http://doc.babylonjs.com/features/cameras
  86292. */
  86293. export class Camera extends Node {
  86294. /** @hidden */
  86295. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  86296. /**
  86297. * This is the default projection mode used by the cameras.
  86298. * It helps recreating a feeling of perspective and better appreciate depth.
  86299. * This is the best way to simulate real life cameras.
  86300. */
  86301. static readonly PERSPECTIVE_CAMERA: number;
  86302. /**
  86303. * This helps creating camera with an orthographic mode.
  86304. * 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.
  86305. */
  86306. static readonly ORTHOGRAPHIC_CAMERA: number;
  86307. /**
  86308. * This is the default FOV mode for perspective cameras.
  86309. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  86310. */
  86311. static readonly FOVMODE_VERTICAL_FIXED: number;
  86312. /**
  86313. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  86314. */
  86315. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  86316. /**
  86317. * This specifies ther is no need for a camera rig.
  86318. * Basically only one eye is rendered corresponding to the camera.
  86319. */
  86320. static readonly RIG_MODE_NONE: number;
  86321. /**
  86322. * Simulates a camera Rig with one blue eye and one red eye.
  86323. * This can be use with 3d blue and red glasses.
  86324. */
  86325. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  86326. /**
  86327. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  86328. */
  86329. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  86330. /**
  86331. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  86332. */
  86333. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  86334. /**
  86335. * Defines that both eyes of the camera will be rendered over under each other.
  86336. */
  86337. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  86338. /**
  86339. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  86340. */
  86341. static readonly RIG_MODE_VR: number;
  86342. /**
  86343. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  86344. */
  86345. static readonly RIG_MODE_WEBVR: number;
  86346. /**
  86347. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  86348. */
  86349. static readonly RIG_MODE_CUSTOM: number;
  86350. /**
  86351. * Defines if by default attaching controls should prevent the default javascript event to continue.
  86352. */
  86353. static ForceAttachControlToAlwaysPreventDefault: boolean;
  86354. /**
  86355. * @hidden
  86356. * Might be removed once multiview will be a thing
  86357. */
  86358. static UseAlternateWebVRRendering: boolean;
  86359. /**
  86360. * Define the input manager associated with the camera.
  86361. */
  86362. inputs: CameraInputsManager<Camera>;
  86363. /** @hidden */
  86364. _position: Vector3;
  86365. /**
  86366. * Define the current local position of the camera in the scene
  86367. */
  86368. position: Vector3;
  86369. /**
  86370. * The vector the camera should consider as up.
  86371. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  86372. */
  86373. upVector: Vector3;
  86374. /**
  86375. * Define the current limit on the left side for an orthographic camera
  86376. * In scene unit
  86377. */
  86378. orthoLeft: Nullable<number>;
  86379. /**
  86380. * Define the current limit on the right side for an orthographic camera
  86381. * In scene unit
  86382. */
  86383. orthoRight: Nullable<number>;
  86384. /**
  86385. * Define the current limit on the bottom side for an orthographic camera
  86386. * In scene unit
  86387. */
  86388. orthoBottom: Nullable<number>;
  86389. /**
  86390. * Define the current limit on the top side for an orthographic camera
  86391. * In scene unit
  86392. */
  86393. orthoTop: Nullable<number>;
  86394. /**
  86395. * Field Of View is set in Radians. (default is 0.8)
  86396. */
  86397. fov: number;
  86398. /**
  86399. * Define the minimum distance the camera can see from.
  86400. * This is important to note that the depth buffer are not infinite and the closer it starts
  86401. * the more your scene might encounter depth fighting issue.
  86402. */
  86403. minZ: number;
  86404. /**
  86405. * Define the maximum distance the camera can see to.
  86406. * This is important to note that the depth buffer are not infinite and the further it end
  86407. * the more your scene might encounter depth fighting issue.
  86408. */
  86409. maxZ: number;
  86410. /**
  86411. * Define the default inertia of the camera.
  86412. * This helps giving a smooth feeling to the camera movement.
  86413. */
  86414. inertia: number;
  86415. /**
  86416. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  86417. */
  86418. mode: number;
  86419. /**
  86420. * Define wether the camera is intermediate.
  86421. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  86422. */
  86423. isIntermediate: boolean;
  86424. /**
  86425. * Define the viewport of the camera.
  86426. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  86427. */
  86428. viewport: Viewport;
  86429. /**
  86430. * Restricts the camera to viewing objects with the same layerMask.
  86431. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  86432. */
  86433. layerMask: number;
  86434. /**
  86435. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  86436. */
  86437. fovMode: number;
  86438. /**
  86439. * Rig mode of the camera.
  86440. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  86441. * This is normally controlled byt the camera themselves as internal use.
  86442. */
  86443. cameraRigMode: number;
  86444. /**
  86445. * Defines the distance between both "eyes" in case of a RIG
  86446. */
  86447. interaxialDistance: number;
  86448. /**
  86449. * Defines if stereoscopic rendering is done side by side or over under.
  86450. */
  86451. isStereoscopicSideBySide: boolean;
  86452. /**
  86453. * 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
  86454. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  86455. * else in the scene.
  86456. */
  86457. customRenderTargets: RenderTargetTexture[];
  86458. /**
  86459. * When set, the camera will render to this render target instead of the default canvas
  86460. */
  86461. outputRenderTarget: Nullable<RenderTargetTexture>;
  86462. /**
  86463. * Observable triggered when the camera view matrix has changed.
  86464. */
  86465. onViewMatrixChangedObservable: Observable<Camera>;
  86466. /**
  86467. * Observable triggered when the camera Projection matrix has changed.
  86468. */
  86469. onProjectionMatrixChangedObservable: Observable<Camera>;
  86470. /**
  86471. * Observable triggered when the inputs have been processed.
  86472. */
  86473. onAfterCheckInputsObservable: Observable<Camera>;
  86474. /**
  86475. * Observable triggered when reset has been called and applied to the camera.
  86476. */
  86477. onRestoreStateObservable: Observable<Camera>;
  86478. /** @hidden */
  86479. _cameraRigParams: any;
  86480. /** @hidden */
  86481. _rigCameras: Camera[];
  86482. /** @hidden */
  86483. _rigPostProcess: Nullable<PostProcess>;
  86484. protected _webvrViewMatrix: Matrix;
  86485. /** @hidden */
  86486. _skipRendering: boolean;
  86487. /** @hidden */
  86488. _alternateCamera: Camera;
  86489. /** @hidden */
  86490. _projectionMatrix: Matrix;
  86491. /** @hidden */
  86492. _postProcesses: Nullable<PostProcess>[];
  86493. /** @hidden */
  86494. _activeMeshes: SmartArray<AbstractMesh>;
  86495. protected _globalPosition: Vector3;
  86496. /** hidden */
  86497. _computedViewMatrix: Matrix;
  86498. private _doNotComputeProjectionMatrix;
  86499. private _transformMatrix;
  86500. private _frustumPlanes;
  86501. private _refreshFrustumPlanes;
  86502. private _storedFov;
  86503. private _stateStored;
  86504. /**
  86505. * Instantiates a new camera object.
  86506. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  86507. * @see http://doc.babylonjs.com/features/cameras
  86508. * @param name Defines the name of the camera in the scene
  86509. * @param position Defines the position of the camera
  86510. * @param scene Defines the scene the camera belongs too
  86511. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  86512. */
  86513. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  86514. /**
  86515. * Store current camera state (fov, position, etc..)
  86516. * @returns the camera
  86517. */
  86518. storeState(): Camera;
  86519. /**
  86520. * Restores the camera state values if it has been stored. You must call storeState() first
  86521. */
  86522. protected _restoreStateValues(): boolean;
  86523. /**
  86524. * Restored camera state. You must call storeState() first.
  86525. * @returns true if restored and false otherwise
  86526. */
  86527. restoreState(): boolean;
  86528. /**
  86529. * Gets the class name of the camera.
  86530. * @returns the class name
  86531. */
  86532. getClassName(): string;
  86533. /** @hidden */
  86534. readonly _isCamera: boolean;
  86535. /**
  86536. * Gets a string representation of the camera useful for debug purpose.
  86537. * @param fullDetails Defines that a more verboe level of logging is required
  86538. * @returns the string representation
  86539. */
  86540. toString(fullDetails?: boolean): string;
  86541. /**
  86542. * Gets the current world space position of the camera.
  86543. */
  86544. readonly globalPosition: Vector3;
  86545. /**
  86546. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  86547. * @returns the active meshe list
  86548. */
  86549. getActiveMeshes(): SmartArray<AbstractMesh>;
  86550. /**
  86551. * Check wether a mesh is part of the current active mesh list of the camera
  86552. * @param mesh Defines the mesh to check
  86553. * @returns true if active, false otherwise
  86554. */
  86555. isActiveMesh(mesh: Mesh): boolean;
  86556. /**
  86557. * Is this camera ready to be used/rendered
  86558. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  86559. * @return true if the camera is ready
  86560. */
  86561. isReady(completeCheck?: boolean): boolean;
  86562. /** @hidden */
  86563. _initCache(): void;
  86564. /** @hidden */
  86565. _updateCache(ignoreParentClass?: boolean): void;
  86566. /** @hidden */
  86567. _isSynchronized(): boolean;
  86568. /** @hidden */
  86569. _isSynchronizedViewMatrix(): boolean;
  86570. /** @hidden */
  86571. _isSynchronizedProjectionMatrix(): boolean;
  86572. /**
  86573. * Attach the input controls to a specific dom element to get the input from.
  86574. * @param element Defines the element the controls should be listened from
  86575. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86576. */
  86577. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  86578. /**
  86579. * Detach the current controls from the specified dom element.
  86580. * @param element Defines the element to stop listening the inputs from
  86581. */
  86582. detachControl(element: HTMLElement): void;
  86583. /**
  86584. * Update the camera state according to the different inputs gathered during the frame.
  86585. */
  86586. update(): void;
  86587. /** @hidden */
  86588. _checkInputs(): void;
  86589. /** @hidden */
  86590. readonly rigCameras: Camera[];
  86591. /**
  86592. * Gets the post process used by the rig cameras
  86593. */
  86594. readonly rigPostProcess: Nullable<PostProcess>;
  86595. /**
  86596. * Internal, gets the first post proces.
  86597. * @returns the first post process to be run on this camera.
  86598. */
  86599. _getFirstPostProcess(): Nullable<PostProcess>;
  86600. private _cascadePostProcessesToRigCams;
  86601. /**
  86602. * Attach a post process to the camera.
  86603. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  86604. * @param postProcess The post process to attach to the camera
  86605. * @param insertAt The position of the post process in case several of them are in use in the scene
  86606. * @returns the position the post process has been inserted at
  86607. */
  86608. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  86609. /**
  86610. * Detach a post process to the camera.
  86611. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  86612. * @param postProcess The post process to detach from the camera
  86613. */
  86614. detachPostProcess(postProcess: PostProcess): void;
  86615. /**
  86616. * Gets the current world matrix of the camera
  86617. */
  86618. getWorldMatrix(): Matrix;
  86619. /** @hidden */
  86620. _getViewMatrix(): Matrix;
  86621. /**
  86622. * Gets the current view matrix of the camera.
  86623. * @param force forces the camera to recompute the matrix without looking at the cached state
  86624. * @returns the view matrix
  86625. */
  86626. getViewMatrix(force?: boolean): Matrix;
  86627. /**
  86628. * Freeze the projection matrix.
  86629. * It will prevent the cache check of the camera projection compute and can speed up perf
  86630. * if no parameter of the camera are meant to change
  86631. * @param projection Defines manually a projection if necessary
  86632. */
  86633. freezeProjectionMatrix(projection?: Matrix): void;
  86634. /**
  86635. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  86636. */
  86637. unfreezeProjectionMatrix(): void;
  86638. /**
  86639. * Gets the current projection matrix of the camera.
  86640. * @param force forces the camera to recompute the matrix without looking at the cached state
  86641. * @returns the projection matrix
  86642. */
  86643. getProjectionMatrix(force?: boolean): Matrix;
  86644. /**
  86645. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  86646. * @returns a Matrix
  86647. */
  86648. getTransformationMatrix(): Matrix;
  86649. private _updateFrustumPlanes;
  86650. /**
  86651. * Checks if a cullable object (mesh...) is in the camera frustum
  86652. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  86653. * @param target The object to check
  86654. * @returns true if the object is in frustum otherwise false
  86655. */
  86656. isInFrustum(target: ICullable): boolean;
  86657. /**
  86658. * Checks if a cullable object (mesh...) is in the camera frustum
  86659. * Unlike isInFrustum this cheks the full bounding box
  86660. * @param target The object to check
  86661. * @returns true if the object is in frustum otherwise false
  86662. */
  86663. isCompletelyInFrustum(target: ICullable): boolean;
  86664. /**
  86665. * Gets a ray in the forward direction from the camera.
  86666. * @param length Defines the length of the ray to create
  86667. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  86668. * @param origin Defines the start point of the ray which defaults to the camera position
  86669. * @returns the forward ray
  86670. */
  86671. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  86672. /**
  86673. * Releases resources associated with this node.
  86674. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  86675. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  86676. */
  86677. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  86678. /**
  86679. * Gets the left camera of a rig setup in case of Rigged Camera
  86680. */
  86681. readonly leftCamera: Nullable<FreeCamera>;
  86682. /**
  86683. * Gets the right camera of a rig setup in case of Rigged Camera
  86684. */
  86685. readonly rightCamera: Nullable<FreeCamera>;
  86686. /**
  86687. * Gets the left camera target of a rig setup in case of Rigged Camera
  86688. * @returns the target position
  86689. */
  86690. getLeftTarget(): Nullable<Vector3>;
  86691. /**
  86692. * Gets the right camera target of a rig setup in case of Rigged Camera
  86693. * @returns the target position
  86694. */
  86695. getRightTarget(): Nullable<Vector3>;
  86696. /**
  86697. * @hidden
  86698. */
  86699. setCameraRigMode(mode: number, rigParams: any): void;
  86700. /** @hidden */
  86701. static _setStereoscopicRigMode(camera: Camera): void;
  86702. /** @hidden */
  86703. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  86704. /** @hidden */
  86705. static _setVRRigMode(camera: Camera, rigParams: any): void;
  86706. /** @hidden */
  86707. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  86708. /** @hidden */
  86709. _getVRProjectionMatrix(): Matrix;
  86710. protected _updateCameraRotationMatrix(): void;
  86711. protected _updateWebVRCameraRotationMatrix(): void;
  86712. /**
  86713. * This function MUST be overwritten by the different WebVR cameras available.
  86714. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  86715. * @hidden
  86716. */
  86717. _getWebVRProjectionMatrix(): Matrix;
  86718. /**
  86719. * This function MUST be overwritten by the different WebVR cameras available.
  86720. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  86721. * @hidden
  86722. */
  86723. _getWebVRViewMatrix(): Matrix;
  86724. /** @hidden */
  86725. setCameraRigParameter(name: string, value: any): void;
  86726. /**
  86727. * needs to be overridden by children so sub has required properties to be copied
  86728. * @hidden
  86729. */
  86730. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  86731. /**
  86732. * May need to be overridden by children
  86733. * @hidden
  86734. */
  86735. _updateRigCameras(): void;
  86736. /** @hidden */
  86737. _setupInputs(): void;
  86738. /**
  86739. * Serialiaze the camera setup to a json represention
  86740. * @returns the JSON representation
  86741. */
  86742. serialize(): any;
  86743. /**
  86744. * Clones the current camera.
  86745. * @param name The cloned camera name
  86746. * @returns the cloned camera
  86747. */
  86748. clone(name: string): Camera;
  86749. /**
  86750. * Gets the direction of the camera relative to a given local axis.
  86751. * @param localAxis Defines the reference axis to provide a relative direction.
  86752. * @return the direction
  86753. */
  86754. getDirection(localAxis: Vector3): Vector3;
  86755. /**
  86756. * Gets the direction of the camera relative to a given local axis into a passed vector.
  86757. * @param localAxis Defines the reference axis to provide a relative direction.
  86758. * @param result Defines the vector to store the result in
  86759. */
  86760. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  86761. /**
  86762. * Gets a camera constructor for a given camera type
  86763. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  86764. * @param name The name of the camera the result will be able to instantiate
  86765. * @param scene The scene the result will construct the camera in
  86766. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  86767. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  86768. * @returns a factory method to construc the camera
  86769. */
  86770. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  86771. /**
  86772. * Compute the world matrix of the camera.
  86773. * @returns the camera workd matrix
  86774. */
  86775. computeWorldMatrix(): Matrix;
  86776. /**
  86777. * Parse a JSON and creates the camera from the parsed information
  86778. * @param parsedCamera The JSON to parse
  86779. * @param scene The scene to instantiate the camera in
  86780. * @returns the newly constructed camera
  86781. */
  86782. static Parse(parsedCamera: any, scene: Scene): Camera;
  86783. }
  86784. }
  86785. declare module BABYLON {
  86786. /**
  86787. * Interface for any object that can request an animation frame
  86788. */
  86789. export interface ICustomAnimationFrameRequester {
  86790. /**
  86791. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  86792. */
  86793. renderFunction?: Function;
  86794. /**
  86795. * Called to request the next frame to render to
  86796. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  86797. */
  86798. requestAnimationFrame: Function;
  86799. /**
  86800. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  86801. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  86802. */
  86803. requestID?: number;
  86804. }
  86805. /**
  86806. * Interface containing an array of animations
  86807. */
  86808. export interface IAnimatable {
  86809. /**
  86810. * Array of animations
  86811. */
  86812. animations: Array<Animation>;
  86813. }
  86814. /** Interface used by value gradients (color, factor, ...) */
  86815. export interface IValueGradient {
  86816. /**
  86817. * Gets or sets the gradient value (between 0 and 1)
  86818. */
  86819. gradient: number;
  86820. }
  86821. /** Class used to store color4 gradient */
  86822. export class ColorGradient implements IValueGradient {
  86823. /**
  86824. * Gets or sets the gradient value (between 0 and 1)
  86825. */
  86826. gradient: number;
  86827. /**
  86828. * Gets or sets first associated color
  86829. */
  86830. color1: Color4;
  86831. /**
  86832. * Gets or sets second associated color
  86833. */
  86834. color2?: Color4;
  86835. /**
  86836. * Will get a color picked randomly between color1 and color2.
  86837. * If color2 is undefined then color1 will be used
  86838. * @param result defines the target Color4 to store the result in
  86839. */
  86840. getColorToRef(result: Color4): void;
  86841. }
  86842. /** Class used to store color 3 gradient */
  86843. export class Color3Gradient implements IValueGradient {
  86844. /**
  86845. * Gets or sets the gradient value (between 0 and 1)
  86846. */
  86847. gradient: number;
  86848. /**
  86849. * Gets or sets the associated color
  86850. */
  86851. color: Color3;
  86852. }
  86853. /** Class used to store factor gradient */
  86854. export class FactorGradient implements IValueGradient {
  86855. /**
  86856. * Gets or sets the gradient value (between 0 and 1)
  86857. */
  86858. gradient: number;
  86859. /**
  86860. * Gets or sets first associated factor
  86861. */
  86862. factor1: number;
  86863. /**
  86864. * Gets or sets second associated factor
  86865. */
  86866. factor2?: number;
  86867. /**
  86868. * Will get a number picked randomly between factor1 and factor2.
  86869. * If factor2 is undefined then factor1 will be used
  86870. * @returns the picked number
  86871. */
  86872. getFactor(): number;
  86873. }
  86874. /**
  86875. * @ignore
  86876. * Application error to support additional information when loading a file
  86877. */
  86878. export class LoadFileError extends Error {
  86879. /** defines the optional XHR request */
  86880. request?: XMLHttpRequest | undefined;
  86881. private static _setPrototypeOf;
  86882. /**
  86883. * Creates a new LoadFileError
  86884. * @param message defines the message of the error
  86885. * @param request defines the optional XHR request
  86886. */
  86887. constructor(message: string,
  86888. /** defines the optional XHR request */
  86889. request?: XMLHttpRequest | undefined);
  86890. }
  86891. /**
  86892. * Class used to define a retry strategy when error happens while loading assets
  86893. */
  86894. export class RetryStrategy {
  86895. /**
  86896. * Function used to defines an exponential back off strategy
  86897. * @param maxRetries defines the maximum number of retries (3 by default)
  86898. * @param baseInterval defines the interval between retries
  86899. * @returns the strategy function to use
  86900. */
  86901. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  86902. }
  86903. /**
  86904. * File request interface
  86905. */
  86906. export interface IFileRequest {
  86907. /**
  86908. * Raised when the request is complete (success or error).
  86909. */
  86910. onCompleteObservable: Observable<IFileRequest>;
  86911. /**
  86912. * Aborts the request for a file.
  86913. */
  86914. abort: () => void;
  86915. }
  86916. /**
  86917. * Class containing a set of static utilities functions
  86918. */
  86919. export class Tools {
  86920. /**
  86921. * Gets or sets the base URL to use to load assets
  86922. */
  86923. static BaseUrl: string;
  86924. /**
  86925. * Enable/Disable Custom HTTP Request Headers globally.
  86926. * default = false
  86927. * @see CustomRequestHeaders
  86928. */
  86929. static UseCustomRequestHeaders: boolean;
  86930. /**
  86931. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  86932. * i.e. when loading files, where the server/service expects an Authorization header.
  86933. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  86934. */
  86935. static CustomRequestHeaders: {
  86936. [key: string]: string;
  86937. };
  86938. /**
  86939. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  86940. */
  86941. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  86942. /**
  86943. * Default behaviour for cors in the application.
  86944. * It can be a string if the expected behavior is identical in the entire app.
  86945. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  86946. */
  86947. static CorsBehavior: string | ((url: string | string[]) => string);
  86948. /**
  86949. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  86950. * @ignorenaming
  86951. */
  86952. static UseFallbackTexture: boolean;
  86953. /**
  86954. * Use this object to register external classes like custom textures or material
  86955. * to allow the laoders to instantiate them
  86956. */
  86957. static RegisteredExternalClasses: {
  86958. [key: string]: Object;
  86959. };
  86960. /**
  86961. * Texture content used if a texture cannot loaded
  86962. * @ignorenaming
  86963. */
  86964. static fallbackTexture: string;
  86965. /**
  86966. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  86967. * @param u defines the coordinate on X axis
  86968. * @param v defines the coordinate on Y axis
  86969. * @param width defines the width of the source data
  86970. * @param height defines the height of the source data
  86971. * @param pixels defines the source byte array
  86972. * @param color defines the output color
  86973. */
  86974. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  86975. /**
  86976. * Interpolates between a and b via alpha
  86977. * @param a The lower value (returned when alpha = 0)
  86978. * @param b The upper value (returned when alpha = 1)
  86979. * @param alpha The interpolation-factor
  86980. * @return The mixed value
  86981. */
  86982. static Mix(a: number, b: number, alpha: number): number;
  86983. /**
  86984. * Tries to instantiate a new object from a given class name
  86985. * @param className defines the class name to instantiate
  86986. * @returns the new object or null if the system was not able to do the instantiation
  86987. */
  86988. static Instantiate(className: string): any;
  86989. /**
  86990. * Provides a slice function that will work even on IE
  86991. * @param data defines the array to slice
  86992. * @param start defines the start of the data (optional)
  86993. * @param end defines the end of the data (optional)
  86994. * @returns the new sliced array
  86995. */
  86996. static Slice<T>(data: T, start?: number, end?: number): T;
  86997. /**
  86998. * Polyfill for setImmediate
  86999. * @param action defines the action to execute after the current execution block
  87000. */
  87001. static SetImmediate(action: () => void): void;
  87002. /**
  87003. * Function indicating if a number is an exponent of 2
  87004. * @param value defines the value to test
  87005. * @returns true if the value is an exponent of 2
  87006. */
  87007. static IsExponentOfTwo(value: number): boolean;
  87008. private static _tmpFloatArray;
  87009. /**
  87010. * Returns the nearest 32-bit single precision float representation of a Number
  87011. * @param value A Number. If the parameter is of a different type, it will get converted
  87012. * to a number or to NaN if it cannot be converted
  87013. * @returns number
  87014. */
  87015. static FloatRound(value: number): number;
  87016. /**
  87017. * Find the next highest power of two.
  87018. * @param x Number to start search from.
  87019. * @return Next highest power of two.
  87020. */
  87021. static CeilingPOT(x: number): number;
  87022. /**
  87023. * Find the next lowest power of two.
  87024. * @param x Number to start search from.
  87025. * @return Next lowest power of two.
  87026. */
  87027. static FloorPOT(x: number): number;
  87028. /**
  87029. * Find the nearest power of two.
  87030. * @param x Number to start search from.
  87031. * @return Next nearest power of two.
  87032. */
  87033. static NearestPOT(x: number): number;
  87034. /**
  87035. * Get the closest exponent of two
  87036. * @param value defines the value to approximate
  87037. * @param max defines the maximum value to return
  87038. * @param mode defines how to define the closest value
  87039. * @returns closest exponent of two of the given value
  87040. */
  87041. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  87042. /**
  87043. * Extracts the filename from a path
  87044. * @param path defines the path to use
  87045. * @returns the filename
  87046. */
  87047. static GetFilename(path: string): string;
  87048. /**
  87049. * Extracts the "folder" part of a path (everything before the filename).
  87050. * @param uri The URI to extract the info from
  87051. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  87052. * @returns The "folder" part of the path
  87053. */
  87054. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  87055. /**
  87056. * Extracts text content from a DOM element hierarchy
  87057. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  87058. */
  87059. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  87060. /**
  87061. * Convert an angle in radians to degrees
  87062. * @param angle defines the angle to convert
  87063. * @returns the angle in degrees
  87064. */
  87065. static ToDegrees(angle: number): number;
  87066. /**
  87067. * Convert an angle in degrees to radians
  87068. * @param angle defines the angle to convert
  87069. * @returns the angle in radians
  87070. */
  87071. static ToRadians(angle: number): number;
  87072. /**
  87073. * Encode a buffer to a base64 string
  87074. * @param buffer defines the buffer to encode
  87075. * @returns the encoded string
  87076. */
  87077. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  87078. /**
  87079. * Extracts minimum and maximum values from a list of indexed positions
  87080. * @param positions defines the positions to use
  87081. * @param indices defines the indices to the positions
  87082. * @param indexStart defines the start index
  87083. * @param indexCount defines the end index
  87084. * @param bias defines bias value to add to the result
  87085. * @return minimum and maximum values
  87086. */
  87087. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  87088. minimum: Vector3;
  87089. maximum: Vector3;
  87090. };
  87091. /**
  87092. * Extracts minimum and maximum values from a list of positions
  87093. * @param positions defines the positions to use
  87094. * @param start defines the start index in the positions array
  87095. * @param count defines the number of positions to handle
  87096. * @param bias defines bias value to add to the result
  87097. * @param stride defines the stride size to use (distance between two positions in the positions array)
  87098. * @return minimum and maximum values
  87099. */
  87100. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  87101. minimum: Vector3;
  87102. maximum: Vector3;
  87103. };
  87104. /**
  87105. * Returns an array if obj is not an array
  87106. * @param obj defines the object to evaluate as an array
  87107. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  87108. * @returns either obj directly if obj is an array or a new array containing obj
  87109. */
  87110. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  87111. /**
  87112. * Gets the pointer prefix to use
  87113. * @returns "pointer" if touch is enabled. Else returns "mouse"
  87114. */
  87115. static GetPointerPrefix(): string;
  87116. /**
  87117. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  87118. * @param func - the function to be called
  87119. * @param requester - the object that will request the next frame. Falls back to window.
  87120. * @returns frame number
  87121. */
  87122. static QueueNewFrame(func: () => void, requester?: any): number;
  87123. /**
  87124. * Ask the browser to promote the current element to fullscreen rendering mode
  87125. * @param element defines the DOM element to promote
  87126. */
  87127. static RequestFullscreen(element: HTMLElement): void;
  87128. /**
  87129. * Asks the browser to exit fullscreen mode
  87130. */
  87131. static ExitFullscreen(): void;
  87132. /**
  87133. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  87134. * @param url define the url we are trying
  87135. * @param element define the dom element where to configure the cors policy
  87136. */
  87137. static SetCorsBehavior(url: string | string[], element: {
  87138. crossOrigin: string | null;
  87139. }): void;
  87140. /**
  87141. * Removes unwanted characters from an url
  87142. * @param url defines the url to clean
  87143. * @returns the cleaned url
  87144. */
  87145. static CleanUrl(url: string): string;
  87146. /**
  87147. * Gets or sets a function used to pre-process url before using them to load assets
  87148. */
  87149. static PreprocessUrl: (url: string) => string;
  87150. /**
  87151. * Loads an image as an HTMLImageElement.
  87152. * @param input url string, ArrayBuffer, or Blob to load
  87153. * @param onLoad callback called when the image successfully loads
  87154. * @param onError callback called when the image fails to load
  87155. * @param offlineProvider offline provider for caching
  87156. * @returns the HTMLImageElement of the loaded image
  87157. */
  87158. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  87159. /**
  87160. * Loads a file
  87161. * @param url url string, ArrayBuffer, or Blob to load
  87162. * @param onSuccess callback called when the file successfully loads
  87163. * @param onProgress callback called while file is loading (if the server supports this mode)
  87164. * @param offlineProvider defines the offline provider for caching
  87165. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  87166. * @param onError callback called when the file fails to load
  87167. * @returns a file request object
  87168. */
  87169. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  87170. /**
  87171. * Load a script (identified by an url). When the url returns, the
  87172. * content of this file is added into a new script element, attached to the DOM (body element)
  87173. * @param scriptUrl defines the url of the script to laod
  87174. * @param onSuccess defines the callback called when the script is loaded
  87175. * @param onError defines the callback to call if an error occurs
  87176. */
  87177. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  87178. /**
  87179. * Loads a file from a blob
  87180. * @param fileToLoad defines the blob to use
  87181. * @param callback defines the callback to call when data is loaded
  87182. * @param progressCallback defines the callback to call during loading process
  87183. * @returns a file request object
  87184. */
  87185. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  87186. /**
  87187. * Loads a file
  87188. * @param fileToLoad defines the file to load
  87189. * @param callback defines the callback to call when data is loaded
  87190. * @param progressCallBack defines the callback to call during loading process
  87191. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  87192. * @returns a file request object
  87193. */
  87194. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  87195. /**
  87196. * Creates a data url from a given string content
  87197. * @param content defines the content to convert
  87198. * @returns the new data url link
  87199. */
  87200. static FileAsURL(content: string): string;
  87201. /**
  87202. * Format the given number to a specific decimal format
  87203. * @param value defines the number to format
  87204. * @param decimals defines the number of decimals to use
  87205. * @returns the formatted string
  87206. */
  87207. static Format(value: number, decimals?: number): string;
  87208. /**
  87209. * Checks if a given vector is inside a specific range
  87210. * @param v defines the vector to test
  87211. * @param min defines the minimum range
  87212. * @param max defines the maximum range
  87213. */
  87214. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  87215. /**
  87216. * Tries to copy an object by duplicating every property
  87217. * @param source defines the source object
  87218. * @param destination defines the target object
  87219. * @param doNotCopyList defines a list of properties to avoid
  87220. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  87221. */
  87222. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  87223. /**
  87224. * Gets a boolean indicating if the given object has no own property
  87225. * @param obj defines the object to test
  87226. * @returns true if object has no own property
  87227. */
  87228. static IsEmpty(obj: any): boolean;
  87229. /**
  87230. * Function used to register events at window level
  87231. * @param events defines the events to register
  87232. */
  87233. static RegisterTopRootEvents(events: {
  87234. name: string;
  87235. handler: Nullable<(e: FocusEvent) => any>;
  87236. }[]): void;
  87237. /**
  87238. * Function used to unregister events from window level
  87239. * @param events defines the events to unregister
  87240. */
  87241. static UnregisterTopRootEvents(events: {
  87242. name: string;
  87243. handler: Nullable<(e: FocusEvent) => any>;
  87244. }[]): void;
  87245. /**
  87246. * Dumps the current bound framebuffer
  87247. * @param width defines the rendering width
  87248. * @param height defines the rendering height
  87249. * @param engine defines the hosting engine
  87250. * @param successCallback defines the callback triggered once the data are available
  87251. * @param mimeType defines the mime type of the result
  87252. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  87253. */
  87254. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  87255. /**
  87256. * Converts the canvas data to blob.
  87257. * This acts as a polyfill for browsers not supporting the to blob function.
  87258. * @param canvas Defines the canvas to extract the data from
  87259. * @param successCallback Defines the callback triggered once the data are available
  87260. * @param mimeType Defines the mime type of the result
  87261. */
  87262. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  87263. /**
  87264. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  87265. * @param successCallback defines the callback triggered once the data are available
  87266. * @param mimeType defines the mime type of the result
  87267. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  87268. */
  87269. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  87270. /**
  87271. * Downloads a blob in the browser
  87272. * @param blob defines the blob to download
  87273. * @param fileName defines the name of the downloaded file
  87274. */
  87275. static Download(blob: Blob, fileName: string): void;
  87276. /**
  87277. * Captures a screenshot of the current rendering
  87278. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  87279. * @param engine defines the rendering engine
  87280. * @param camera defines the source camera
  87281. * @param size This parameter can be set to a single number or to an object with the
  87282. * following (optional) properties: precision, width, height. If a single number is passed,
  87283. * it will be used for both width and height. If an object is passed, the screenshot size
  87284. * will be derived from the parameters. The precision property is a multiplier allowing
  87285. * rendering at a higher or lower resolution
  87286. * @param successCallback defines the callback receives a single parameter which contains the
  87287. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  87288. * src parameter of an <img> to display it
  87289. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  87290. * Check your browser for supported MIME types
  87291. */
  87292. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  87293. /**
  87294. * Generates an image screenshot from the specified camera.
  87295. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  87296. * @param engine The engine to use for rendering
  87297. * @param camera The camera to use for rendering
  87298. * @param size This parameter can be set to a single number or to an object with the
  87299. * following (optional) properties: precision, width, height. If a single number is passed,
  87300. * it will be used for both width and height. If an object is passed, the screenshot size
  87301. * will be derived from the parameters. The precision property is a multiplier allowing
  87302. * rendering at a higher or lower resolution
  87303. * @param successCallback The callback receives a single parameter which contains the
  87304. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  87305. * src parameter of an <img> to display it
  87306. * @param mimeType The MIME type of the screenshot image (default: image/png).
  87307. * Check your browser for supported MIME types
  87308. * @param samples Texture samples (default: 1)
  87309. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  87310. * @param fileName A name for for the downloaded file.
  87311. */
  87312. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  87313. /**
  87314. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  87315. * Be aware Math.random() could cause collisions, but:
  87316. * "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"
  87317. * @returns a pseudo random id
  87318. */
  87319. static RandomId(): string;
  87320. /**
  87321. * Test if the given uri is a base64 string
  87322. * @param uri The uri to test
  87323. * @return True if the uri is a base64 string or false otherwise
  87324. */
  87325. static IsBase64(uri: string): boolean;
  87326. /**
  87327. * Decode the given base64 uri.
  87328. * @param uri The uri to decode
  87329. * @return The decoded base64 data.
  87330. */
  87331. static DecodeBase64(uri: string): ArrayBuffer;
  87332. /**
  87333. * No log
  87334. */
  87335. static readonly NoneLogLevel: number;
  87336. /**
  87337. * Only message logs
  87338. */
  87339. static readonly MessageLogLevel: number;
  87340. /**
  87341. * Only warning logs
  87342. */
  87343. static readonly WarningLogLevel: number;
  87344. /**
  87345. * Only error logs
  87346. */
  87347. static readonly ErrorLogLevel: number;
  87348. /**
  87349. * All logs
  87350. */
  87351. static readonly AllLogLevel: number;
  87352. /**
  87353. * Gets a value indicating the number of loading errors
  87354. * @ignorenaming
  87355. */
  87356. static readonly errorsCount: number;
  87357. /**
  87358. * Callback called when a new log is added
  87359. */
  87360. static OnNewCacheEntry: (entry: string) => void;
  87361. /**
  87362. * Log a message to the console
  87363. * @param message defines the message to log
  87364. */
  87365. static Log(message: string): void;
  87366. /**
  87367. * Write a warning message to the console
  87368. * @param message defines the message to log
  87369. */
  87370. static Warn(message: string): void;
  87371. /**
  87372. * Write an error message to the console
  87373. * @param message defines the message to log
  87374. */
  87375. static Error(message: string): void;
  87376. /**
  87377. * Gets current log cache (list of logs)
  87378. */
  87379. static readonly LogCache: string;
  87380. /**
  87381. * Clears the log cache
  87382. */
  87383. static ClearLogCache(): void;
  87384. /**
  87385. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  87386. */
  87387. static LogLevels: number;
  87388. /**
  87389. * Checks if the loaded document was accessed via `file:`-Protocol.
  87390. * @returns boolean
  87391. */
  87392. static IsFileURL(): boolean;
  87393. /**
  87394. * Checks if the window object exists
  87395. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  87396. */
  87397. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  87398. /**
  87399. * No performance log
  87400. */
  87401. static readonly PerformanceNoneLogLevel: number;
  87402. /**
  87403. * Use user marks to log performance
  87404. */
  87405. static readonly PerformanceUserMarkLogLevel: number;
  87406. /**
  87407. * Log performance to the console
  87408. */
  87409. static readonly PerformanceConsoleLogLevel: number;
  87410. private static _performance;
  87411. /**
  87412. * Sets the current performance log level
  87413. */
  87414. static PerformanceLogLevel: number;
  87415. private static _StartPerformanceCounterDisabled;
  87416. private static _EndPerformanceCounterDisabled;
  87417. private static _StartUserMark;
  87418. private static _EndUserMark;
  87419. private static _StartPerformanceConsole;
  87420. private static _EndPerformanceConsole;
  87421. /**
  87422. * Injects the @see CustomRequestHeaders into the given request
  87423. * @param request the request that should be used for injection
  87424. */
  87425. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  87426. /**
  87427. * Starts a performance counter
  87428. */
  87429. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  87430. /**
  87431. * Ends a specific performance coutner
  87432. */
  87433. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  87434. /**
  87435. * Gets either window.performance.now() if supported or Date.now() else
  87436. */
  87437. static readonly Now: number;
  87438. /**
  87439. * This method will return the name of the class used to create the instance of the given object.
  87440. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  87441. * @param object the object to get the class name from
  87442. * @param isType defines if the object is actually a type
  87443. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  87444. */
  87445. static GetClassName(object: any, isType?: boolean): string;
  87446. /**
  87447. * Gets the first element of an array satisfying a given predicate
  87448. * @param array defines the array to browse
  87449. * @param predicate defines the predicate to use
  87450. * @returns null if not found or the element
  87451. */
  87452. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  87453. /**
  87454. * This method will return the name of the full name of the class, including its owning module (if any).
  87455. * 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).
  87456. * @param object the object to get the class name from
  87457. * @param isType defines if the object is actually a type
  87458. * @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.
  87459. * @ignorenaming
  87460. */
  87461. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  87462. /**
  87463. * Returns a promise that resolves after the given amount of time.
  87464. * @param delay Number of milliseconds to delay
  87465. * @returns Promise that resolves after the given amount of time
  87466. */
  87467. static DelayAsync(delay: number): Promise<void>;
  87468. /**
  87469. * Gets the current gradient from an array of IValueGradient
  87470. * @param ratio defines the current ratio to get
  87471. * @param gradients defines the array of IValueGradient
  87472. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  87473. */
  87474. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  87475. }
  87476. /**
  87477. * This class is used to track a performance counter which is number based.
  87478. * The user has access to many properties which give statistics of different nature.
  87479. *
  87480. * The implementer can track two kinds of Performance Counter: time and count.
  87481. * 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.
  87482. * 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.
  87483. */
  87484. export class PerfCounter {
  87485. /**
  87486. * Gets or sets a global boolean to turn on and off all the counters
  87487. */
  87488. static Enabled: boolean;
  87489. /**
  87490. * Returns the smallest value ever
  87491. */
  87492. readonly min: number;
  87493. /**
  87494. * Returns the biggest value ever
  87495. */
  87496. readonly max: number;
  87497. /**
  87498. * Returns the average value since the performance counter is running
  87499. */
  87500. readonly average: number;
  87501. /**
  87502. * Returns the average value of the last second the counter was monitored
  87503. */
  87504. readonly lastSecAverage: number;
  87505. /**
  87506. * Returns the current value
  87507. */
  87508. readonly current: number;
  87509. /**
  87510. * Gets the accumulated total
  87511. */
  87512. readonly total: number;
  87513. /**
  87514. * Gets the total value count
  87515. */
  87516. readonly count: number;
  87517. /**
  87518. * Creates a new counter
  87519. */
  87520. constructor();
  87521. /**
  87522. * Call this method to start monitoring a new frame.
  87523. * 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.
  87524. */
  87525. fetchNewFrame(): void;
  87526. /**
  87527. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  87528. * @param newCount the count value to add to the monitored count
  87529. * @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.
  87530. */
  87531. addCount(newCount: number, fetchResult: boolean): void;
  87532. /**
  87533. * Start monitoring this performance counter
  87534. */
  87535. beginMonitoring(): void;
  87536. /**
  87537. * Compute the time lapsed since the previous beginMonitoring() call.
  87538. * @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
  87539. */
  87540. endMonitoring(newFrame?: boolean): void;
  87541. private _fetchResult;
  87542. private _startMonitoringTime;
  87543. private _min;
  87544. private _max;
  87545. private _average;
  87546. private _current;
  87547. private _totalValueCount;
  87548. private _totalAccumulated;
  87549. private _lastSecAverage;
  87550. private _lastSecAccumulated;
  87551. private _lastSecTime;
  87552. private _lastSecValueCount;
  87553. }
  87554. /**
  87555. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  87556. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  87557. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  87558. * @param name The name of the class, case should be preserved
  87559. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  87560. */
  87561. export function className(name: string, module?: string): (target: Object) => void;
  87562. /**
  87563. * An implementation of a loop for asynchronous functions.
  87564. */
  87565. export class AsyncLoop {
  87566. /**
  87567. * Defines the number of iterations for the loop
  87568. */
  87569. iterations: number;
  87570. /**
  87571. * Defines the current index of the loop.
  87572. */
  87573. index: number;
  87574. private _done;
  87575. private _fn;
  87576. private _successCallback;
  87577. /**
  87578. * Constructor.
  87579. * @param iterations the number of iterations.
  87580. * @param func the function to run each iteration
  87581. * @param successCallback the callback that will be called upon succesful execution
  87582. * @param offset starting offset.
  87583. */
  87584. constructor(
  87585. /**
  87586. * Defines the number of iterations for the loop
  87587. */
  87588. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  87589. /**
  87590. * Execute the next iteration. Must be called after the last iteration was finished.
  87591. */
  87592. executeNext(): void;
  87593. /**
  87594. * Break the loop and run the success callback.
  87595. */
  87596. breakLoop(): void;
  87597. /**
  87598. * Create and run an async loop.
  87599. * @param iterations the number of iterations.
  87600. * @param fn the function to run each iteration
  87601. * @param successCallback the callback that will be called upon succesful execution
  87602. * @param offset starting offset.
  87603. * @returns the created async loop object
  87604. */
  87605. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  87606. /**
  87607. * A for-loop that will run a given number of iterations synchronous and the rest async.
  87608. * @param iterations total number of iterations
  87609. * @param syncedIterations number of synchronous iterations in each async iteration.
  87610. * @param fn the function to call each iteration.
  87611. * @param callback a success call back that will be called when iterating stops.
  87612. * @param breakFunction a break condition (optional)
  87613. * @param timeout timeout settings for the setTimeout function. default - 0.
  87614. * @returns the created async loop object
  87615. */
  87616. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  87617. }
  87618. }
  87619. declare module BABYLON {
  87620. /** @hidden */
  87621. export interface ICollisionCoordinator {
  87622. createCollider(): Collider;
  87623. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  87624. init(scene: Scene): void;
  87625. }
  87626. /** @hidden */
  87627. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  87628. private _scene;
  87629. private _scaledPosition;
  87630. private _scaledVelocity;
  87631. private _finalPosition;
  87632. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  87633. createCollider(): Collider;
  87634. init(scene: Scene): void;
  87635. private _collideWithWorld;
  87636. }
  87637. }
  87638. declare module BABYLON {
  87639. /**
  87640. * This class defines the direct association between an animation and a target
  87641. */
  87642. export class TargetedAnimation {
  87643. /**
  87644. * Animation to perform
  87645. */
  87646. animation: Animation;
  87647. /**
  87648. * Target to animate
  87649. */
  87650. target: any;
  87651. }
  87652. /**
  87653. * Use this class to create coordinated animations on multiple targets
  87654. */
  87655. export class AnimationGroup implements IDisposable {
  87656. /** The name of the animation group */
  87657. name: string;
  87658. private _scene;
  87659. private _targetedAnimations;
  87660. private _animatables;
  87661. private _from;
  87662. private _to;
  87663. private _isStarted;
  87664. private _isPaused;
  87665. private _speedRatio;
  87666. /**
  87667. * Gets or sets the unique id of the node
  87668. */
  87669. uniqueId: number;
  87670. /**
  87671. * This observable will notify when one animation have ended
  87672. */
  87673. onAnimationEndObservable: Observable<TargetedAnimation>;
  87674. /**
  87675. * Observer raised when one animation loops
  87676. */
  87677. onAnimationLoopObservable: Observable<TargetedAnimation>;
  87678. /**
  87679. * This observable will notify when all animations have ended.
  87680. */
  87681. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  87682. /**
  87683. * This observable will notify when all animations have paused.
  87684. */
  87685. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  87686. /**
  87687. * This observable will notify when all animations are playing.
  87688. */
  87689. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  87690. /**
  87691. * Gets the first frame
  87692. */
  87693. readonly from: number;
  87694. /**
  87695. * Gets the last frame
  87696. */
  87697. readonly to: number;
  87698. /**
  87699. * Define if the animations are started
  87700. */
  87701. readonly isStarted: boolean;
  87702. /**
  87703. * Gets a value indicating that the current group is playing
  87704. */
  87705. readonly isPlaying: boolean;
  87706. /**
  87707. * Gets or sets the speed ratio to use for all animations
  87708. */
  87709. /**
  87710. * Gets or sets the speed ratio to use for all animations
  87711. */
  87712. speedRatio: number;
  87713. /**
  87714. * Gets the targeted animations for this animation group
  87715. */
  87716. readonly targetedAnimations: Array<TargetedAnimation>;
  87717. /**
  87718. * returning the list of animatables controlled by this animation group.
  87719. */
  87720. readonly animatables: Array<Animatable>;
  87721. /**
  87722. * Instantiates a new Animation Group.
  87723. * This helps managing several animations at once.
  87724. * @see http://doc.babylonjs.com/how_to/group
  87725. * @param name Defines the name of the group
  87726. * @param scene Defines the scene the group belongs to
  87727. */
  87728. constructor(
  87729. /** The name of the animation group */
  87730. name: string, scene?: Nullable<Scene>);
  87731. /**
  87732. * Add an animation (with its target) in the group
  87733. * @param animation defines the animation we want to add
  87734. * @param target defines the target of the animation
  87735. * @returns the TargetedAnimation object
  87736. */
  87737. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  87738. /**
  87739. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  87740. * It can add constant keys at begin or end
  87741. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  87742. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  87743. * @returns the animation group
  87744. */
  87745. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  87746. /**
  87747. * Start all animations on given targets
  87748. * @param loop defines if animations must loop
  87749. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  87750. * @param from defines the from key (optional)
  87751. * @param to defines the to key (optional)
  87752. * @returns the current animation group
  87753. */
  87754. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  87755. /**
  87756. * Pause all animations
  87757. * @returns the animation group
  87758. */
  87759. pause(): AnimationGroup;
  87760. /**
  87761. * Play all animations to initial state
  87762. * This function will start() the animations if they were not started or will restart() them if they were paused
  87763. * @param loop defines if animations must loop
  87764. * @returns the animation group
  87765. */
  87766. play(loop?: boolean): AnimationGroup;
  87767. /**
  87768. * Reset all animations to initial state
  87769. * @returns the animation group
  87770. */
  87771. reset(): AnimationGroup;
  87772. /**
  87773. * Restart animations from key 0
  87774. * @returns the animation group
  87775. */
  87776. restart(): AnimationGroup;
  87777. /**
  87778. * Stop all animations
  87779. * @returns the animation group
  87780. */
  87781. stop(): AnimationGroup;
  87782. /**
  87783. * Set animation weight for all animatables
  87784. * @param weight defines the weight to use
  87785. * @return the animationGroup
  87786. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  87787. */
  87788. setWeightForAllAnimatables(weight: number): AnimationGroup;
  87789. /**
  87790. * Synchronize and normalize all animatables with a source animatable
  87791. * @param root defines the root animatable to synchronize with
  87792. * @return the animationGroup
  87793. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  87794. */
  87795. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  87796. /**
  87797. * Goes to a specific frame in this animation group
  87798. * @param frame the frame number to go to
  87799. * @return the animationGroup
  87800. */
  87801. goToFrame(frame: number): AnimationGroup;
  87802. /**
  87803. * Dispose all associated resources
  87804. */
  87805. dispose(): void;
  87806. private _checkAnimationGroupEnded;
  87807. /**
  87808. * Clone the current animation group and returns a copy
  87809. * @param newName defines the name of the new group
  87810. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  87811. * @returns the new aniamtion group
  87812. */
  87813. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  87814. /**
  87815. * Returns a new AnimationGroup object parsed from the source provided.
  87816. * @param parsedAnimationGroup defines the source
  87817. * @param scene defines the scene that will receive the animationGroup
  87818. * @returns a new AnimationGroup
  87819. */
  87820. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  87821. /**
  87822. * Returns the string "AnimationGroup"
  87823. * @returns "AnimationGroup"
  87824. */
  87825. getClassName(): string;
  87826. /**
  87827. * Creates a detailled string about the object
  87828. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  87829. * @returns a string representing the object
  87830. */
  87831. toString(fullDetails?: boolean): string;
  87832. }
  87833. }
  87834. declare module BABYLON {
  87835. /**
  87836. * Define an interface for all classes that will hold resources
  87837. */
  87838. export interface IDisposable {
  87839. /**
  87840. * Releases all held resources
  87841. */
  87842. dispose(): void;
  87843. }
  87844. /** Interface defining initialization parameters for Scene class */
  87845. export interface SceneOptions {
  87846. /**
  87847. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  87848. * It will improve performance when the number of geometries becomes important.
  87849. */
  87850. useGeometryUniqueIdsMap?: boolean;
  87851. /**
  87852. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  87853. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  87854. */
  87855. useMaterialMeshMap?: boolean;
  87856. /**
  87857. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  87858. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  87859. */
  87860. useClonedMeshhMap?: boolean;
  87861. }
  87862. /**
  87863. * Represents a scene to be rendered by the engine.
  87864. * @see http://doc.babylonjs.com/features/scene
  87865. */
  87866. export class Scene extends AbstractScene implements IAnimatable {
  87867. private static _uniqueIdCounter;
  87868. /** The fog is deactivated */
  87869. static readonly FOGMODE_NONE: number;
  87870. /** The fog density is following an exponential function */
  87871. static readonly FOGMODE_EXP: number;
  87872. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  87873. static readonly FOGMODE_EXP2: number;
  87874. /** The fog density is following a linear function. */
  87875. static readonly FOGMODE_LINEAR: number;
  87876. /**
  87877. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  87878. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87879. */
  87880. static MinDeltaTime: number;
  87881. /**
  87882. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  87883. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87884. */
  87885. static MaxDeltaTime: number;
  87886. /**
  87887. * Factory used to create the default material.
  87888. * @param name The name of the material to create
  87889. * @param scene The scene to create the material for
  87890. * @returns The default material
  87891. */
  87892. static DefaultMaterialFactory(scene: Scene): Material;
  87893. /**
  87894. * Factory used to create the a collision coordinator.
  87895. * @returns The collision coordinator
  87896. */
  87897. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  87898. /** @hidden */
  87899. readonly _isScene: boolean;
  87900. /**
  87901. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  87902. */
  87903. autoClear: boolean;
  87904. /**
  87905. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  87906. */
  87907. autoClearDepthAndStencil: boolean;
  87908. /**
  87909. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  87910. */
  87911. clearColor: Color4;
  87912. /**
  87913. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  87914. */
  87915. ambientColor: Color3;
  87916. /** @hidden */
  87917. _environmentBRDFTexture: BaseTexture;
  87918. /** @hidden */
  87919. protected _environmentTexture: Nullable<BaseTexture>;
  87920. /**
  87921. * Texture used in all pbr material as the reflection texture.
  87922. * As in the majority of the scene they are the same (exception for multi room and so on),
  87923. * this is easier to reference from here than from all the materials.
  87924. */
  87925. /**
  87926. * Texture used in all pbr material as the reflection texture.
  87927. * As in the majority of the scene they are the same (exception for multi room and so on),
  87928. * this is easier to set here than in all the materials.
  87929. */
  87930. environmentTexture: Nullable<BaseTexture>;
  87931. /** @hidden */
  87932. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  87933. /**
  87934. * Default image processing configuration used either in the rendering
  87935. * Forward main pass or through the imageProcessingPostProcess if present.
  87936. * As in the majority of the scene they are the same (exception for multi camera),
  87937. * this is easier to reference from here than from all the materials and post process.
  87938. *
  87939. * No setter as we it is a shared configuration, you can set the values instead.
  87940. */
  87941. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  87942. private _forceWireframe;
  87943. /**
  87944. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  87945. */
  87946. forceWireframe: boolean;
  87947. private _forcePointsCloud;
  87948. /**
  87949. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  87950. */
  87951. forcePointsCloud: boolean;
  87952. /**
  87953. * Gets or sets the active clipplane 1
  87954. */
  87955. clipPlane: Nullable<Plane>;
  87956. /**
  87957. * Gets or sets the active clipplane 2
  87958. */
  87959. clipPlane2: Nullable<Plane>;
  87960. /**
  87961. * Gets or sets the active clipplane 3
  87962. */
  87963. clipPlane3: Nullable<Plane>;
  87964. /**
  87965. * Gets or sets the active clipplane 4
  87966. */
  87967. clipPlane4: Nullable<Plane>;
  87968. /**
  87969. * Gets or sets a boolean indicating if animations are enabled
  87970. */
  87971. animationsEnabled: boolean;
  87972. private _animationPropertiesOverride;
  87973. /**
  87974. * Gets or sets the animation properties override
  87975. */
  87976. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  87977. /**
  87978. * Gets or sets a boolean indicating if a constant deltatime has to be used
  87979. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  87980. */
  87981. useConstantAnimationDeltaTime: boolean;
  87982. /**
  87983. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  87984. * Please note that it requires to run a ray cast through the scene on every frame
  87985. */
  87986. constantlyUpdateMeshUnderPointer: boolean;
  87987. /**
  87988. * Defines the HTML cursor to use when hovering over interactive elements
  87989. */
  87990. hoverCursor: string;
  87991. /**
  87992. * Defines the HTML default cursor to use (empty by default)
  87993. */
  87994. defaultCursor: string;
  87995. /**
  87996. * This is used to call preventDefault() on pointer down
  87997. * in order to block unwanted artifacts like system double clicks
  87998. */
  87999. preventDefaultOnPointerDown: boolean;
  88000. /**
  88001. * This is used to call preventDefault() on pointer up
  88002. * in order to block unwanted artifacts like system double clicks
  88003. */
  88004. preventDefaultOnPointerUp: boolean;
  88005. /**
  88006. * Gets or sets user defined metadata
  88007. */
  88008. metadata: any;
  88009. /**
  88010. * For internal use only. Please do not use.
  88011. */
  88012. reservedDataStore: any;
  88013. /**
  88014. * Gets the name of the plugin used to load this scene (null by default)
  88015. */
  88016. loadingPluginName: string;
  88017. /**
  88018. * Use this array to add regular expressions used to disable offline support for specific urls
  88019. */
  88020. disableOfflineSupportExceptionRules: RegExp[];
  88021. /**
  88022. * An event triggered when the scene is disposed.
  88023. */
  88024. onDisposeObservable: Observable<Scene>;
  88025. private _onDisposeObserver;
  88026. /** Sets a function to be executed when this scene is disposed. */
  88027. onDispose: () => void;
  88028. /**
  88029. * An event triggered before rendering the scene (right after animations and physics)
  88030. */
  88031. onBeforeRenderObservable: Observable<Scene>;
  88032. private _onBeforeRenderObserver;
  88033. /** Sets a function to be executed before rendering this scene */
  88034. beforeRender: Nullable<() => void>;
  88035. /**
  88036. * An event triggered after rendering the scene
  88037. */
  88038. onAfterRenderObservable: Observable<Scene>;
  88039. private _onAfterRenderObserver;
  88040. /** Sets a function to be executed after rendering this scene */
  88041. afterRender: Nullable<() => void>;
  88042. /**
  88043. * An event triggered before animating the scene
  88044. */
  88045. onBeforeAnimationsObservable: Observable<Scene>;
  88046. /**
  88047. * An event triggered after animations processing
  88048. */
  88049. onAfterAnimationsObservable: Observable<Scene>;
  88050. /**
  88051. * An event triggered before draw calls are ready to be sent
  88052. */
  88053. onBeforeDrawPhaseObservable: Observable<Scene>;
  88054. /**
  88055. * An event triggered after draw calls have been sent
  88056. */
  88057. onAfterDrawPhaseObservable: Observable<Scene>;
  88058. /**
  88059. * An event triggered when the scene is ready
  88060. */
  88061. onReadyObservable: Observable<Scene>;
  88062. /**
  88063. * An event triggered before rendering a camera
  88064. */
  88065. onBeforeCameraRenderObservable: Observable<Camera>;
  88066. private _onBeforeCameraRenderObserver;
  88067. /** Sets a function to be executed before rendering a camera*/
  88068. beforeCameraRender: () => void;
  88069. /**
  88070. * An event triggered after rendering a camera
  88071. */
  88072. onAfterCameraRenderObservable: Observable<Camera>;
  88073. private _onAfterCameraRenderObserver;
  88074. /** Sets a function to be executed after rendering a camera*/
  88075. afterCameraRender: () => void;
  88076. /**
  88077. * An event triggered when active meshes evaluation is about to start
  88078. */
  88079. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  88080. /**
  88081. * An event triggered when active meshes evaluation is done
  88082. */
  88083. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  88084. /**
  88085. * An event triggered when particles rendering is about to start
  88086. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  88087. */
  88088. onBeforeParticlesRenderingObservable: Observable<Scene>;
  88089. /**
  88090. * An event triggered when particles rendering is done
  88091. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  88092. */
  88093. onAfterParticlesRenderingObservable: Observable<Scene>;
  88094. /**
  88095. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  88096. */
  88097. onDataLoadedObservable: Observable<Scene>;
  88098. /**
  88099. * An event triggered when a camera is created
  88100. */
  88101. onNewCameraAddedObservable: Observable<Camera>;
  88102. /**
  88103. * An event triggered when a camera is removed
  88104. */
  88105. onCameraRemovedObservable: Observable<Camera>;
  88106. /**
  88107. * An event triggered when a light is created
  88108. */
  88109. onNewLightAddedObservable: Observable<Light>;
  88110. /**
  88111. * An event triggered when a light is removed
  88112. */
  88113. onLightRemovedObservable: Observable<Light>;
  88114. /**
  88115. * An event triggered when a geometry is created
  88116. */
  88117. onNewGeometryAddedObservable: Observable<Geometry>;
  88118. /**
  88119. * An event triggered when a geometry is removed
  88120. */
  88121. onGeometryRemovedObservable: Observable<Geometry>;
  88122. /**
  88123. * An event triggered when a transform node is created
  88124. */
  88125. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  88126. /**
  88127. * An event triggered when a transform node is removed
  88128. */
  88129. onTransformNodeRemovedObservable: Observable<TransformNode>;
  88130. /**
  88131. * An event triggered when a mesh is created
  88132. */
  88133. onNewMeshAddedObservable: Observable<AbstractMesh>;
  88134. /**
  88135. * An event triggered when a mesh is removed
  88136. */
  88137. onMeshRemovedObservable: Observable<AbstractMesh>;
  88138. /**
  88139. * An event triggered when a material is created
  88140. */
  88141. onNewMaterialAddedObservable: Observable<Material>;
  88142. /**
  88143. * An event triggered when a material is removed
  88144. */
  88145. onMaterialRemovedObservable: Observable<Material>;
  88146. /**
  88147. * An event triggered when a texture is created
  88148. */
  88149. onNewTextureAddedObservable: Observable<BaseTexture>;
  88150. /**
  88151. * An event triggered when a texture is removed
  88152. */
  88153. onTextureRemovedObservable: Observable<BaseTexture>;
  88154. /**
  88155. * An event triggered when render targets are about to be rendered
  88156. * Can happen multiple times per frame.
  88157. */
  88158. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  88159. /**
  88160. * An event triggered when render targets were rendered.
  88161. * Can happen multiple times per frame.
  88162. */
  88163. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  88164. /**
  88165. * An event triggered before calculating deterministic simulation step
  88166. */
  88167. onBeforeStepObservable: Observable<Scene>;
  88168. /**
  88169. * An event triggered after calculating deterministic simulation step
  88170. */
  88171. onAfterStepObservable: Observable<Scene>;
  88172. /**
  88173. * An event triggered when the activeCamera property is updated
  88174. */
  88175. onActiveCameraChanged: Observable<Scene>;
  88176. /**
  88177. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  88178. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  88179. * 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)
  88180. */
  88181. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  88182. /**
  88183. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  88184. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  88185. * 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)
  88186. */
  88187. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  88188. /**
  88189. * This Observable will when a mesh has been imported into the scene.
  88190. */
  88191. onMeshImportedObservable: Observable<AbstractMesh>;
  88192. /** @hidden */
  88193. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  88194. /**
  88195. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  88196. */
  88197. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  88198. /**
  88199. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  88200. */
  88201. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  88202. /**
  88203. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  88204. */
  88205. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  88206. private _onPointerMove;
  88207. private _onPointerDown;
  88208. private _onPointerUp;
  88209. /** Callback called when a pointer move is detected */
  88210. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  88211. /** Callback called when a pointer down is detected */
  88212. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  88213. /** Callback called when a pointer up is detected */
  88214. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  88215. /** Callback called when a pointer pick is detected */
  88216. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  88217. /**
  88218. * 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).
  88219. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  88220. */
  88221. onPrePointerObservable: Observable<PointerInfoPre>;
  88222. /**
  88223. * Observable event triggered each time an input event is received from the rendering canvas
  88224. */
  88225. onPointerObservable: Observable<PointerInfo>;
  88226. /**
  88227. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  88228. */
  88229. readonly unTranslatedPointer: Vector2;
  88230. /** The distance in pixel that you have to move to prevent some events */
  88231. static DragMovementThreshold: number;
  88232. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  88233. static LongPressDelay: number;
  88234. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  88235. static DoubleClickDelay: number;
  88236. /** If you need to check double click without raising a single click at first click, enable this flag */
  88237. static ExclusiveDoubleClickMode: boolean;
  88238. private _initClickEvent;
  88239. private _initActionManager;
  88240. private _delayedSimpleClick;
  88241. private _delayedSimpleClickTimeout;
  88242. private _previousDelayedSimpleClickTimeout;
  88243. private _meshPickProceed;
  88244. private _previousButtonPressed;
  88245. private _currentPickResult;
  88246. private _previousPickResult;
  88247. private _totalPointersPressed;
  88248. private _doubleClickOccured;
  88249. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  88250. cameraToUseForPointers: Nullable<Camera>;
  88251. private _pointerX;
  88252. private _pointerY;
  88253. private _unTranslatedPointerX;
  88254. private _unTranslatedPointerY;
  88255. private _startingPointerPosition;
  88256. private _previousStartingPointerPosition;
  88257. private _startingPointerTime;
  88258. private _previousStartingPointerTime;
  88259. private _pointerCaptures;
  88260. private _timeAccumulator;
  88261. private _currentStepId;
  88262. private _currentInternalStep;
  88263. /** @hidden */
  88264. _mirroredCameraPosition: Nullable<Vector3>;
  88265. /**
  88266. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  88267. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  88268. */
  88269. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  88270. /**
  88271. * Observable event triggered each time an keyboard event is received from the hosting window
  88272. */
  88273. onKeyboardObservable: Observable<KeyboardInfo>;
  88274. private _onKeyDown;
  88275. private _onKeyUp;
  88276. private _onCanvasFocusObserver;
  88277. private _onCanvasBlurObserver;
  88278. private _useRightHandedSystem;
  88279. /**
  88280. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  88281. */
  88282. useRightHandedSystem: boolean;
  88283. /**
  88284. * Sets the step Id used by deterministic lock step
  88285. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88286. * @param newStepId defines the step Id
  88287. */
  88288. setStepId(newStepId: number): void;
  88289. /**
  88290. * Gets the step Id used by deterministic lock step
  88291. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88292. * @returns the step Id
  88293. */
  88294. getStepId(): number;
  88295. /**
  88296. * Gets the internal step used by deterministic lock step
  88297. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88298. * @returns the internal step
  88299. */
  88300. getInternalStep(): number;
  88301. private _fogEnabled;
  88302. /**
  88303. * Gets or sets a boolean indicating if fog is enabled on this scene
  88304. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88305. * (Default is true)
  88306. */
  88307. fogEnabled: boolean;
  88308. private _fogMode;
  88309. /**
  88310. * Gets or sets the fog mode to use
  88311. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88312. * | mode | value |
  88313. * | --- | --- |
  88314. * | FOGMODE_NONE | 0 |
  88315. * | FOGMODE_EXP | 1 |
  88316. * | FOGMODE_EXP2 | 2 |
  88317. * | FOGMODE_LINEAR | 3 |
  88318. */
  88319. fogMode: number;
  88320. /**
  88321. * Gets or sets the fog color to use
  88322. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88323. * (Default is Color3(0.2, 0.2, 0.3))
  88324. */
  88325. fogColor: Color3;
  88326. /**
  88327. * Gets or sets the fog density to use
  88328. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88329. * (Default is 0.1)
  88330. */
  88331. fogDensity: number;
  88332. /**
  88333. * Gets or sets the fog start distance to use
  88334. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88335. * (Default is 0)
  88336. */
  88337. fogStart: number;
  88338. /**
  88339. * Gets or sets the fog end distance to use
  88340. * @see http://doc.babylonjs.com/babylon101/environment#fog
  88341. * (Default is 1000)
  88342. */
  88343. fogEnd: number;
  88344. private _shadowsEnabled;
  88345. /**
  88346. * Gets or sets a boolean indicating if shadows are enabled on this scene
  88347. */
  88348. shadowsEnabled: boolean;
  88349. private _lightsEnabled;
  88350. /**
  88351. * Gets or sets a boolean indicating if lights are enabled on this scene
  88352. */
  88353. lightsEnabled: boolean;
  88354. /** All of the active cameras added to this scene. */
  88355. activeCameras: Camera[];
  88356. private _activeCamera;
  88357. /** Gets or sets the current active camera */
  88358. activeCamera: Nullable<Camera>;
  88359. private _defaultMaterial;
  88360. /** The default material used on meshes when no material is affected */
  88361. /** The default material used on meshes when no material is affected */
  88362. defaultMaterial: Material;
  88363. private _texturesEnabled;
  88364. /**
  88365. * Gets or sets a boolean indicating if textures are enabled on this scene
  88366. */
  88367. texturesEnabled: boolean;
  88368. /**
  88369. * Gets or sets a boolean indicating if particles are enabled on this scene
  88370. */
  88371. particlesEnabled: boolean;
  88372. /**
  88373. * Gets or sets a boolean indicating if sprites are enabled on this scene
  88374. */
  88375. spritesEnabled: boolean;
  88376. private _skeletonsEnabled;
  88377. /**
  88378. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  88379. */
  88380. skeletonsEnabled: boolean;
  88381. /**
  88382. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  88383. */
  88384. lensFlaresEnabled: boolean;
  88385. /**
  88386. * Gets or sets a boolean indicating if collisions are enabled on this scene
  88387. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  88388. */
  88389. collisionsEnabled: boolean;
  88390. private _collisionCoordinator;
  88391. /** @hidden */
  88392. readonly collisionCoordinator: ICollisionCoordinator;
  88393. /**
  88394. * Defines the gravity applied to this scene (used only for collisions)
  88395. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  88396. */
  88397. gravity: Vector3;
  88398. /**
  88399. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  88400. */
  88401. postProcessesEnabled: boolean;
  88402. /**
  88403. * The list of postprocesses added to the scene
  88404. */
  88405. postProcesses: PostProcess[];
  88406. /**
  88407. * Gets the current postprocess manager
  88408. */
  88409. postProcessManager: PostProcessManager;
  88410. /**
  88411. * Gets or sets a boolean indicating if render targets are enabled on this scene
  88412. */
  88413. renderTargetsEnabled: boolean;
  88414. /**
  88415. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  88416. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  88417. */
  88418. dumpNextRenderTargets: boolean;
  88419. /**
  88420. * The list of user defined render targets added to the scene
  88421. */
  88422. customRenderTargets: RenderTargetTexture[];
  88423. /**
  88424. * Defines if texture loading must be delayed
  88425. * If true, textures will only be loaded when they need to be rendered
  88426. */
  88427. useDelayedTextureLoading: boolean;
  88428. /**
  88429. * Gets the list of meshes imported to the scene through SceneLoader
  88430. */
  88431. importedMeshesFiles: String[];
  88432. /**
  88433. * Gets or sets a boolean indicating if probes are enabled on this scene
  88434. */
  88435. probesEnabled: boolean;
  88436. /**
  88437. * Gets or sets the current offline provider to use to store scene data
  88438. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  88439. */
  88440. offlineProvider: IOfflineProvider;
  88441. /**
  88442. * Gets or sets the action manager associated with the scene
  88443. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  88444. */
  88445. actionManager: AbstractActionManager;
  88446. private _meshesForIntersections;
  88447. /**
  88448. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  88449. */
  88450. proceduralTexturesEnabled: boolean;
  88451. private _engine;
  88452. private _totalVertices;
  88453. /** @hidden */
  88454. _activeIndices: PerfCounter;
  88455. /** @hidden */
  88456. _activeParticles: PerfCounter;
  88457. /** @hidden */
  88458. _activeBones: PerfCounter;
  88459. private _animationRatio;
  88460. /** @hidden */
  88461. _animationTimeLast: number;
  88462. /** @hidden */
  88463. _animationTime: number;
  88464. /**
  88465. * Gets or sets a general scale for animation speed
  88466. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  88467. */
  88468. animationTimeScale: number;
  88469. /** @hidden */
  88470. _cachedMaterial: Nullable<Material>;
  88471. /** @hidden */
  88472. _cachedEffect: Nullable<Effect>;
  88473. /** @hidden */
  88474. _cachedVisibility: Nullable<number>;
  88475. private _renderId;
  88476. private _frameId;
  88477. private _executeWhenReadyTimeoutId;
  88478. private _intermediateRendering;
  88479. private _viewUpdateFlag;
  88480. private _projectionUpdateFlag;
  88481. private _alternateViewUpdateFlag;
  88482. private _alternateProjectionUpdateFlag;
  88483. /** @hidden */
  88484. _toBeDisposed: Nullable<IDisposable>[];
  88485. private _activeRequests;
  88486. /** @hidden */
  88487. _pendingData: any[];
  88488. private _isDisposed;
  88489. /**
  88490. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  88491. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  88492. */
  88493. dispatchAllSubMeshesOfActiveMeshes: boolean;
  88494. private _activeMeshes;
  88495. private _processedMaterials;
  88496. private _renderTargets;
  88497. /** @hidden */
  88498. _activeParticleSystems: SmartArray<IParticleSystem>;
  88499. private _activeSkeletons;
  88500. private _softwareSkinnedMeshes;
  88501. private _renderingManager;
  88502. /** @hidden */
  88503. _activeAnimatables: Animatable[];
  88504. private _transformMatrix;
  88505. private _sceneUbo;
  88506. private _alternateSceneUbo;
  88507. private _viewMatrix;
  88508. private _projectionMatrix;
  88509. private _alternateViewMatrix;
  88510. private _alternateProjectionMatrix;
  88511. private _alternateTransformMatrix;
  88512. private _useAlternateCameraConfiguration;
  88513. private _alternateRendering;
  88514. private _wheelEventName;
  88515. /** @hidden */
  88516. _forcedViewPosition: Nullable<Vector3>;
  88517. /** @hidden */
  88518. readonly _isAlternateRenderingEnabled: boolean;
  88519. private _frustumPlanes;
  88520. /**
  88521. * Gets the list of frustum planes (built from the active camera)
  88522. */
  88523. readonly frustumPlanes: Plane[];
  88524. /**
  88525. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  88526. * This is useful if there are more lights that the maximum simulteanous authorized
  88527. */
  88528. requireLightSorting: boolean;
  88529. /** @hidden */
  88530. readonly useMaterialMeshMap: boolean;
  88531. /** @hidden */
  88532. readonly useClonedMeshhMap: boolean;
  88533. private _pointerOverMesh;
  88534. private _pickedDownMesh;
  88535. private _pickedUpMesh;
  88536. private _externalData;
  88537. private _uid;
  88538. /**
  88539. * @hidden
  88540. * Backing store of defined scene components.
  88541. */
  88542. _components: ISceneComponent[];
  88543. /**
  88544. * @hidden
  88545. * Backing store of defined scene components.
  88546. */
  88547. _serializableComponents: ISceneSerializableComponent[];
  88548. /**
  88549. * List of components to register on the next registration step.
  88550. */
  88551. private _transientComponents;
  88552. /**
  88553. * Registers the transient components if needed.
  88554. */
  88555. private _registerTransientComponents;
  88556. /**
  88557. * @hidden
  88558. * Add a component to the scene.
  88559. * Note that the ccomponent could be registered on th next frame if this is called after
  88560. * the register component stage.
  88561. * @param component Defines the component to add to the scene
  88562. */
  88563. _addComponent(component: ISceneComponent): void;
  88564. /**
  88565. * @hidden
  88566. * Gets a component from the scene.
  88567. * @param name defines the name of the component to retrieve
  88568. * @returns the component or null if not present
  88569. */
  88570. _getComponent(name: string): Nullable<ISceneComponent>;
  88571. /**
  88572. * @hidden
  88573. * Defines the actions happening before camera updates.
  88574. */
  88575. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  88576. /**
  88577. * @hidden
  88578. * Defines the actions happening before clear the canvas.
  88579. */
  88580. _beforeClearStage: Stage<SimpleStageAction>;
  88581. /**
  88582. * @hidden
  88583. * Defines the actions when collecting render targets for the frame.
  88584. */
  88585. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  88586. /**
  88587. * @hidden
  88588. * Defines the actions happening for one camera in the frame.
  88589. */
  88590. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  88591. /**
  88592. * @hidden
  88593. * Defines the actions happening during the per mesh ready checks.
  88594. */
  88595. _isReadyForMeshStage: Stage<MeshStageAction>;
  88596. /**
  88597. * @hidden
  88598. * Defines the actions happening before evaluate active mesh checks.
  88599. */
  88600. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  88601. /**
  88602. * @hidden
  88603. * Defines the actions happening during the evaluate sub mesh checks.
  88604. */
  88605. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  88606. /**
  88607. * @hidden
  88608. * Defines the actions happening during the active mesh stage.
  88609. */
  88610. _activeMeshStage: Stage<ActiveMeshStageAction>;
  88611. /**
  88612. * @hidden
  88613. * Defines the actions happening during the per camera render target step.
  88614. */
  88615. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  88616. /**
  88617. * @hidden
  88618. * Defines the actions happening just before the active camera is drawing.
  88619. */
  88620. _beforeCameraDrawStage: Stage<CameraStageAction>;
  88621. /**
  88622. * @hidden
  88623. * Defines the actions happening just before a render target is drawing.
  88624. */
  88625. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  88626. /**
  88627. * @hidden
  88628. * Defines the actions happening just before a rendering group is drawing.
  88629. */
  88630. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  88631. /**
  88632. * @hidden
  88633. * Defines the actions happening just before a mesh is drawing.
  88634. */
  88635. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  88636. /**
  88637. * @hidden
  88638. * Defines the actions happening just after a mesh has been drawn.
  88639. */
  88640. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  88641. /**
  88642. * @hidden
  88643. * Defines the actions happening just after a rendering group has been drawn.
  88644. */
  88645. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  88646. /**
  88647. * @hidden
  88648. * Defines the actions happening just after the active camera has been drawn.
  88649. */
  88650. _afterCameraDrawStage: Stage<CameraStageAction>;
  88651. /**
  88652. * @hidden
  88653. * Defines the actions happening just after a render target has been drawn.
  88654. */
  88655. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  88656. /**
  88657. * @hidden
  88658. * Defines the actions happening just after rendering all cameras and computing intersections.
  88659. */
  88660. _afterRenderStage: Stage<SimpleStageAction>;
  88661. /**
  88662. * @hidden
  88663. * Defines the actions happening when a pointer move event happens.
  88664. */
  88665. _pointerMoveStage: Stage<PointerMoveStageAction>;
  88666. /**
  88667. * @hidden
  88668. * Defines the actions happening when a pointer down event happens.
  88669. */
  88670. _pointerDownStage: Stage<PointerUpDownStageAction>;
  88671. /**
  88672. * @hidden
  88673. * Defines the actions happening when a pointer up event happens.
  88674. */
  88675. _pointerUpStage: Stage<PointerUpDownStageAction>;
  88676. /**
  88677. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  88678. */
  88679. private geometriesByUniqueId;
  88680. /**
  88681. * Creates a new Scene
  88682. * @param engine defines the engine to use to render this scene
  88683. * @param options defines the scene options
  88684. */
  88685. constructor(engine: Engine, options?: SceneOptions);
  88686. private _defaultMeshCandidates;
  88687. /**
  88688. * @hidden
  88689. */
  88690. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  88691. private _defaultSubMeshCandidates;
  88692. /**
  88693. * @hidden
  88694. */
  88695. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  88696. /**
  88697. * Sets the default candidate providers for the scene.
  88698. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  88699. * and getCollidingSubMeshCandidates to their default function
  88700. */
  88701. setDefaultCandidateProviders(): void;
  88702. /**
  88703. * Gets the mesh that is currently under the pointer
  88704. */
  88705. readonly meshUnderPointer: Nullable<AbstractMesh>;
  88706. /**
  88707. * Gets or sets the current on-screen X position of the pointer
  88708. */
  88709. pointerX: number;
  88710. /**
  88711. * Gets or sets the current on-screen Y position of the pointer
  88712. */
  88713. pointerY: number;
  88714. /**
  88715. * Gets the cached material (ie. the latest rendered one)
  88716. * @returns the cached material
  88717. */
  88718. getCachedMaterial(): Nullable<Material>;
  88719. /**
  88720. * Gets the cached effect (ie. the latest rendered one)
  88721. * @returns the cached effect
  88722. */
  88723. getCachedEffect(): Nullable<Effect>;
  88724. /**
  88725. * Gets the cached visibility state (ie. the latest rendered one)
  88726. * @returns the cached visibility state
  88727. */
  88728. getCachedVisibility(): Nullable<number>;
  88729. /**
  88730. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  88731. * @param material defines the current material
  88732. * @param effect defines the current effect
  88733. * @param visibility defines the current visibility state
  88734. * @returns true if one parameter is not cached
  88735. */
  88736. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  88737. /**
  88738. * Gets the engine associated with the scene
  88739. * @returns an Engine
  88740. */
  88741. getEngine(): Engine;
  88742. /**
  88743. * Gets the total number of vertices rendered per frame
  88744. * @returns the total number of vertices rendered per frame
  88745. */
  88746. getTotalVertices(): number;
  88747. /**
  88748. * Gets the performance counter for total vertices
  88749. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  88750. */
  88751. readonly totalVerticesPerfCounter: PerfCounter;
  88752. /**
  88753. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  88754. * @returns the total number of active indices rendered per frame
  88755. */
  88756. getActiveIndices(): number;
  88757. /**
  88758. * Gets the performance counter for active indices
  88759. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  88760. */
  88761. readonly totalActiveIndicesPerfCounter: PerfCounter;
  88762. /**
  88763. * Gets the total number of active particles rendered per frame
  88764. * @returns the total number of active particles rendered per frame
  88765. */
  88766. getActiveParticles(): number;
  88767. /**
  88768. * Gets the performance counter for active particles
  88769. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  88770. */
  88771. readonly activeParticlesPerfCounter: PerfCounter;
  88772. /**
  88773. * Gets the total number of active bones rendered per frame
  88774. * @returns the total number of active bones rendered per frame
  88775. */
  88776. getActiveBones(): number;
  88777. /**
  88778. * Gets the performance counter for active bones
  88779. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  88780. */
  88781. readonly activeBonesPerfCounter: PerfCounter;
  88782. /**
  88783. * Gets the array of active meshes
  88784. * @returns an array of AbstractMesh
  88785. */
  88786. getActiveMeshes(): SmartArray<AbstractMesh>;
  88787. /**
  88788. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  88789. * @returns a number
  88790. */
  88791. getAnimationRatio(): number;
  88792. /**
  88793. * Gets an unique Id for the current render phase
  88794. * @returns a number
  88795. */
  88796. getRenderId(): number;
  88797. /**
  88798. * Gets an unique Id for the current frame
  88799. * @returns a number
  88800. */
  88801. getFrameId(): number;
  88802. /** Call this function if you want to manually increment the render Id*/
  88803. incrementRenderId(): void;
  88804. private _updatePointerPosition;
  88805. private _createUbo;
  88806. private _createAlternateUbo;
  88807. private _setRayOnPointerInfo;
  88808. /**
  88809. * Use this method to simulate a pointer move on a mesh
  88810. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  88811. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  88812. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  88813. * @returns the current scene
  88814. */
  88815. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  88816. private _processPointerMove;
  88817. private _checkPrePointerObservable;
  88818. /**
  88819. * Use this method to simulate a pointer down on a mesh
  88820. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  88821. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  88822. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  88823. * @returns the current scene
  88824. */
  88825. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  88826. private _processPointerDown;
  88827. /**
  88828. * Use this method to simulate a pointer up on a mesh
  88829. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  88830. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  88831. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  88832. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  88833. * @returns the current scene
  88834. */
  88835. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  88836. private _processPointerUp;
  88837. /**
  88838. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  88839. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  88840. * @returns true if the pointer was captured
  88841. */
  88842. isPointerCaptured(pointerId?: number): boolean;
  88843. /** @hidden */
  88844. _isPointerSwiping(): boolean;
  88845. /**
  88846. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  88847. * @param attachUp defines if you want to attach events to pointerup
  88848. * @param attachDown defines if you want to attach events to pointerdown
  88849. * @param attachMove defines if you want to attach events to pointermove
  88850. */
  88851. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  88852. /** Detaches all event handlers*/
  88853. detachControl(): void;
  88854. /**
  88855. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  88856. * Delay loaded resources are not taking in account
  88857. * @return true if all required resources are ready
  88858. */
  88859. isReady(): boolean;
  88860. /** Resets all cached information relative to material (including effect and visibility) */
  88861. resetCachedMaterial(): void;
  88862. /**
  88863. * Registers a function to be called before every frame render
  88864. * @param func defines the function to register
  88865. */
  88866. registerBeforeRender(func: () => void): void;
  88867. /**
  88868. * Unregisters a function called before every frame render
  88869. * @param func defines the function to unregister
  88870. */
  88871. unregisterBeforeRender(func: () => void): void;
  88872. /**
  88873. * Registers a function to be called after every frame render
  88874. * @param func defines the function to register
  88875. */
  88876. registerAfterRender(func: () => void): void;
  88877. /**
  88878. * Unregisters a function called after every frame render
  88879. * @param func defines the function to unregister
  88880. */
  88881. unregisterAfterRender(func: () => void): void;
  88882. private _executeOnceBeforeRender;
  88883. /**
  88884. * The provided function will run before render once and will be disposed afterwards.
  88885. * A timeout delay can be provided so that the function will be executed in N ms.
  88886. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  88887. * @param func The function to be executed.
  88888. * @param timeout optional delay in ms
  88889. */
  88890. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  88891. /** @hidden */
  88892. _addPendingData(data: any): void;
  88893. /** @hidden */
  88894. _removePendingData(data: any): void;
  88895. /**
  88896. * Returns the number of items waiting to be loaded
  88897. * @returns the number of items waiting to be loaded
  88898. */
  88899. getWaitingItemsCount(): number;
  88900. /**
  88901. * Returns a boolean indicating if the scene is still loading data
  88902. */
  88903. readonly isLoading: boolean;
  88904. /**
  88905. * Registers a function to be executed when the scene is ready
  88906. * @param {Function} func - the function to be executed
  88907. */
  88908. executeWhenReady(func: () => void): void;
  88909. /**
  88910. * Returns a promise that resolves when the scene is ready
  88911. * @returns A promise that resolves when the scene is ready
  88912. */
  88913. whenReadyAsync(): Promise<void>;
  88914. /** @hidden */
  88915. _checkIsReady(): void;
  88916. /**
  88917. * Gets all animatable attached to the scene
  88918. */
  88919. readonly animatables: Animatable[];
  88920. /**
  88921. * Resets the last animation time frame.
  88922. * Useful to override when animations start running when loading a scene for the first time.
  88923. */
  88924. resetLastAnimationTimeFrame(): void;
  88925. /** @hidden */
  88926. _switchToAlternateCameraConfiguration(active: boolean): void;
  88927. /**
  88928. * Gets the current view matrix
  88929. * @returns a Matrix
  88930. */
  88931. getViewMatrix(): Matrix;
  88932. /**
  88933. * Gets the current projection matrix
  88934. * @returns a Matrix
  88935. */
  88936. getProjectionMatrix(): Matrix;
  88937. /**
  88938. * Gets the current transform matrix
  88939. * @returns a Matrix made of View * Projection
  88940. */
  88941. getTransformMatrix(): Matrix;
  88942. /**
  88943. * Sets the current transform matrix
  88944. * @param view defines the View matrix to use
  88945. * @param projection defines the Projection matrix to use
  88946. */
  88947. setTransformMatrix(view: Matrix, projection: Matrix): void;
  88948. /** @hidden */
  88949. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  88950. /**
  88951. * Gets the uniform buffer used to store scene data
  88952. * @returns a UniformBuffer
  88953. */
  88954. getSceneUniformBuffer(): UniformBuffer;
  88955. /**
  88956. * Gets an unique (relatively to the current scene) Id
  88957. * @returns an unique number for the scene
  88958. */
  88959. getUniqueId(): number;
  88960. /**
  88961. * Add a mesh to the list of scene's meshes
  88962. * @param newMesh defines the mesh to add
  88963. * @param recursive if all child meshes should also be added to the scene
  88964. */
  88965. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  88966. /**
  88967. * Remove a mesh for the list of scene's meshes
  88968. * @param toRemove defines the mesh to remove
  88969. * @param recursive if all child meshes should also be removed from the scene
  88970. * @returns the index where the mesh was in the mesh list
  88971. */
  88972. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  88973. /**
  88974. * Add a transform node to the list of scene's transform nodes
  88975. * @param newTransformNode defines the transform node to add
  88976. */
  88977. addTransformNode(newTransformNode: TransformNode): void;
  88978. /**
  88979. * Remove a transform node for the list of scene's transform nodes
  88980. * @param toRemove defines the transform node to remove
  88981. * @returns the index where the transform node was in the transform node list
  88982. */
  88983. removeTransformNode(toRemove: TransformNode): number;
  88984. /**
  88985. * Remove a skeleton for the list of scene's skeletons
  88986. * @param toRemove defines the skeleton to remove
  88987. * @returns the index where the skeleton was in the skeleton list
  88988. */
  88989. removeSkeleton(toRemove: Skeleton): number;
  88990. /**
  88991. * Remove a morph target for the list of scene's morph targets
  88992. * @param toRemove defines the morph target to remove
  88993. * @returns the index where the morph target was in the morph target list
  88994. */
  88995. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  88996. /**
  88997. * Remove a light for the list of scene's lights
  88998. * @param toRemove defines the light to remove
  88999. * @returns the index where the light was in the light list
  89000. */
  89001. removeLight(toRemove: Light): number;
  89002. /**
  89003. * Remove a camera for the list of scene's cameras
  89004. * @param toRemove defines the camera to remove
  89005. * @returns the index where the camera was in the camera list
  89006. */
  89007. removeCamera(toRemove: Camera): number;
  89008. /**
  89009. * Remove a particle system for the list of scene's particle systems
  89010. * @param toRemove defines the particle system to remove
  89011. * @returns the index where the particle system was in the particle system list
  89012. */
  89013. removeParticleSystem(toRemove: IParticleSystem): number;
  89014. /**
  89015. * Remove a animation for the list of scene's animations
  89016. * @param toRemove defines the animation to remove
  89017. * @returns the index where the animation was in the animation list
  89018. */
  89019. removeAnimation(toRemove: Animation): number;
  89020. /**
  89021. * Removes the given animation group from this scene.
  89022. * @param toRemove The animation group to remove
  89023. * @returns The index of the removed animation group
  89024. */
  89025. removeAnimationGroup(toRemove: AnimationGroup): number;
  89026. /**
  89027. * Removes the given multi-material from this scene.
  89028. * @param toRemove The multi-material to remove
  89029. * @returns The index of the removed multi-material
  89030. */
  89031. removeMultiMaterial(toRemove: MultiMaterial): number;
  89032. /**
  89033. * Removes the given material from this scene.
  89034. * @param toRemove The material to remove
  89035. * @returns The index of the removed material
  89036. */
  89037. removeMaterial(toRemove: Material): number;
  89038. /**
  89039. * Removes the given action manager from this scene.
  89040. * @param toRemove The action manager to remove
  89041. * @returns The index of the removed action manager
  89042. */
  89043. removeActionManager(toRemove: AbstractActionManager): number;
  89044. /**
  89045. * Removes the given texture from this scene.
  89046. * @param toRemove The texture to remove
  89047. * @returns The index of the removed texture
  89048. */
  89049. removeTexture(toRemove: BaseTexture): number;
  89050. /**
  89051. * Adds the given light to this scene
  89052. * @param newLight The light to add
  89053. */
  89054. addLight(newLight: Light): void;
  89055. /**
  89056. * Sorts the list list based on light priorities
  89057. */
  89058. sortLightsByPriority(): void;
  89059. /**
  89060. * Adds the given camera to this scene
  89061. * @param newCamera The camera to add
  89062. */
  89063. addCamera(newCamera: Camera): void;
  89064. /**
  89065. * Adds the given skeleton to this scene
  89066. * @param newSkeleton The skeleton to add
  89067. */
  89068. addSkeleton(newSkeleton: Skeleton): void;
  89069. /**
  89070. * Adds the given particle system to this scene
  89071. * @param newParticleSystem The particle system to add
  89072. */
  89073. addParticleSystem(newParticleSystem: IParticleSystem): void;
  89074. /**
  89075. * Adds the given animation to this scene
  89076. * @param newAnimation The animation to add
  89077. */
  89078. addAnimation(newAnimation: Animation): void;
  89079. /**
  89080. * Adds the given animation group to this scene.
  89081. * @param newAnimationGroup The animation group to add
  89082. */
  89083. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  89084. /**
  89085. * Adds the given multi-material to this scene
  89086. * @param newMultiMaterial The multi-material to add
  89087. */
  89088. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  89089. /**
  89090. * Adds the given material to this scene
  89091. * @param newMaterial The material to add
  89092. */
  89093. addMaterial(newMaterial: Material): void;
  89094. /**
  89095. * Adds the given morph target to this scene
  89096. * @param newMorphTargetManager The morph target to add
  89097. */
  89098. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  89099. /**
  89100. * Adds the given geometry to this scene
  89101. * @param newGeometry The geometry to add
  89102. */
  89103. addGeometry(newGeometry: Geometry): void;
  89104. /**
  89105. * Adds the given action manager to this scene
  89106. * @param newActionManager The action manager to add
  89107. */
  89108. addActionManager(newActionManager: AbstractActionManager): void;
  89109. /**
  89110. * Adds the given texture to this scene.
  89111. * @param newTexture The texture to add
  89112. */
  89113. addTexture(newTexture: BaseTexture): void;
  89114. /**
  89115. * Switch active camera
  89116. * @param newCamera defines the new active camera
  89117. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  89118. */
  89119. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  89120. /**
  89121. * sets the active camera of the scene using its ID
  89122. * @param id defines the camera's ID
  89123. * @return the new active camera or null if none found.
  89124. */
  89125. setActiveCameraByID(id: string): Nullable<Camera>;
  89126. /**
  89127. * sets the active camera of the scene using its name
  89128. * @param name defines the camera's name
  89129. * @returns the new active camera or null if none found.
  89130. */
  89131. setActiveCameraByName(name: string): Nullable<Camera>;
  89132. /**
  89133. * get an animation group using its name
  89134. * @param name defines the material's name
  89135. * @return the animation group or null if none found.
  89136. */
  89137. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  89138. /**
  89139. * get a material using its id
  89140. * @param id defines the material's ID
  89141. * @return the material or null if none found.
  89142. */
  89143. getMaterialByID(id: string): Nullable<Material>;
  89144. /**
  89145. * Gets a material using its name
  89146. * @param name defines the material's name
  89147. * @return the material or null if none found.
  89148. */
  89149. getMaterialByName(name: string): Nullable<Material>;
  89150. /**
  89151. * Gets a camera using its id
  89152. * @param id defines the id to look for
  89153. * @returns the camera or null if not found
  89154. */
  89155. getCameraByID(id: string): Nullable<Camera>;
  89156. /**
  89157. * Gets a camera using its unique id
  89158. * @param uniqueId defines the unique id to look for
  89159. * @returns the camera or null if not found
  89160. */
  89161. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  89162. /**
  89163. * Gets a camera using its name
  89164. * @param name defines the camera's name
  89165. * @return the camera or null if none found.
  89166. */
  89167. getCameraByName(name: string): Nullable<Camera>;
  89168. /**
  89169. * Gets a bone using its id
  89170. * @param id defines the bone's id
  89171. * @return the bone or null if not found
  89172. */
  89173. getBoneByID(id: string): Nullable<Bone>;
  89174. /**
  89175. * Gets a bone using its id
  89176. * @param name defines the bone's name
  89177. * @return the bone or null if not found
  89178. */
  89179. getBoneByName(name: string): Nullable<Bone>;
  89180. /**
  89181. * Gets a light node using its name
  89182. * @param name defines the the light's name
  89183. * @return the light or null if none found.
  89184. */
  89185. getLightByName(name: string): Nullable<Light>;
  89186. /**
  89187. * Gets a light node using its id
  89188. * @param id defines the light's id
  89189. * @return the light or null if none found.
  89190. */
  89191. getLightByID(id: string): Nullable<Light>;
  89192. /**
  89193. * Gets a light node using its scene-generated unique ID
  89194. * @param uniqueId defines the light's unique id
  89195. * @return the light or null if none found.
  89196. */
  89197. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  89198. /**
  89199. * Gets a particle system by id
  89200. * @param id defines the particle system id
  89201. * @return the corresponding system or null if none found
  89202. */
  89203. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  89204. /**
  89205. * Gets a geometry using its ID
  89206. * @param id defines the geometry's id
  89207. * @return the geometry or null if none found.
  89208. */
  89209. getGeometryByID(id: string): Nullable<Geometry>;
  89210. private _getGeometryByUniqueID;
  89211. /**
  89212. * Add a new geometry to this scene
  89213. * @param geometry defines the geometry to be added to the scene.
  89214. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  89215. * @return a boolean defining if the geometry was added or not
  89216. */
  89217. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  89218. /**
  89219. * Removes an existing geometry
  89220. * @param geometry defines the geometry to be removed from the scene
  89221. * @return a boolean defining if the geometry was removed or not
  89222. */
  89223. removeGeometry(geometry: Geometry): boolean;
  89224. /**
  89225. * Gets the list of geometries attached to the scene
  89226. * @returns an array of Geometry
  89227. */
  89228. getGeometries(): Geometry[];
  89229. /**
  89230. * Gets the first added mesh found of a given ID
  89231. * @param id defines the id to search for
  89232. * @return the mesh found or null if not found at all
  89233. */
  89234. getMeshByID(id: string): Nullable<AbstractMesh>;
  89235. /**
  89236. * Gets a list of meshes using their id
  89237. * @param id defines the id to search for
  89238. * @returns a list of meshes
  89239. */
  89240. getMeshesByID(id: string): Array<AbstractMesh>;
  89241. /**
  89242. * Gets the first added transform node found of a given ID
  89243. * @param id defines the id to search for
  89244. * @return the found transform node or null if not found at all.
  89245. */
  89246. getTransformNodeByID(id: string): Nullable<TransformNode>;
  89247. /**
  89248. * Gets a list of transform nodes using their id
  89249. * @param id defines the id to search for
  89250. * @returns a list of transform nodes
  89251. */
  89252. getTransformNodesByID(id: string): Array<TransformNode>;
  89253. /**
  89254. * Gets a mesh with its auto-generated unique id
  89255. * @param uniqueId defines the unique id to search for
  89256. * @return the found mesh or null if not found at all.
  89257. */
  89258. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  89259. /**
  89260. * Gets a the last added mesh using a given id
  89261. * @param id defines the id to search for
  89262. * @return the found mesh or null if not found at all.
  89263. */
  89264. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  89265. /**
  89266. * Gets a the last added node (Mesh, Camera, Light) using a given id
  89267. * @param id defines the id to search for
  89268. * @return the found node or null if not found at all
  89269. */
  89270. getLastEntryByID(id: string): Nullable<Node>;
  89271. /**
  89272. * Gets a node (Mesh, Camera, Light) using a given id
  89273. * @param id defines the id to search for
  89274. * @return the found node or null if not found at all
  89275. */
  89276. getNodeByID(id: string): Nullable<Node>;
  89277. /**
  89278. * Gets a node (Mesh, Camera, Light) using a given name
  89279. * @param name defines the name to search for
  89280. * @return the found node or null if not found at all.
  89281. */
  89282. getNodeByName(name: string): Nullable<Node>;
  89283. /**
  89284. * Gets a mesh using a given name
  89285. * @param name defines the name to search for
  89286. * @return the found mesh or null if not found at all.
  89287. */
  89288. getMeshByName(name: string): Nullable<AbstractMesh>;
  89289. /**
  89290. * Gets a transform node using a given name
  89291. * @param name defines the name to search for
  89292. * @return the found transform node or null if not found at all.
  89293. */
  89294. getTransformNodeByName(name: string): Nullable<TransformNode>;
  89295. /**
  89296. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  89297. * @param id defines the id to search for
  89298. * @return the found skeleton or null if not found at all.
  89299. */
  89300. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  89301. /**
  89302. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  89303. * @param id defines the id to search for
  89304. * @return the found skeleton or null if not found at all.
  89305. */
  89306. getSkeletonById(id: string): Nullable<Skeleton>;
  89307. /**
  89308. * Gets a skeleton using a given name
  89309. * @param name defines the name to search for
  89310. * @return the found skeleton or null if not found at all.
  89311. */
  89312. getSkeletonByName(name: string): Nullable<Skeleton>;
  89313. /**
  89314. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  89315. * @param id defines the id to search for
  89316. * @return the found morph target manager or null if not found at all.
  89317. */
  89318. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  89319. /**
  89320. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  89321. * @param id defines the id to search for
  89322. * @return the found morph target or null if not found at all.
  89323. */
  89324. getMorphTargetById(id: string): Nullable<MorphTarget>;
  89325. /**
  89326. * Gets a boolean indicating if the given mesh is active
  89327. * @param mesh defines the mesh to look for
  89328. * @returns true if the mesh is in the active list
  89329. */
  89330. isActiveMesh(mesh: AbstractMesh): boolean;
  89331. /**
  89332. * Return a unique id as a string which can serve as an identifier for the scene
  89333. */
  89334. readonly uid: string;
  89335. /**
  89336. * Add an externaly attached data from its key.
  89337. * This method call will fail and return false, if such key already exists.
  89338. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  89339. * @param key the unique key that identifies the data
  89340. * @param data the data object to associate to the key for this Engine instance
  89341. * @return true if no such key were already present and the data was added successfully, false otherwise
  89342. */
  89343. addExternalData<T>(key: string, data: T): boolean;
  89344. /**
  89345. * Get an externaly attached data from its key
  89346. * @param key the unique key that identifies the data
  89347. * @return the associated data, if present (can be null), or undefined if not present
  89348. */
  89349. getExternalData<T>(key: string): Nullable<T>;
  89350. /**
  89351. * Get an externaly attached data from its key, create it using a factory if it's not already present
  89352. * @param key the unique key that identifies the data
  89353. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  89354. * @return the associated data, can be null if the factory returned null.
  89355. */
  89356. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  89357. /**
  89358. * Remove an externaly attached data from the Engine instance
  89359. * @param key the unique key that identifies the data
  89360. * @return true if the data was successfully removed, false if it doesn't exist
  89361. */
  89362. removeExternalData(key: string): boolean;
  89363. private _evaluateSubMesh;
  89364. /**
  89365. * Clear the processed materials smart array preventing retention point in material dispose.
  89366. */
  89367. freeProcessedMaterials(): void;
  89368. private _preventFreeActiveMeshesAndRenderingGroups;
  89369. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  89370. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  89371. * when disposing several meshes in a row or a hierarchy of meshes.
  89372. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  89373. */
  89374. blockfreeActiveMeshesAndRenderingGroups: boolean;
  89375. /**
  89376. * Clear the active meshes smart array preventing retention point in mesh dispose.
  89377. */
  89378. freeActiveMeshes(): void;
  89379. /**
  89380. * Clear the info related to rendering groups preventing retention points during dispose.
  89381. */
  89382. freeRenderingGroups(): void;
  89383. /** @hidden */
  89384. _isInIntermediateRendering(): boolean;
  89385. /**
  89386. * Lambda returning the list of potentially active meshes.
  89387. */
  89388. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  89389. /**
  89390. * Lambda returning the list of potentially active sub meshes.
  89391. */
  89392. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  89393. /**
  89394. * Lambda returning the list of potentially intersecting sub meshes.
  89395. */
  89396. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  89397. /**
  89398. * Lambda returning the list of potentially colliding sub meshes.
  89399. */
  89400. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  89401. private _activeMeshesFrozen;
  89402. /**
  89403. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  89404. * @returns the current scene
  89405. */
  89406. freezeActiveMeshes(): Scene;
  89407. /**
  89408. * Use this function to restart evaluating active meshes on every frame
  89409. * @returns the current scene
  89410. */
  89411. unfreezeActiveMeshes(): Scene;
  89412. private _evaluateActiveMeshes;
  89413. private _activeMesh;
  89414. /**
  89415. * Update the transform matrix to update from the current active camera
  89416. * @param force defines a boolean used to force the update even if cache is up to date
  89417. */
  89418. updateTransformMatrix(force?: boolean): void;
  89419. /**
  89420. * 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)
  89421. * @param alternateCamera defines the camera to use
  89422. */
  89423. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  89424. /** @hidden */
  89425. _allowPostProcessClearColor: boolean;
  89426. private _renderForCamera;
  89427. private _processSubCameras;
  89428. private _checkIntersections;
  89429. /** @hidden */
  89430. _advancePhysicsEngineStep(step: number): void;
  89431. /**
  89432. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  89433. */
  89434. getDeterministicFrameTime: () => number;
  89435. /** @hidden */
  89436. _animate(): void;
  89437. /**
  89438. * Render the scene
  89439. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  89440. */
  89441. render(updateCameras?: boolean): void;
  89442. /**
  89443. * Freeze all materials
  89444. * A frozen material will not be updatable but should be faster to render
  89445. */
  89446. freezeMaterials(): void;
  89447. /**
  89448. * Unfreeze all materials
  89449. * A frozen material will not be updatable but should be faster to render
  89450. */
  89451. unfreezeMaterials(): void;
  89452. /**
  89453. * Releases all held ressources
  89454. */
  89455. dispose(): void;
  89456. /**
  89457. * Gets if the scene is already disposed
  89458. */
  89459. readonly isDisposed: boolean;
  89460. /**
  89461. * Call this function to reduce memory footprint of the scene.
  89462. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  89463. */
  89464. clearCachedVertexData(): void;
  89465. /**
  89466. * This function will remove the local cached buffer data from texture.
  89467. * It will save memory but will prevent the texture from being rebuilt
  89468. */
  89469. cleanCachedTextureBuffer(): void;
  89470. /**
  89471. * Get the world extend vectors with an optional filter
  89472. *
  89473. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  89474. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  89475. */
  89476. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  89477. min: Vector3;
  89478. max: Vector3;
  89479. };
  89480. /**
  89481. * Creates a ray that can be used to pick in the scene
  89482. * @param x defines the x coordinate of the origin (on-screen)
  89483. * @param y defines the y coordinate of the origin (on-screen)
  89484. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  89485. * @param camera defines the camera to use for the picking
  89486. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  89487. * @returns a Ray
  89488. */
  89489. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  89490. /**
  89491. * Creates a ray that can be used to pick in the scene
  89492. * @param x defines the x coordinate of the origin (on-screen)
  89493. * @param y defines the y coordinate of the origin (on-screen)
  89494. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  89495. * @param result defines the ray where to store the picking ray
  89496. * @param camera defines the camera to use for the picking
  89497. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  89498. * @returns the current scene
  89499. */
  89500. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  89501. /**
  89502. * Creates a ray that can be used to pick in the scene
  89503. * @param x defines the x coordinate of the origin (on-screen)
  89504. * @param y defines the y coordinate of the origin (on-screen)
  89505. * @param camera defines the camera to use for the picking
  89506. * @returns a Ray
  89507. */
  89508. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  89509. /**
  89510. * Creates a ray that can be used to pick in the scene
  89511. * @param x defines the x coordinate of the origin (on-screen)
  89512. * @param y defines the y coordinate of the origin (on-screen)
  89513. * @param result defines the ray where to store the picking ray
  89514. * @param camera defines the camera to use for the picking
  89515. * @returns the current scene
  89516. */
  89517. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  89518. /** Launch a ray to try to pick a mesh in the scene
  89519. * @param x position on screen
  89520. * @param y position on screen
  89521. * @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
  89522. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  89523. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  89524. * @returns a PickingInfo
  89525. */
  89526. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  89527. /** Use the given ray to pick a mesh in the scene
  89528. * @param ray The ray to use to pick meshes
  89529. * @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
  89530. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  89531. * @returns a PickingInfo
  89532. */
  89533. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  89534. /**
  89535. * Launch a ray to try to pick a mesh in the scene
  89536. * @param x X position on screen
  89537. * @param y Y position on screen
  89538. * @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
  89539. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  89540. * @returns an array of PickingInfo
  89541. */
  89542. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  89543. /**
  89544. * Launch a ray to try to pick a mesh in the scene
  89545. * @param ray Ray to use
  89546. * @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
  89547. * @returns an array of PickingInfo
  89548. */
  89549. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  89550. /**
  89551. * Force the value of meshUnderPointer
  89552. * @param mesh defines the mesh to use
  89553. */
  89554. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  89555. /**
  89556. * Gets the mesh under the pointer
  89557. * @returns a Mesh or null if no mesh is under the pointer
  89558. */
  89559. getPointerOverMesh(): Nullable<AbstractMesh>;
  89560. /** @hidden */
  89561. _rebuildGeometries(): void;
  89562. /** @hidden */
  89563. _rebuildTextures(): void;
  89564. private _getByTags;
  89565. /**
  89566. * Get a list of meshes by tags
  89567. * @param tagsQuery defines the tags query to use
  89568. * @param forEach defines a predicate used to filter results
  89569. * @returns an array of Mesh
  89570. */
  89571. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  89572. /**
  89573. * Get a list of cameras by tags
  89574. * @param tagsQuery defines the tags query to use
  89575. * @param forEach defines a predicate used to filter results
  89576. * @returns an array of Camera
  89577. */
  89578. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  89579. /**
  89580. * Get a list of lights by tags
  89581. * @param tagsQuery defines the tags query to use
  89582. * @param forEach defines a predicate used to filter results
  89583. * @returns an array of Light
  89584. */
  89585. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  89586. /**
  89587. * Get a list of materials by tags
  89588. * @param tagsQuery defines the tags query to use
  89589. * @param forEach defines a predicate used to filter results
  89590. * @returns an array of Material
  89591. */
  89592. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  89593. /**
  89594. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  89595. * This allowed control for front to back rendering or reversly depending of the special needs.
  89596. *
  89597. * @param renderingGroupId The rendering group id corresponding to its index
  89598. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  89599. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  89600. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  89601. */
  89602. 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;
  89603. /**
  89604. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  89605. *
  89606. * @param renderingGroupId The rendering group id corresponding to its index
  89607. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  89608. * @param depth Automatically clears depth between groups if true and autoClear is true.
  89609. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  89610. */
  89611. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  89612. /**
  89613. * Gets the current auto clear configuration for one rendering group of the rendering
  89614. * manager.
  89615. * @param index the rendering group index to get the information for
  89616. * @returns The auto clear setup for the requested rendering group
  89617. */
  89618. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  89619. private _blockMaterialDirtyMechanism;
  89620. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  89621. blockMaterialDirtyMechanism: boolean;
  89622. /**
  89623. * Will flag all materials as dirty to trigger new shader compilation
  89624. * @param flag defines the flag used to specify which material part must be marked as dirty
  89625. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  89626. */
  89627. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  89628. /** @hidden */
  89629. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  89630. /** @hidden */
  89631. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  89632. }
  89633. }
  89634. declare module BABYLON {
  89635. /**
  89636. * Set of assets to keep when moving a scene into an asset container.
  89637. */
  89638. export class KeepAssets extends AbstractScene {
  89639. }
  89640. /**
  89641. * Container with a set of assets that can be added or removed from a scene.
  89642. */
  89643. export class AssetContainer extends AbstractScene {
  89644. /**
  89645. * The scene the AssetContainer belongs to.
  89646. */
  89647. scene: Scene;
  89648. /**
  89649. * Instantiates an AssetContainer.
  89650. * @param scene The scene the AssetContainer belongs to.
  89651. */
  89652. constructor(scene: Scene);
  89653. /**
  89654. * Adds all the assets from the container to the scene.
  89655. */
  89656. addAllToScene(): void;
  89657. /**
  89658. * Removes all the assets in the container from the scene
  89659. */
  89660. removeAllFromScene(): void;
  89661. /**
  89662. * Disposes all the assets in the container
  89663. */
  89664. dispose(): void;
  89665. private _moveAssets;
  89666. /**
  89667. * Removes all the assets contained in the scene and adds them to the container.
  89668. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  89669. */
  89670. moveAllFromScene(keepAssets?: KeepAssets): void;
  89671. /**
  89672. * 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.
  89673. * @returns the root mesh
  89674. */
  89675. createRootMesh(): Mesh;
  89676. }
  89677. }
  89678. declare module BABYLON {
  89679. /**
  89680. * Defines how the parser contract is defined.
  89681. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  89682. */
  89683. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  89684. /**
  89685. * Defines how the individual parser contract is defined.
  89686. * These parser can parse an individual asset
  89687. */
  89688. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  89689. /**
  89690. * Base class of the scene acting as a container for the different elements composing a scene.
  89691. * This class is dynamically extended by the different components of the scene increasing
  89692. * flexibility and reducing coupling
  89693. */
  89694. export abstract class AbstractScene {
  89695. /**
  89696. * Stores the list of available parsers in the application.
  89697. */
  89698. private static _BabylonFileParsers;
  89699. /**
  89700. * Stores the list of available individual parsers in the application.
  89701. */
  89702. private static _IndividualBabylonFileParsers;
  89703. /**
  89704. * Adds a parser in the list of available ones
  89705. * @param name Defines the name of the parser
  89706. * @param parser Defines the parser to add
  89707. */
  89708. static AddParser(name: string, parser: BabylonFileParser): void;
  89709. /**
  89710. * Gets a general parser from the list of avaialble ones
  89711. * @param name Defines the name of the parser
  89712. * @returns the requested parser or null
  89713. */
  89714. static GetParser(name: string): Nullable<BabylonFileParser>;
  89715. /**
  89716. * Adds n individual parser in the list of available ones
  89717. * @param name Defines the name of the parser
  89718. * @param parser Defines the parser to add
  89719. */
  89720. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  89721. /**
  89722. * Gets an individual parser from the list of avaialble ones
  89723. * @param name Defines the name of the parser
  89724. * @returns the requested parser or null
  89725. */
  89726. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  89727. /**
  89728. * Parser json data and populate both a scene and its associated container object
  89729. * @param jsonData Defines the data to parse
  89730. * @param scene Defines the scene to parse the data for
  89731. * @param container Defines the container attached to the parsing sequence
  89732. * @param rootUrl Defines the root url of the data
  89733. */
  89734. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  89735. /**
  89736. * Gets the list of root nodes (ie. nodes with no parent)
  89737. */
  89738. rootNodes: Node[];
  89739. /** All of the cameras added to this scene
  89740. * @see http://doc.babylonjs.com/babylon101/cameras
  89741. */
  89742. cameras: Camera[];
  89743. /**
  89744. * All of the lights added to this scene
  89745. * @see http://doc.babylonjs.com/babylon101/lights
  89746. */
  89747. lights: Light[];
  89748. /**
  89749. * All of the (abstract) meshes added to this scene
  89750. */
  89751. meshes: AbstractMesh[];
  89752. /**
  89753. * The list of skeletons added to the scene
  89754. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  89755. */
  89756. skeletons: Skeleton[];
  89757. /**
  89758. * All of the particle systems added to this scene
  89759. * @see http://doc.babylonjs.com/babylon101/particles
  89760. */
  89761. particleSystems: IParticleSystem[];
  89762. /**
  89763. * Gets a list of Animations associated with the scene
  89764. */
  89765. animations: Animation[];
  89766. /**
  89767. * All of the animation groups added to this scene
  89768. * @see http://doc.babylonjs.com/how_to/group
  89769. */
  89770. animationGroups: AnimationGroup[];
  89771. /**
  89772. * All of the multi-materials added to this scene
  89773. * @see http://doc.babylonjs.com/how_to/multi_materials
  89774. */
  89775. multiMaterials: MultiMaterial[];
  89776. /**
  89777. * All of the materials added to this scene
  89778. * In the context of a Scene, it is not supposed to be modified manually.
  89779. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  89780. * Note also that the order of the Material wihin the array is not significant and might change.
  89781. * @see http://doc.babylonjs.com/babylon101/materials
  89782. */
  89783. materials: Material[];
  89784. /**
  89785. * The list of morph target managers added to the scene
  89786. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  89787. */
  89788. morphTargetManagers: MorphTargetManager[];
  89789. /**
  89790. * The list of geometries used in the scene.
  89791. */
  89792. geometries: Geometry[];
  89793. /**
  89794. * All of the tranform nodes added to this scene
  89795. * In the context of a Scene, it is not supposed to be modified manually.
  89796. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  89797. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  89798. * @see http://doc.babylonjs.com/how_to/transformnode
  89799. */
  89800. transformNodes: TransformNode[];
  89801. /**
  89802. * ActionManagers available on the scene.
  89803. */
  89804. actionManagers: AbstractActionManager[];
  89805. /**
  89806. * Textures to keep.
  89807. */
  89808. textures: BaseTexture[];
  89809. }
  89810. }
  89811. declare module BABYLON {
  89812. /**
  89813. * Defines a sound that can be played in the application.
  89814. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  89815. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89816. */
  89817. export class Sound {
  89818. /**
  89819. * The name of the sound in the scene.
  89820. */
  89821. name: string;
  89822. /**
  89823. * Does the sound autoplay once loaded.
  89824. */
  89825. autoplay: boolean;
  89826. /**
  89827. * Does the sound loop after it finishes playing once.
  89828. */
  89829. loop: boolean;
  89830. /**
  89831. * Does the sound use a custom attenuation curve to simulate the falloff
  89832. * happening when the source gets further away from the camera.
  89833. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  89834. */
  89835. useCustomAttenuation: boolean;
  89836. /**
  89837. * The sound track id this sound belongs to.
  89838. */
  89839. soundTrackId: number;
  89840. /**
  89841. * Is this sound currently played.
  89842. */
  89843. isPlaying: boolean;
  89844. /**
  89845. * Is this sound currently paused.
  89846. */
  89847. isPaused: boolean;
  89848. /**
  89849. * Does this sound enables spatial sound.
  89850. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89851. */
  89852. spatialSound: boolean;
  89853. /**
  89854. * Define the reference distance the sound should be heard perfectly.
  89855. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89856. */
  89857. refDistance: number;
  89858. /**
  89859. * Define the roll off factor of spatial sounds.
  89860. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89861. */
  89862. rolloffFactor: number;
  89863. /**
  89864. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  89865. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89866. */
  89867. maxDistance: number;
  89868. /**
  89869. * Define the distance attenuation model the sound will follow.
  89870. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89871. */
  89872. distanceModel: string;
  89873. /**
  89874. * @hidden
  89875. * Back Compat
  89876. **/
  89877. onended: () => any;
  89878. /**
  89879. * Observable event when the current playing sound finishes.
  89880. */
  89881. onEndedObservable: Observable<Sound>;
  89882. private _panningModel;
  89883. private _playbackRate;
  89884. private _streaming;
  89885. private _startTime;
  89886. private _startOffset;
  89887. private _position;
  89888. /** @hidden */
  89889. _positionInEmitterSpace: boolean;
  89890. private _localDirection;
  89891. private _volume;
  89892. private _isReadyToPlay;
  89893. private _isDirectional;
  89894. private _readyToPlayCallback;
  89895. private _audioBuffer;
  89896. private _soundSource;
  89897. private _streamingSource;
  89898. private _soundPanner;
  89899. private _soundGain;
  89900. private _inputAudioNode;
  89901. private _outputAudioNode;
  89902. private _coneInnerAngle;
  89903. private _coneOuterAngle;
  89904. private _coneOuterGain;
  89905. private _scene;
  89906. private _connectedTransformNode;
  89907. private _customAttenuationFunction;
  89908. private _registerFunc;
  89909. private _isOutputConnected;
  89910. private _htmlAudioElement;
  89911. private _urlType;
  89912. /** @hidden */
  89913. static _SceneComponentInitialization: (scene: Scene) => void;
  89914. /**
  89915. * Create a sound and attach it to a scene
  89916. * @param name Name of your sound
  89917. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  89918. * @param scene defines the scene the sound belongs to
  89919. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  89920. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  89921. */
  89922. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  89923. /**
  89924. * Release the sound and its associated resources
  89925. */
  89926. dispose(): void;
  89927. /**
  89928. * Gets if the sounds is ready to be played or not.
  89929. * @returns true if ready, otherwise false
  89930. */
  89931. isReady(): boolean;
  89932. private _soundLoaded;
  89933. /**
  89934. * Sets the data of the sound from an audiobuffer
  89935. * @param audioBuffer The audioBuffer containing the data
  89936. */
  89937. setAudioBuffer(audioBuffer: AudioBuffer): void;
  89938. /**
  89939. * Updates the current sounds options such as maxdistance, loop...
  89940. * @param options A JSON object containing values named as the object properties
  89941. */
  89942. updateOptions(options: any): void;
  89943. private _createSpatialParameters;
  89944. private _updateSpatialParameters;
  89945. /**
  89946. * Switch the panning model to HRTF:
  89947. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  89948. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89949. */
  89950. switchPanningModelToHRTF(): void;
  89951. /**
  89952. * Switch the panning model to Equal Power:
  89953. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  89954. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89955. */
  89956. switchPanningModelToEqualPower(): void;
  89957. private _switchPanningModel;
  89958. /**
  89959. * Connect this sound to a sound track audio node like gain...
  89960. * @param soundTrackAudioNode the sound track audio node to connect to
  89961. */
  89962. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  89963. /**
  89964. * Transform this sound into a directional source
  89965. * @param coneInnerAngle Size of the inner cone in degree
  89966. * @param coneOuterAngle Size of the outer cone in degree
  89967. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  89968. */
  89969. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  89970. /**
  89971. * Gets or sets the inner angle for the directional cone.
  89972. */
  89973. /**
  89974. * Gets or sets the inner angle for the directional cone.
  89975. */
  89976. directionalConeInnerAngle: number;
  89977. /**
  89978. * Gets or sets the outer angle for the directional cone.
  89979. */
  89980. /**
  89981. * Gets or sets the outer angle for the directional cone.
  89982. */
  89983. directionalConeOuterAngle: number;
  89984. /**
  89985. * Sets the position of the emitter if spatial sound is enabled
  89986. * @param newPosition Defines the new posisiton
  89987. */
  89988. setPosition(newPosition: Vector3): void;
  89989. /**
  89990. * Sets the local direction of the emitter if spatial sound is enabled
  89991. * @param newLocalDirection Defines the new local direction
  89992. */
  89993. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  89994. private _updateDirection;
  89995. /** @hidden */
  89996. updateDistanceFromListener(): void;
  89997. /**
  89998. * Sets a new custom attenuation function for the sound.
  89999. * @param callback Defines the function used for the attenuation
  90000. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  90001. */
  90002. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  90003. /**
  90004. * Play the sound
  90005. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  90006. * @param offset (optional) Start the sound setting it at a specific time
  90007. */
  90008. play(time?: number, offset?: number): void;
  90009. private _onended;
  90010. /**
  90011. * Stop the sound
  90012. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  90013. */
  90014. stop(time?: number): void;
  90015. /**
  90016. * Put the sound in pause
  90017. */
  90018. pause(): void;
  90019. /**
  90020. * Sets a dedicated volume for this sounds
  90021. * @param newVolume Define the new volume of the sound
  90022. * @param time Define in how long the sound should be at this value
  90023. */
  90024. setVolume(newVolume: number, time?: number): void;
  90025. /**
  90026. * Set the sound play back rate
  90027. * @param newPlaybackRate Define the playback rate the sound should be played at
  90028. */
  90029. setPlaybackRate(newPlaybackRate: number): void;
  90030. /**
  90031. * Gets the volume of the sound.
  90032. * @returns the volume of the sound
  90033. */
  90034. getVolume(): number;
  90035. /**
  90036. * Attach the sound to a dedicated mesh
  90037. * @param transformNode The transform node to connect the sound with
  90038. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  90039. */
  90040. attachToMesh(transformNode: TransformNode): void;
  90041. /**
  90042. * Detach the sound from the previously attached mesh
  90043. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  90044. */
  90045. detachFromMesh(): void;
  90046. private _onRegisterAfterWorldMatrixUpdate;
  90047. /**
  90048. * Clone the current sound in the scene.
  90049. * @returns the new sound clone
  90050. */
  90051. clone(): Nullable<Sound>;
  90052. /**
  90053. * Gets the current underlying audio buffer containing the data
  90054. * @returns the audio buffer
  90055. */
  90056. getAudioBuffer(): Nullable<AudioBuffer>;
  90057. /**
  90058. * Serializes the Sound in a JSON representation
  90059. * @returns the JSON representation of the sound
  90060. */
  90061. serialize(): any;
  90062. /**
  90063. * Parse a JSON representation of a sound to innstantiate in a given scene
  90064. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  90065. * @param scene Define the scene the new parsed sound should be created in
  90066. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  90067. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  90068. * @returns the newly parsed sound
  90069. */
  90070. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  90071. }
  90072. }
  90073. declare module BABYLON {
  90074. /**
  90075. * This defines an action helpful to play a defined sound on a triggered action.
  90076. */
  90077. export class PlaySoundAction extends Action {
  90078. private _sound;
  90079. /**
  90080. * Instantiate the action
  90081. * @param triggerOptions defines the trigger options
  90082. * @param sound defines the sound to play
  90083. * @param condition defines the trigger related conditions
  90084. */
  90085. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  90086. /** @hidden */
  90087. _prepare(): void;
  90088. /**
  90089. * Execute the action and play the sound.
  90090. */
  90091. execute(): void;
  90092. /**
  90093. * Serializes the actions and its related information.
  90094. * @param parent defines the object to serialize in
  90095. * @returns the serialized object
  90096. */
  90097. serialize(parent: any): any;
  90098. }
  90099. /**
  90100. * This defines an action helpful to stop a defined sound on a triggered action.
  90101. */
  90102. export class StopSoundAction extends Action {
  90103. private _sound;
  90104. /**
  90105. * Instantiate the action
  90106. * @param triggerOptions defines the trigger options
  90107. * @param sound defines the sound to stop
  90108. * @param condition defines the trigger related conditions
  90109. */
  90110. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  90111. /** @hidden */
  90112. _prepare(): void;
  90113. /**
  90114. * Execute the action and stop the sound.
  90115. */
  90116. execute(): void;
  90117. /**
  90118. * Serializes the actions and its related information.
  90119. * @param parent defines the object to serialize in
  90120. * @returns the serialized object
  90121. */
  90122. serialize(parent: any): any;
  90123. }
  90124. }
  90125. declare module BABYLON {
  90126. /**
  90127. * This defines an action responsible to change the value of a property
  90128. * by interpolating between its current value and the newly set one once triggered.
  90129. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90130. */
  90131. export class InterpolateValueAction extends Action {
  90132. /**
  90133. * Defines the path of the property where the value should be interpolated
  90134. */
  90135. propertyPath: string;
  90136. /**
  90137. * Defines the target value at the end of the interpolation.
  90138. */
  90139. value: any;
  90140. /**
  90141. * Defines the time it will take for the property to interpolate to the value.
  90142. */
  90143. duration: number;
  90144. /**
  90145. * Defines if the other scene animations should be stopped when the action has been triggered
  90146. */
  90147. stopOtherAnimations?: boolean;
  90148. /**
  90149. * Defines a callback raised once the interpolation animation has been done.
  90150. */
  90151. onInterpolationDone?: () => void;
  90152. /**
  90153. * Observable triggered once the interpolation animation has been done.
  90154. */
  90155. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  90156. private _target;
  90157. private _effectiveTarget;
  90158. private _property;
  90159. /**
  90160. * Instantiate the action
  90161. * @param triggerOptions defines the trigger options
  90162. * @param target defines the object containing the value to interpolate
  90163. * @param propertyPath defines the path to the property in the target object
  90164. * @param value defines the target value at the end of the interpolation
  90165. * @param duration deines the time it will take for the property to interpolate to the value.
  90166. * @param condition defines the trigger related conditions
  90167. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  90168. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  90169. */
  90170. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  90171. /** @hidden */
  90172. _prepare(): void;
  90173. /**
  90174. * Execute the action starts the value interpolation.
  90175. */
  90176. execute(): void;
  90177. /**
  90178. * Serializes the actions and its related information.
  90179. * @param parent defines the object to serialize in
  90180. * @returns the serialized object
  90181. */
  90182. serialize(parent: any): any;
  90183. }
  90184. }
  90185. declare module BABYLON {
  90186. /**
  90187. * Options allowed during the creation of a sound track.
  90188. */
  90189. export interface ISoundTrackOptions {
  90190. /**
  90191. * The volume the sound track should take during creation
  90192. */
  90193. volume?: number;
  90194. /**
  90195. * Define if the sound track is the main sound track of the scene
  90196. */
  90197. mainTrack?: boolean;
  90198. }
  90199. /**
  90200. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  90201. * It will be also used in a future release to apply effects on a specific track.
  90202. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  90203. */
  90204. export class SoundTrack {
  90205. /**
  90206. * The unique identifier of the sound track in the scene.
  90207. */
  90208. id: number;
  90209. /**
  90210. * The list of sounds included in the sound track.
  90211. */
  90212. soundCollection: Array<Sound>;
  90213. private _outputAudioNode;
  90214. private _scene;
  90215. private _isMainTrack;
  90216. private _connectedAnalyser;
  90217. private _options;
  90218. private _isInitialized;
  90219. /**
  90220. * Creates a new sound track.
  90221. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  90222. * @param scene Define the scene the sound track belongs to
  90223. * @param options
  90224. */
  90225. constructor(scene: Scene, options?: ISoundTrackOptions);
  90226. private _initializeSoundTrackAudioGraph;
  90227. /**
  90228. * Release the sound track and its associated resources
  90229. */
  90230. dispose(): void;
  90231. /**
  90232. * Adds a sound to this sound track
  90233. * @param sound define the cound to add
  90234. * @ignoreNaming
  90235. */
  90236. AddSound(sound: Sound): void;
  90237. /**
  90238. * Removes a sound to this sound track
  90239. * @param sound define the cound to remove
  90240. * @ignoreNaming
  90241. */
  90242. RemoveSound(sound: Sound): void;
  90243. /**
  90244. * Set a global volume for the full sound track.
  90245. * @param newVolume Define the new volume of the sound track
  90246. */
  90247. setVolume(newVolume: number): void;
  90248. /**
  90249. * Switch the panning model to HRTF:
  90250. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  90251. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90252. */
  90253. switchPanningModelToHRTF(): void;
  90254. /**
  90255. * Switch the panning model to Equal Power:
  90256. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  90257. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90258. */
  90259. switchPanningModelToEqualPower(): void;
  90260. /**
  90261. * Connect the sound track to an audio analyser allowing some amazing
  90262. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  90263. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  90264. * @param analyser The analyser to connect to the engine
  90265. */
  90266. connectToAnalyser(analyser: Analyser): void;
  90267. }
  90268. }
  90269. declare module BABYLON {
  90270. interface AbstractScene {
  90271. /**
  90272. * The list of sounds used in the scene.
  90273. */
  90274. sounds: Nullable<Array<Sound>>;
  90275. }
  90276. interface Scene {
  90277. /**
  90278. * @hidden
  90279. * Backing field
  90280. */
  90281. _mainSoundTrack: SoundTrack;
  90282. /**
  90283. * The main sound track played by the scene.
  90284. * It cotains your primary collection of sounds.
  90285. */
  90286. mainSoundTrack: SoundTrack;
  90287. /**
  90288. * The list of sound tracks added to the scene
  90289. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90290. */
  90291. soundTracks: Nullable<Array<SoundTrack>>;
  90292. /**
  90293. * Gets a sound using a given name
  90294. * @param name defines the name to search for
  90295. * @return the found sound or null if not found at all.
  90296. */
  90297. getSoundByName(name: string): Nullable<Sound>;
  90298. /**
  90299. * Gets or sets if audio support is enabled
  90300. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90301. */
  90302. audioEnabled: boolean;
  90303. /**
  90304. * Gets or sets if audio will be output to headphones
  90305. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90306. */
  90307. headphone: boolean;
  90308. }
  90309. /**
  90310. * Defines the sound scene component responsible to manage any sounds
  90311. * in a given scene.
  90312. */
  90313. export class AudioSceneComponent implements ISceneSerializableComponent {
  90314. /**
  90315. * The component name helpfull to identify the component in the list of scene components.
  90316. */
  90317. readonly name: string;
  90318. /**
  90319. * The scene the component belongs to.
  90320. */
  90321. scene: Scene;
  90322. private _audioEnabled;
  90323. /**
  90324. * Gets whether audio is enabled or not.
  90325. * Please use related enable/disable method to switch state.
  90326. */
  90327. readonly audioEnabled: boolean;
  90328. private _headphone;
  90329. /**
  90330. * Gets whether audio is outputing to headphone or not.
  90331. * Please use the according Switch methods to change output.
  90332. */
  90333. readonly headphone: boolean;
  90334. /**
  90335. * Creates a new instance of the component for the given scene
  90336. * @param scene Defines the scene to register the component in
  90337. */
  90338. constructor(scene: Scene);
  90339. /**
  90340. * Registers the component in a given scene
  90341. */
  90342. register(): void;
  90343. /**
  90344. * Rebuilds the elements related to this component in case of
  90345. * context lost for instance.
  90346. */
  90347. rebuild(): void;
  90348. /**
  90349. * Serializes the component data to the specified json object
  90350. * @param serializationObject The object to serialize to
  90351. */
  90352. serialize(serializationObject: any): void;
  90353. /**
  90354. * Adds all the element from the container to the scene
  90355. * @param container the container holding the elements
  90356. */
  90357. addFromContainer(container: AbstractScene): void;
  90358. /**
  90359. * Removes all the elements in the container from the scene
  90360. * @param container contains the elements to remove
  90361. */
  90362. removeFromContainer(container: AbstractScene): void;
  90363. /**
  90364. * Disposes the component and the associated ressources.
  90365. */
  90366. dispose(): void;
  90367. /**
  90368. * Disables audio in the associated scene.
  90369. */
  90370. disableAudio(): void;
  90371. /**
  90372. * Enables audio in the associated scene.
  90373. */
  90374. enableAudio(): void;
  90375. /**
  90376. * Switch audio to headphone output.
  90377. */
  90378. switchAudioModeForHeadphones(): void;
  90379. /**
  90380. * Switch audio to normal speakers.
  90381. */
  90382. switchAudioModeForNormalSpeakers(): void;
  90383. private _afterRender;
  90384. }
  90385. }
  90386. declare module BABYLON {
  90387. /**
  90388. * Wraps one or more Sound objects and selects one with random weight for playback.
  90389. */
  90390. export class WeightedSound {
  90391. /** When true a Sound will be selected and played when the current playing Sound completes. */
  90392. loop: boolean;
  90393. private _coneInnerAngle;
  90394. private _coneOuterAngle;
  90395. private _volume;
  90396. /** A Sound is currently playing. */
  90397. isPlaying: boolean;
  90398. /** A Sound is currently paused. */
  90399. isPaused: boolean;
  90400. private _sounds;
  90401. private _weights;
  90402. private _currentIndex?;
  90403. /**
  90404. * Creates a new WeightedSound from the list of sounds given.
  90405. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  90406. * @param sounds Array of Sounds that will be selected from.
  90407. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  90408. */
  90409. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  90410. /**
  90411. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  90412. */
  90413. /**
  90414. * The size of cone in degress for a directional sound in which there will be no attenuation.
  90415. */
  90416. directionalConeInnerAngle: number;
  90417. /**
  90418. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  90419. * Listener angles between innerAngle and outerAngle will falloff linearly.
  90420. */
  90421. /**
  90422. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  90423. * Listener angles between innerAngle and outerAngle will falloff linearly.
  90424. */
  90425. directionalConeOuterAngle: number;
  90426. /**
  90427. * Playback volume.
  90428. */
  90429. /**
  90430. * Playback volume.
  90431. */
  90432. volume: number;
  90433. private _onended;
  90434. /**
  90435. * Suspend playback
  90436. */
  90437. pause(): void;
  90438. /**
  90439. * Stop playback
  90440. */
  90441. stop(): void;
  90442. /**
  90443. * Start playback.
  90444. * @param startOffset Position the clip head at a specific time in seconds.
  90445. */
  90446. play(startOffset?: number): void;
  90447. }
  90448. }
  90449. declare module BABYLON {
  90450. /**
  90451. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  90452. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  90453. */
  90454. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  90455. /**
  90456. * Gets the name of the behavior.
  90457. */
  90458. readonly name: string;
  90459. /**
  90460. * The easing function used by animations
  90461. */
  90462. static EasingFunction: BackEase;
  90463. /**
  90464. * The easing mode used by animations
  90465. */
  90466. static EasingMode: number;
  90467. /**
  90468. * The duration of the animation, in milliseconds
  90469. */
  90470. transitionDuration: number;
  90471. /**
  90472. * Length of the distance animated by the transition when lower radius is reached
  90473. */
  90474. lowerRadiusTransitionRange: number;
  90475. /**
  90476. * Length of the distance animated by the transition when upper radius is reached
  90477. */
  90478. upperRadiusTransitionRange: number;
  90479. private _autoTransitionRange;
  90480. /**
  90481. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  90482. */
  90483. /**
  90484. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  90485. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  90486. */
  90487. autoTransitionRange: boolean;
  90488. private _attachedCamera;
  90489. private _onAfterCheckInputsObserver;
  90490. private _onMeshTargetChangedObserver;
  90491. /**
  90492. * Initializes the behavior.
  90493. */
  90494. init(): void;
  90495. /**
  90496. * Attaches the behavior to its arc rotate camera.
  90497. * @param camera Defines the camera to attach the behavior to
  90498. */
  90499. attach(camera: ArcRotateCamera): void;
  90500. /**
  90501. * Detaches the behavior from its current arc rotate camera.
  90502. */
  90503. detach(): void;
  90504. private _radiusIsAnimating;
  90505. private _radiusBounceTransition;
  90506. private _animatables;
  90507. private _cachedWheelPrecision;
  90508. /**
  90509. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  90510. * @param radiusLimit The limit to check against.
  90511. * @return Bool to indicate if at limit.
  90512. */
  90513. private _isRadiusAtLimit;
  90514. /**
  90515. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  90516. * @param radiusDelta The delta by which to animate to. Can be negative.
  90517. */
  90518. private _applyBoundRadiusAnimation;
  90519. /**
  90520. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  90521. */
  90522. protected _clearAnimationLocks(): void;
  90523. /**
  90524. * Stops and removes all animations that have been applied to the camera
  90525. */
  90526. stopAllAnimations(): void;
  90527. }
  90528. }
  90529. declare module BABYLON {
  90530. /**
  90531. * 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.
  90532. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  90533. */
  90534. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  90535. /**
  90536. * Gets the name of the behavior.
  90537. */
  90538. readonly name: string;
  90539. private _mode;
  90540. private _radiusScale;
  90541. private _positionScale;
  90542. private _defaultElevation;
  90543. private _elevationReturnTime;
  90544. private _elevationReturnWaitTime;
  90545. private _zoomStopsAnimation;
  90546. private _framingTime;
  90547. /**
  90548. * The easing function used by animations
  90549. */
  90550. static EasingFunction: ExponentialEase;
  90551. /**
  90552. * The easing mode used by animations
  90553. */
  90554. static EasingMode: number;
  90555. /**
  90556. * Sets the current mode used by the behavior
  90557. */
  90558. /**
  90559. * Gets current mode used by the behavior.
  90560. */
  90561. mode: number;
  90562. /**
  90563. * Sets the scale applied to the radius (1 by default)
  90564. */
  90565. /**
  90566. * Gets the scale applied to the radius
  90567. */
  90568. radiusScale: number;
  90569. /**
  90570. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  90571. */
  90572. /**
  90573. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  90574. */
  90575. positionScale: number;
  90576. /**
  90577. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  90578. * behaviour is triggered, in radians.
  90579. */
  90580. /**
  90581. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  90582. * behaviour is triggered, in radians.
  90583. */
  90584. defaultElevation: number;
  90585. /**
  90586. * Sets the time (in milliseconds) taken to return to the default beta position.
  90587. * Negative value indicates camera should not return to default.
  90588. */
  90589. /**
  90590. * Gets the time (in milliseconds) taken to return to the default beta position.
  90591. * Negative value indicates camera should not return to default.
  90592. */
  90593. elevationReturnTime: number;
  90594. /**
  90595. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  90596. */
  90597. /**
  90598. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  90599. */
  90600. elevationReturnWaitTime: number;
  90601. /**
  90602. * Sets the flag that indicates if user zooming should stop animation.
  90603. */
  90604. /**
  90605. * Gets the flag that indicates if user zooming should stop animation.
  90606. */
  90607. zoomStopsAnimation: boolean;
  90608. /**
  90609. * Sets the transition time when framing the mesh, in milliseconds
  90610. */
  90611. /**
  90612. * Gets the transition time when framing the mesh, in milliseconds
  90613. */
  90614. framingTime: number;
  90615. /**
  90616. * Define if the behavior should automatically change the configured
  90617. * camera limits and sensibilities.
  90618. */
  90619. autoCorrectCameraLimitsAndSensibility: boolean;
  90620. private _onPrePointerObservableObserver;
  90621. private _onAfterCheckInputsObserver;
  90622. private _onMeshTargetChangedObserver;
  90623. private _attachedCamera;
  90624. private _isPointerDown;
  90625. private _lastInteractionTime;
  90626. /**
  90627. * Initializes the behavior.
  90628. */
  90629. init(): void;
  90630. /**
  90631. * Attaches the behavior to its arc rotate camera.
  90632. * @param camera Defines the camera to attach the behavior to
  90633. */
  90634. attach(camera: ArcRotateCamera): void;
  90635. /**
  90636. * Detaches the behavior from its current arc rotate camera.
  90637. */
  90638. detach(): void;
  90639. private _animatables;
  90640. private _betaIsAnimating;
  90641. private _betaTransition;
  90642. private _radiusTransition;
  90643. private _vectorTransition;
  90644. /**
  90645. * Targets the given mesh and updates zoom level accordingly.
  90646. * @param mesh The mesh to target.
  90647. * @param radius Optional. If a cached radius position already exists, overrides default.
  90648. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  90649. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  90650. * @param onAnimationEnd Callback triggered at the end of the framing animation
  90651. */
  90652. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  90653. /**
  90654. * Targets the given mesh with its children and updates zoom level accordingly.
  90655. * @param mesh The mesh to target.
  90656. * @param radius Optional. If a cached radius position already exists, overrides default.
  90657. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  90658. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  90659. * @param onAnimationEnd Callback triggered at the end of the framing animation
  90660. */
  90661. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  90662. /**
  90663. * Targets the given meshes with their children and updates zoom level accordingly.
  90664. * @param meshes The mesh to target.
  90665. * @param radius Optional. If a cached radius position already exists, overrides default.
  90666. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  90667. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  90668. * @param onAnimationEnd Callback triggered at the end of the framing animation
  90669. */
  90670. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  90671. /**
  90672. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  90673. * @param minimumWorld Determines the smaller position of the bounding box extend
  90674. * @param maximumWorld Determines the bigger position of the bounding box extend
  90675. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  90676. * @param onAnimationEnd Callback triggered at the end of the framing animation
  90677. */
  90678. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  90679. /**
  90680. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  90681. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  90682. * frustum width.
  90683. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  90684. * to fully enclose the mesh in the viewing frustum.
  90685. */
  90686. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  90687. /**
  90688. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  90689. * is automatically returned to its default position (expected to be above ground plane).
  90690. */
  90691. private _maintainCameraAboveGround;
  90692. /**
  90693. * Returns the frustum slope based on the canvas ratio and camera FOV
  90694. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  90695. */
  90696. private _getFrustumSlope;
  90697. /**
  90698. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  90699. */
  90700. private _clearAnimationLocks;
  90701. /**
  90702. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  90703. */
  90704. private _applyUserInteraction;
  90705. /**
  90706. * Stops and removes all animations that have been applied to the camera
  90707. */
  90708. stopAllAnimations(): void;
  90709. /**
  90710. * Gets a value indicating if the user is moving the camera
  90711. */
  90712. readonly isUserIsMoving: boolean;
  90713. /**
  90714. * The camera can move all the way towards the mesh.
  90715. */
  90716. static IgnoreBoundsSizeMode: number;
  90717. /**
  90718. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  90719. */
  90720. static FitFrustumSidesMode: number;
  90721. }
  90722. }
  90723. declare module BABYLON {
  90724. /**
  90725. * Manage the pointers inputs to control an arc rotate camera.
  90726. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  90727. */
  90728. export class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  90729. /**
  90730. * Defines the camera the input is attached to.
  90731. */
  90732. camera: ArcRotateCamera;
  90733. /**
  90734. * Defines the buttons associated with the input to handle camera move.
  90735. */
  90736. buttons: number[];
  90737. /**
  90738. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  90739. */
  90740. angularSensibilityX: number;
  90741. /**
  90742. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  90743. */
  90744. angularSensibilityY: number;
  90745. /**
  90746. * Defines the pointer pinch precision or how fast is the camera zooming.
  90747. */
  90748. pinchPrecision: number;
  90749. /**
  90750. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  90751. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  90752. */
  90753. pinchDeltaPercentage: number;
  90754. /**
  90755. * Defines the pointer panning sensibility or how fast is the camera moving.
  90756. */
  90757. panningSensibility: number;
  90758. /**
  90759. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  90760. */
  90761. multiTouchPanning: boolean;
  90762. /**
  90763. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  90764. */
  90765. multiTouchPanAndZoom: boolean;
  90766. /**
  90767. * Revers pinch action direction.
  90768. */
  90769. pinchInwards: boolean;
  90770. private _isPanClick;
  90771. private _pointerInput;
  90772. private _observer;
  90773. private _onMouseMove;
  90774. private _onGestureStart;
  90775. private _onGesture;
  90776. private _MSGestureHandler;
  90777. private _onLostFocus;
  90778. private _onContextMenu;
  90779. /**
  90780. * Attach the input controls to a specific dom element to get the input from.
  90781. * @param element Defines the element the controls should be listened from
  90782. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90783. */
  90784. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  90785. /**
  90786. * Detach the current controls from the specified dom element.
  90787. * @param element Defines the element to stop listening the inputs from
  90788. */
  90789. detachControl(element: Nullable<HTMLElement>): void;
  90790. /**
  90791. * Gets the class name of the current intput.
  90792. * @returns the class name
  90793. */
  90794. getClassName(): string;
  90795. /**
  90796. * Get the friendly name associated with the input class.
  90797. * @returns the input friendly name
  90798. */
  90799. getSimpleName(): string;
  90800. }
  90801. }
  90802. declare module BABYLON {
  90803. /**
  90804. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  90805. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  90806. */
  90807. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  90808. /**
  90809. * Defines the camera the input is attached to.
  90810. */
  90811. camera: ArcRotateCamera;
  90812. /**
  90813. * Defines the list of key codes associated with the up action (increase alpha)
  90814. */
  90815. keysUp: number[];
  90816. /**
  90817. * Defines the list of key codes associated with the down action (decrease alpha)
  90818. */
  90819. keysDown: number[];
  90820. /**
  90821. * Defines the list of key codes associated with the left action (increase beta)
  90822. */
  90823. keysLeft: number[];
  90824. /**
  90825. * Defines the list of key codes associated with the right action (decrease beta)
  90826. */
  90827. keysRight: number[];
  90828. /**
  90829. * Defines the list of key codes associated with the reset action.
  90830. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  90831. */
  90832. keysReset: number[];
  90833. /**
  90834. * Defines the panning sensibility of the inputs.
  90835. * (How fast is the camera paning)
  90836. */
  90837. panningSensibility: number;
  90838. /**
  90839. * Defines the zooming sensibility of the inputs.
  90840. * (How fast is the camera zooming)
  90841. */
  90842. zoomingSensibility: number;
  90843. /**
  90844. * Defines wether maintaining the alt key down switch the movement mode from
  90845. * orientation to zoom.
  90846. */
  90847. useAltToZoom: boolean;
  90848. /**
  90849. * Rotation speed of the camera
  90850. */
  90851. angularSpeed: number;
  90852. private _keys;
  90853. private _ctrlPressed;
  90854. private _altPressed;
  90855. private _onCanvasBlurObserver;
  90856. private _onKeyboardObserver;
  90857. private _engine;
  90858. private _scene;
  90859. /**
  90860. * Attach the input controls to a specific dom element to get the input from.
  90861. * @param element Defines the element the controls should be listened from
  90862. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90863. */
  90864. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  90865. /**
  90866. * Detach the current controls from the specified dom element.
  90867. * @param element Defines the element to stop listening the inputs from
  90868. */
  90869. detachControl(element: Nullable<HTMLElement>): void;
  90870. /**
  90871. * Update the current camera state depending on the inputs that have been used this frame.
  90872. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  90873. */
  90874. checkInputs(): void;
  90875. /**
  90876. * Gets the class name of the current intput.
  90877. * @returns the class name
  90878. */
  90879. getClassName(): string;
  90880. /**
  90881. * Get the friendly name associated with the input class.
  90882. * @returns the input friendly name
  90883. */
  90884. getSimpleName(): string;
  90885. }
  90886. }
  90887. declare module BABYLON {
  90888. /**
  90889. * Manage the mouse wheel inputs to control an arc rotate camera.
  90890. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  90891. */
  90892. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  90893. /**
  90894. * Defines the camera the input is attached to.
  90895. */
  90896. camera: ArcRotateCamera;
  90897. /**
  90898. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  90899. */
  90900. wheelPrecision: number;
  90901. /**
  90902. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  90903. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  90904. */
  90905. wheelDeltaPercentage: number;
  90906. private _wheel;
  90907. private _observer;
  90908. /**
  90909. * Attach the input controls to a specific dom element to get the input from.
  90910. * @param element Defines the element the controls should be listened from
  90911. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90912. */
  90913. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  90914. /**
  90915. * Detach the current controls from the specified dom element.
  90916. * @param element Defines the element to stop listening the inputs from
  90917. */
  90918. detachControl(element: Nullable<HTMLElement>): void;
  90919. /**
  90920. * Gets the class name of the current intput.
  90921. * @returns the class name
  90922. */
  90923. getClassName(): string;
  90924. /**
  90925. * Get the friendly name associated with the input class.
  90926. * @returns the input friendly name
  90927. */
  90928. getSimpleName(): string;
  90929. }
  90930. }
  90931. declare module BABYLON {
  90932. /**
  90933. * Default Inputs manager for the ArcRotateCamera.
  90934. * It groups all the default supported inputs for ease of use.
  90935. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  90936. */
  90937. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  90938. /**
  90939. * Instantiates a new ArcRotateCameraInputsManager.
  90940. * @param camera Defines the camera the inputs belong to
  90941. */
  90942. constructor(camera: ArcRotateCamera);
  90943. /**
  90944. * Add mouse wheel input support to the input manager.
  90945. * @returns the current input manager
  90946. */
  90947. addMouseWheel(): ArcRotateCameraInputsManager;
  90948. /**
  90949. * Add pointers input support to the input manager.
  90950. * @returns the current input manager
  90951. */
  90952. addPointers(): ArcRotateCameraInputsManager;
  90953. /**
  90954. * Add keyboard input support to the input manager.
  90955. * @returns the current input manager
  90956. */
  90957. addKeyboard(): ArcRotateCameraInputsManager;
  90958. }
  90959. }
  90960. declare module BABYLON {
  90961. /**
  90962. * This represents an orbital type of camera.
  90963. *
  90964. * 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.
  90965. * 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.
  90966. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  90967. */
  90968. export class ArcRotateCamera extends TargetCamera {
  90969. /**
  90970. * Defines the rotation angle of the camera along the longitudinal axis.
  90971. */
  90972. alpha: number;
  90973. /**
  90974. * Defines the rotation angle of the camera along the latitudinal axis.
  90975. */
  90976. beta: number;
  90977. /**
  90978. * Defines the radius of the camera from it s target point.
  90979. */
  90980. radius: number;
  90981. protected _target: Vector3;
  90982. protected _targetHost: Nullable<AbstractMesh>;
  90983. /**
  90984. * Defines the target point of the camera.
  90985. * The camera looks towards it form the radius distance.
  90986. */
  90987. target: Vector3;
  90988. /**
  90989. * Define the current local position of the camera in the scene
  90990. */
  90991. position: Vector3;
  90992. /**
  90993. * Current inertia value on the longitudinal axis.
  90994. * The bigger this number the longer it will take for the camera to stop.
  90995. */
  90996. inertialAlphaOffset: number;
  90997. /**
  90998. * Current inertia value on the latitudinal axis.
  90999. * The bigger this number the longer it will take for the camera to stop.
  91000. */
  91001. inertialBetaOffset: number;
  91002. /**
  91003. * Current inertia value on the radius axis.
  91004. * The bigger this number the longer it will take for the camera to stop.
  91005. */
  91006. inertialRadiusOffset: number;
  91007. /**
  91008. * Minimum allowed angle on the longitudinal axis.
  91009. * This can help limiting how the Camera is able to move in the scene.
  91010. */
  91011. lowerAlphaLimit: Nullable<number>;
  91012. /**
  91013. * Maximum allowed angle on the longitudinal axis.
  91014. * This can help limiting how the Camera is able to move in the scene.
  91015. */
  91016. upperAlphaLimit: Nullable<number>;
  91017. /**
  91018. * Minimum allowed angle on the latitudinal axis.
  91019. * This can help limiting how the Camera is able to move in the scene.
  91020. */
  91021. lowerBetaLimit: number;
  91022. /**
  91023. * Maximum allowed angle on the latitudinal axis.
  91024. * This can help limiting how the Camera is able to move in the scene.
  91025. */
  91026. upperBetaLimit: number;
  91027. /**
  91028. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  91029. * This can help limiting how the Camera is able to move in the scene.
  91030. */
  91031. lowerRadiusLimit: Nullable<number>;
  91032. /**
  91033. * Maximum allowed distance of the camera to the target (The camera can not get further).
  91034. * This can help limiting how the Camera is able to move in the scene.
  91035. */
  91036. upperRadiusLimit: Nullable<number>;
  91037. /**
  91038. * Defines the current inertia value used during panning of the camera along the X axis.
  91039. */
  91040. inertialPanningX: number;
  91041. /**
  91042. * Defines the current inertia value used during panning of the camera along the Y axis.
  91043. */
  91044. inertialPanningY: number;
  91045. /**
  91046. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  91047. * Basically if your fingers moves away from more than this distance you will be considered
  91048. * in pinch mode.
  91049. */
  91050. pinchToPanMaxDistance: number;
  91051. /**
  91052. * Defines the maximum distance the camera can pan.
  91053. * This could help keeping the cammera always in your scene.
  91054. */
  91055. panningDistanceLimit: Nullable<number>;
  91056. /**
  91057. * Defines the target of the camera before paning.
  91058. */
  91059. panningOriginTarget: Vector3;
  91060. /**
  91061. * Defines the value of the inertia used during panning.
  91062. * 0 would mean stop inertia and one would mean no decelleration at all.
  91063. */
  91064. panningInertia: number;
  91065. /**
  91066. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  91067. */
  91068. angularSensibilityX: number;
  91069. /**
  91070. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  91071. */
  91072. angularSensibilityY: number;
  91073. /**
  91074. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  91075. */
  91076. pinchPrecision: number;
  91077. /**
  91078. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  91079. * It will be used instead of pinchDeltaPrecision if different from 0.
  91080. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  91081. */
  91082. pinchDeltaPercentage: number;
  91083. /**
  91084. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  91085. */
  91086. panningSensibility: number;
  91087. /**
  91088. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  91089. */
  91090. keysUp: number[];
  91091. /**
  91092. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  91093. */
  91094. keysDown: number[];
  91095. /**
  91096. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  91097. */
  91098. keysLeft: number[];
  91099. /**
  91100. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  91101. */
  91102. keysRight: number[];
  91103. /**
  91104. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  91105. */
  91106. wheelPrecision: number;
  91107. /**
  91108. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  91109. * It will be used instead of pinchDeltaPrecision if different from 0.
  91110. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  91111. */
  91112. wheelDeltaPercentage: number;
  91113. /**
  91114. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  91115. */
  91116. zoomOnFactor: number;
  91117. /**
  91118. * Defines a screen offset for the camera position.
  91119. */
  91120. targetScreenOffset: Vector2;
  91121. /**
  91122. * Allows the camera to be completely reversed.
  91123. * If false the camera can not arrive upside down.
  91124. */
  91125. allowUpsideDown: boolean;
  91126. /**
  91127. * Define if double tap/click is used to restore the previously saved state of the camera.
  91128. */
  91129. useInputToRestoreState: boolean;
  91130. /** @hidden */
  91131. _viewMatrix: Matrix;
  91132. /** @hidden */
  91133. _useCtrlForPanning: boolean;
  91134. /** @hidden */
  91135. _panningMouseButton: number;
  91136. /**
  91137. * Defines the input associated to the camera.
  91138. */
  91139. inputs: ArcRotateCameraInputsManager;
  91140. /** @hidden */
  91141. _reset: () => void;
  91142. /**
  91143. * Defines the allowed panning axis.
  91144. */
  91145. panningAxis: Vector3;
  91146. protected _localDirection: Vector3;
  91147. protected _transformedDirection: Vector3;
  91148. private _bouncingBehavior;
  91149. /**
  91150. * Gets the bouncing behavior of the camera if it has been enabled.
  91151. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  91152. */
  91153. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  91154. /**
  91155. * Defines if the bouncing behavior of the camera is enabled on the camera.
  91156. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  91157. */
  91158. useBouncingBehavior: boolean;
  91159. private _framingBehavior;
  91160. /**
  91161. * Gets the framing behavior of the camera if it has been enabled.
  91162. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  91163. */
  91164. readonly framingBehavior: Nullable<FramingBehavior>;
  91165. /**
  91166. * Defines if the framing behavior of the camera is enabled on the camera.
  91167. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  91168. */
  91169. useFramingBehavior: boolean;
  91170. private _autoRotationBehavior;
  91171. /**
  91172. * Gets the auto rotation behavior of the camera if it has been enabled.
  91173. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  91174. */
  91175. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  91176. /**
  91177. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  91178. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  91179. */
  91180. useAutoRotationBehavior: boolean;
  91181. /**
  91182. * Observable triggered when the mesh target has been changed on the camera.
  91183. */
  91184. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  91185. /**
  91186. * Event raised when the camera is colliding with a mesh.
  91187. */
  91188. onCollide: (collidedMesh: AbstractMesh) => void;
  91189. /**
  91190. * Defines whether the camera should check collision with the objects oh the scene.
  91191. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  91192. */
  91193. checkCollisions: boolean;
  91194. /**
  91195. * Defines the collision radius of the camera.
  91196. * This simulates a sphere around the camera.
  91197. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  91198. */
  91199. collisionRadius: Vector3;
  91200. protected _collider: Collider;
  91201. protected _previousPosition: Vector3;
  91202. protected _collisionVelocity: Vector3;
  91203. protected _newPosition: Vector3;
  91204. protected _previousAlpha: number;
  91205. protected _previousBeta: number;
  91206. protected _previousRadius: number;
  91207. protected _collisionTriggered: boolean;
  91208. protected _targetBoundingCenter: Nullable<Vector3>;
  91209. private _computationVector;
  91210. private _tempAxisVector;
  91211. private _tempAxisRotationMatrix;
  91212. /**
  91213. * Instantiates a new ArcRotateCamera in a given scene
  91214. * @param name Defines the name of the camera
  91215. * @param alpha Defines the camera rotation along the logitudinal axis
  91216. * @param beta Defines the camera rotation along the latitudinal axis
  91217. * @param radius Defines the camera distance from its target
  91218. * @param target Defines the camera target
  91219. * @param scene Defines the scene the camera belongs to
  91220. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  91221. */
  91222. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  91223. /** @hidden */
  91224. _initCache(): void;
  91225. /** @hidden */
  91226. _updateCache(ignoreParentClass?: boolean): void;
  91227. protected _getTargetPosition(): Vector3;
  91228. private _storedAlpha;
  91229. private _storedBeta;
  91230. private _storedRadius;
  91231. private _storedTarget;
  91232. /**
  91233. * Stores the current state of the camera (alpha, beta, radius and target)
  91234. * @returns the camera itself
  91235. */
  91236. storeState(): Camera;
  91237. /**
  91238. * @hidden
  91239. * Restored camera state. You must call storeState() first
  91240. */
  91241. _restoreStateValues(): boolean;
  91242. /** @hidden */
  91243. _isSynchronizedViewMatrix(): boolean;
  91244. /**
  91245. * Attached controls to the current camera.
  91246. * @param element Defines the element the controls should be listened from
  91247. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91248. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  91249. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  91250. */
  91251. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  91252. /**
  91253. * Detach the current controls from the camera.
  91254. * The camera will stop reacting to inputs.
  91255. * @param element Defines the element to stop listening the inputs from
  91256. */
  91257. detachControl(element: HTMLElement): void;
  91258. /** @hidden */
  91259. _checkInputs(): void;
  91260. protected _checkLimits(): void;
  91261. /**
  91262. * Rebuilds angles (alpha, beta) and radius from the give position and target
  91263. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  91264. */
  91265. rebuildAnglesAndRadius(updateView?: boolean): void;
  91266. /**
  91267. * Use a position to define the current camera related information like aplha, beta and radius
  91268. * @param position Defines the position to set the camera at
  91269. */
  91270. setPosition(position: Vector3): void;
  91271. /**
  91272. * Defines the target the camera should look at.
  91273. * This will automatically adapt alpha beta and radius to fit within the new target.
  91274. * @param target Defines the new target as a Vector or a mesh
  91275. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  91276. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  91277. */
  91278. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  91279. /** @hidden */
  91280. _getViewMatrix(): Matrix;
  91281. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  91282. /**
  91283. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  91284. * @param meshes Defines the mesh to zoom on
  91285. * @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)
  91286. */
  91287. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  91288. /**
  91289. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  91290. * The target will be changed but the radius
  91291. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  91292. * @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)
  91293. */
  91294. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  91295. min: Vector3;
  91296. max: Vector3;
  91297. distance: number;
  91298. }, doNotUpdateMaxZ?: boolean): void;
  91299. /**
  91300. * @override
  91301. * Override Camera.createRigCamera
  91302. */
  91303. createRigCamera(name: string, cameraIndex: number): Camera;
  91304. /**
  91305. * @hidden
  91306. * @override
  91307. * Override Camera._updateRigCameras
  91308. */
  91309. _updateRigCameras(): void;
  91310. /**
  91311. * Destroy the camera and release the current resources hold by it.
  91312. */
  91313. dispose(): void;
  91314. /**
  91315. * Gets the current object class name.
  91316. * @return the class name
  91317. */
  91318. getClassName(): string;
  91319. }
  91320. }
  91321. declare module BABYLON {
  91322. /**
  91323. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  91324. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  91325. */
  91326. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  91327. /**
  91328. * Gets the name of the behavior.
  91329. */
  91330. readonly name: string;
  91331. private _zoomStopsAnimation;
  91332. private _idleRotationSpeed;
  91333. private _idleRotationWaitTime;
  91334. private _idleRotationSpinupTime;
  91335. /**
  91336. * Sets the flag that indicates if user zooming should stop animation.
  91337. */
  91338. /**
  91339. * Gets the flag that indicates if user zooming should stop animation.
  91340. */
  91341. zoomStopsAnimation: boolean;
  91342. /**
  91343. * Sets the default speed at which the camera rotates around the model.
  91344. */
  91345. /**
  91346. * Gets the default speed at which the camera rotates around the model.
  91347. */
  91348. idleRotationSpeed: number;
  91349. /**
  91350. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  91351. */
  91352. /**
  91353. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  91354. */
  91355. idleRotationWaitTime: number;
  91356. /**
  91357. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  91358. */
  91359. /**
  91360. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  91361. */
  91362. idleRotationSpinupTime: number;
  91363. /**
  91364. * Gets a value indicating if the camera is currently rotating because of this behavior
  91365. */
  91366. readonly rotationInProgress: boolean;
  91367. private _onPrePointerObservableObserver;
  91368. private _onAfterCheckInputsObserver;
  91369. private _attachedCamera;
  91370. private _isPointerDown;
  91371. private _lastFrameTime;
  91372. private _lastInteractionTime;
  91373. private _cameraRotationSpeed;
  91374. /**
  91375. * Initializes the behavior.
  91376. */
  91377. init(): void;
  91378. /**
  91379. * Attaches the behavior to its arc rotate camera.
  91380. * @param camera Defines the camera to attach the behavior to
  91381. */
  91382. attach(camera: ArcRotateCamera): void;
  91383. /**
  91384. * Detaches the behavior from its current arc rotate camera.
  91385. */
  91386. detach(): void;
  91387. /**
  91388. * Returns true if user is scrolling.
  91389. * @return true if user is scrolling.
  91390. */
  91391. private _userIsZooming;
  91392. private _lastFrameRadius;
  91393. private _shouldAnimationStopForInteraction;
  91394. /**
  91395. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  91396. */
  91397. private _applyUserInteraction;
  91398. private _userIsMoving;
  91399. }
  91400. }
  91401. declare module BABYLON {
  91402. /**
  91403. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  91404. */
  91405. export class AttachToBoxBehavior implements Behavior<Mesh> {
  91406. private ui;
  91407. /**
  91408. * The name of the behavior
  91409. */
  91410. name: string;
  91411. /**
  91412. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  91413. */
  91414. distanceAwayFromFace: number;
  91415. /**
  91416. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  91417. */
  91418. distanceAwayFromBottomOfFace: number;
  91419. private _faceVectors;
  91420. private _target;
  91421. private _scene;
  91422. private _onRenderObserver;
  91423. private _tmpMatrix;
  91424. private _tmpVector;
  91425. /**
  91426. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  91427. * @param ui The transform node that should be attched to the mesh
  91428. */
  91429. constructor(ui: TransformNode);
  91430. /**
  91431. * Initializes the behavior
  91432. */
  91433. init(): void;
  91434. private _closestFace;
  91435. private _zeroVector;
  91436. private _lookAtTmpMatrix;
  91437. private _lookAtToRef;
  91438. /**
  91439. * Attaches the AttachToBoxBehavior to the passed in mesh
  91440. * @param target The mesh that the specified node will be attached to
  91441. */
  91442. attach(target: Mesh): void;
  91443. /**
  91444. * Detaches the behavior from the mesh
  91445. */
  91446. detach(): void;
  91447. }
  91448. }
  91449. declare module BABYLON {
  91450. /**
  91451. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  91452. */
  91453. export class FadeInOutBehavior implements Behavior<Mesh> {
  91454. /**
  91455. * Time in milliseconds to delay before fading in (Default: 0)
  91456. */
  91457. delay: number;
  91458. /**
  91459. * Time in milliseconds for the mesh to fade in (Default: 300)
  91460. */
  91461. fadeInTime: number;
  91462. private _millisecondsPerFrame;
  91463. private _hovered;
  91464. private _hoverValue;
  91465. private _ownerNode;
  91466. /**
  91467. * Instatiates the FadeInOutBehavior
  91468. */
  91469. constructor();
  91470. /**
  91471. * The name of the behavior
  91472. */
  91473. readonly name: string;
  91474. /**
  91475. * Initializes the behavior
  91476. */
  91477. init(): void;
  91478. /**
  91479. * Attaches the fade behavior on the passed in mesh
  91480. * @param ownerNode The mesh that will be faded in/out once attached
  91481. */
  91482. attach(ownerNode: Mesh): void;
  91483. /**
  91484. * Detaches the behavior from the mesh
  91485. */
  91486. detach(): void;
  91487. /**
  91488. * Triggers the mesh to begin fading in or out
  91489. * @param value if the object should fade in or out (true to fade in)
  91490. */
  91491. fadeIn(value: boolean): void;
  91492. private _update;
  91493. private _setAllVisibility;
  91494. }
  91495. }
  91496. declare module BABYLON {
  91497. /**
  91498. * Class containing a set of static utilities functions for managing Pivots
  91499. * @hidden
  91500. */
  91501. export class PivotTools {
  91502. private static _PivotCached;
  91503. private static _OldPivotPoint;
  91504. private static _PivotTranslation;
  91505. private static _PivotTmpVector;
  91506. /** @hidden */
  91507. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  91508. /** @hidden */
  91509. static _RestorePivotPoint(mesh: AbstractMesh): void;
  91510. }
  91511. }
  91512. declare module BABYLON {
  91513. /**
  91514. * Class containing static functions to help procedurally build meshes
  91515. */
  91516. export class PlaneBuilder {
  91517. /**
  91518. * Creates a plane mesh
  91519. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  91520. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  91521. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  91522. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  91523. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  91524. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91525. * @param name defines the name of the mesh
  91526. * @param options defines the options used to create the mesh
  91527. * @param scene defines the hosting scene
  91528. * @returns the plane mesh
  91529. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  91530. */
  91531. static CreatePlane(name: string, options: {
  91532. size?: number;
  91533. width?: number;
  91534. height?: number;
  91535. sideOrientation?: number;
  91536. frontUVs?: Vector4;
  91537. backUVs?: Vector4;
  91538. updatable?: boolean;
  91539. sourcePlane?: Plane;
  91540. }, scene: Scene): Mesh;
  91541. }
  91542. }
  91543. declare module BABYLON {
  91544. /**
  91545. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  91546. */
  91547. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  91548. private static _AnyMouseID;
  91549. private _attachedNode;
  91550. private _dragPlane;
  91551. private _scene;
  91552. private _pointerObserver;
  91553. private _beforeRenderObserver;
  91554. private static _planeScene;
  91555. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  91556. /**
  91557. * 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)
  91558. */
  91559. maxDragAngle: number;
  91560. /**
  91561. * @hidden
  91562. */
  91563. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  91564. /**
  91565. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  91566. */
  91567. currentDraggingPointerID: number;
  91568. /**
  91569. * The last position where the pointer hit the drag plane in world space
  91570. */
  91571. lastDragPosition: Vector3;
  91572. /**
  91573. * If the behavior is currently in a dragging state
  91574. */
  91575. dragging: boolean;
  91576. /**
  91577. * 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)
  91578. */
  91579. dragDeltaRatio: number;
  91580. /**
  91581. * If the drag plane orientation should be updated during the dragging (Default: true)
  91582. */
  91583. updateDragPlane: boolean;
  91584. private _debugMode;
  91585. private _moving;
  91586. /**
  91587. * Fires each time the attached mesh is dragged with the pointer
  91588. * * delta between last drag position and current drag position in world space
  91589. * * dragDistance along the drag axis
  91590. * * dragPlaneNormal normal of the current drag plane used during the drag
  91591. * * dragPlanePoint in world space where the drag intersects the drag plane
  91592. */
  91593. onDragObservable: Observable<{
  91594. delta: Vector3;
  91595. dragPlanePoint: Vector3;
  91596. dragPlaneNormal: Vector3;
  91597. dragDistance: number;
  91598. pointerId: number;
  91599. }>;
  91600. /**
  91601. * Fires each time a drag begins (eg. mouse down on mesh)
  91602. */
  91603. onDragStartObservable: Observable<{
  91604. dragPlanePoint: Vector3;
  91605. pointerId: number;
  91606. }>;
  91607. /**
  91608. * Fires each time a drag ends (eg. mouse release after drag)
  91609. */
  91610. onDragEndObservable: Observable<{
  91611. dragPlanePoint: Vector3;
  91612. pointerId: number;
  91613. }>;
  91614. /**
  91615. * If the attached mesh should be moved when dragged
  91616. */
  91617. moveAttached: boolean;
  91618. /**
  91619. * If the drag behavior will react to drag events (Default: true)
  91620. */
  91621. enabled: boolean;
  91622. /**
  91623. * If camera controls should be detached during the drag
  91624. */
  91625. detachCameraControls: boolean;
  91626. /**
  91627. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  91628. */
  91629. useObjectOrienationForDragging: boolean;
  91630. private _options;
  91631. /**
  91632. * Creates a pointer drag behavior that can be attached to a mesh
  91633. * @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)
  91634. */
  91635. constructor(options?: {
  91636. dragAxis?: Vector3;
  91637. dragPlaneNormal?: Vector3;
  91638. });
  91639. /**
  91640. * Predicate to determine if it is valid to move the object to a new position when it is moved
  91641. */
  91642. validateDrag: (targetPosition: Vector3) => boolean;
  91643. /**
  91644. * The name of the behavior
  91645. */
  91646. readonly name: string;
  91647. /**
  91648. * Initializes the behavior
  91649. */
  91650. init(): void;
  91651. private _tmpVector;
  91652. private _alternatePickedPoint;
  91653. private _worldDragAxis;
  91654. private _targetPosition;
  91655. private _attachedElement;
  91656. /**
  91657. * Attaches the drag behavior the passed in mesh
  91658. * @param ownerNode The mesh that will be dragged around once attached
  91659. */
  91660. attach(ownerNode: AbstractMesh): void;
  91661. /**
  91662. * Force relase the drag action by code.
  91663. */
  91664. releaseDrag(): void;
  91665. private _startDragRay;
  91666. private _lastPointerRay;
  91667. /**
  91668. * Simulates the start of a pointer drag event on the behavior
  91669. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  91670. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  91671. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  91672. */
  91673. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  91674. private _startDrag;
  91675. private _dragDelta;
  91676. private _moveDrag;
  91677. private _pickWithRayOnDragPlane;
  91678. private _pointA;
  91679. private _pointB;
  91680. private _pointC;
  91681. private _lineA;
  91682. private _lineB;
  91683. private _localAxis;
  91684. private _lookAt;
  91685. private _updateDragPlanePosition;
  91686. /**
  91687. * Detaches the behavior from the mesh
  91688. */
  91689. detach(): void;
  91690. }
  91691. }
  91692. declare module BABYLON {
  91693. /**
  91694. * A behavior that when attached to a mesh will allow the mesh to be scaled
  91695. */
  91696. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  91697. private _dragBehaviorA;
  91698. private _dragBehaviorB;
  91699. private _startDistance;
  91700. private _initialScale;
  91701. private _targetScale;
  91702. private _ownerNode;
  91703. private _sceneRenderObserver;
  91704. /**
  91705. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  91706. */
  91707. constructor();
  91708. /**
  91709. * The name of the behavior
  91710. */
  91711. readonly name: string;
  91712. /**
  91713. * Initializes the behavior
  91714. */
  91715. init(): void;
  91716. private _getCurrentDistance;
  91717. /**
  91718. * Attaches the scale behavior the passed in mesh
  91719. * @param ownerNode The mesh that will be scaled around once attached
  91720. */
  91721. attach(ownerNode: Mesh): void;
  91722. /**
  91723. * Detaches the behavior from the mesh
  91724. */
  91725. detach(): void;
  91726. }
  91727. }
  91728. declare module BABYLON {
  91729. /**
  91730. * 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
  91731. */
  91732. export class SixDofDragBehavior implements Behavior<Mesh> {
  91733. private static _virtualScene;
  91734. private _ownerNode;
  91735. private _sceneRenderObserver;
  91736. private _scene;
  91737. private _targetPosition;
  91738. private _virtualOriginMesh;
  91739. private _virtualDragMesh;
  91740. private _pointerObserver;
  91741. private _moving;
  91742. private _startingOrientation;
  91743. /**
  91744. * 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)
  91745. */
  91746. private zDragFactor;
  91747. /**
  91748. * If the object should rotate to face the drag origin
  91749. */
  91750. rotateDraggedObject: boolean;
  91751. /**
  91752. * If the behavior is currently in a dragging state
  91753. */
  91754. dragging: boolean;
  91755. /**
  91756. * 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)
  91757. */
  91758. dragDeltaRatio: number;
  91759. /**
  91760. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  91761. */
  91762. currentDraggingPointerID: number;
  91763. /**
  91764. * If camera controls should be detached during the drag
  91765. */
  91766. detachCameraControls: boolean;
  91767. /**
  91768. * Fires each time a drag starts
  91769. */
  91770. onDragStartObservable: Observable<{}>;
  91771. /**
  91772. * Fires each time a drag ends (eg. mouse release after drag)
  91773. */
  91774. onDragEndObservable: Observable<{}>;
  91775. /**
  91776. * 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
  91777. */
  91778. constructor();
  91779. /**
  91780. * The name of the behavior
  91781. */
  91782. readonly name: string;
  91783. /**
  91784. * Initializes the behavior
  91785. */
  91786. init(): void;
  91787. /**
  91788. * Attaches the scale behavior the passed in mesh
  91789. * @param ownerNode The mesh that will be scaled around once attached
  91790. */
  91791. attach(ownerNode: Mesh): void;
  91792. /**
  91793. * Detaches the behavior from the mesh
  91794. */
  91795. detach(): void;
  91796. }
  91797. }
  91798. declare module BABYLON {
  91799. /**
  91800. * Class used to apply inverse kinematics to bones
  91801. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  91802. */
  91803. export class BoneIKController {
  91804. private static _tmpVecs;
  91805. private static _tmpQuat;
  91806. private static _tmpMats;
  91807. /**
  91808. * Gets or sets the target mesh
  91809. */
  91810. targetMesh: AbstractMesh;
  91811. /** Gets or sets the mesh used as pole */
  91812. poleTargetMesh: AbstractMesh;
  91813. /**
  91814. * Gets or sets the bone used as pole
  91815. */
  91816. poleTargetBone: Nullable<Bone>;
  91817. /**
  91818. * Gets or sets the target position
  91819. */
  91820. targetPosition: Vector3;
  91821. /**
  91822. * Gets or sets the pole target position
  91823. */
  91824. poleTargetPosition: Vector3;
  91825. /**
  91826. * Gets or sets the pole target local offset
  91827. */
  91828. poleTargetLocalOffset: Vector3;
  91829. /**
  91830. * Gets or sets the pole angle
  91831. */
  91832. poleAngle: number;
  91833. /**
  91834. * Gets or sets the mesh associated with the controller
  91835. */
  91836. mesh: AbstractMesh;
  91837. /**
  91838. * 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)
  91839. */
  91840. slerpAmount: number;
  91841. private _bone1Quat;
  91842. private _bone1Mat;
  91843. private _bone2Ang;
  91844. private _bone1;
  91845. private _bone2;
  91846. private _bone1Length;
  91847. private _bone2Length;
  91848. private _maxAngle;
  91849. private _maxReach;
  91850. private _rightHandedSystem;
  91851. private _bendAxis;
  91852. private _slerping;
  91853. private _adjustRoll;
  91854. /**
  91855. * Gets or sets maximum allowed angle
  91856. */
  91857. maxAngle: number;
  91858. /**
  91859. * Creates a new BoneIKController
  91860. * @param mesh defines the mesh to control
  91861. * @param bone defines the bone to control
  91862. * @param options defines options to set up the controller
  91863. */
  91864. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  91865. targetMesh?: AbstractMesh;
  91866. poleTargetMesh?: AbstractMesh;
  91867. poleTargetBone?: Bone;
  91868. poleTargetLocalOffset?: Vector3;
  91869. poleAngle?: number;
  91870. bendAxis?: Vector3;
  91871. maxAngle?: number;
  91872. slerpAmount?: number;
  91873. });
  91874. private _setMaxAngle;
  91875. /**
  91876. * Force the controller to update the bones
  91877. */
  91878. update(): void;
  91879. }
  91880. }
  91881. declare module BABYLON {
  91882. /**
  91883. * Class used to make a bone look toward a point in space
  91884. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  91885. */
  91886. export class BoneLookController {
  91887. private static _tmpVecs;
  91888. private static _tmpQuat;
  91889. private static _tmpMats;
  91890. /**
  91891. * The target Vector3 that the bone will look at
  91892. */
  91893. target: Vector3;
  91894. /**
  91895. * The mesh that the bone is attached to
  91896. */
  91897. mesh: AbstractMesh;
  91898. /**
  91899. * The bone that will be looking to the target
  91900. */
  91901. bone: Bone;
  91902. /**
  91903. * The up axis of the coordinate system that is used when the bone is rotated
  91904. */
  91905. upAxis: Vector3;
  91906. /**
  91907. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  91908. */
  91909. upAxisSpace: Space;
  91910. /**
  91911. * Used to make an adjustment to the yaw of the bone
  91912. */
  91913. adjustYaw: number;
  91914. /**
  91915. * Used to make an adjustment to the pitch of the bone
  91916. */
  91917. adjustPitch: number;
  91918. /**
  91919. * Used to make an adjustment to the roll of the bone
  91920. */
  91921. adjustRoll: number;
  91922. /**
  91923. * 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)
  91924. */
  91925. slerpAmount: number;
  91926. private _minYaw;
  91927. private _maxYaw;
  91928. private _minPitch;
  91929. private _maxPitch;
  91930. private _minYawSin;
  91931. private _minYawCos;
  91932. private _maxYawSin;
  91933. private _maxYawCos;
  91934. private _midYawConstraint;
  91935. private _minPitchTan;
  91936. private _maxPitchTan;
  91937. private _boneQuat;
  91938. private _slerping;
  91939. private _transformYawPitch;
  91940. private _transformYawPitchInv;
  91941. private _firstFrameSkipped;
  91942. private _yawRange;
  91943. private _fowardAxis;
  91944. /**
  91945. * Gets or sets the minimum yaw angle that the bone can look to
  91946. */
  91947. minYaw: number;
  91948. /**
  91949. * Gets or sets the maximum yaw angle that the bone can look to
  91950. */
  91951. maxYaw: number;
  91952. /**
  91953. * Gets or sets the minimum pitch angle that the bone can look to
  91954. */
  91955. minPitch: number;
  91956. /**
  91957. * Gets or sets the maximum pitch angle that the bone can look to
  91958. */
  91959. maxPitch: number;
  91960. /**
  91961. * Create a BoneLookController
  91962. * @param mesh the mesh that the bone belongs to
  91963. * @param bone the bone that will be looking to the target
  91964. * @param target the target Vector3 to look at
  91965. * @param options optional settings:
  91966. * * maxYaw: the maximum angle the bone will yaw to
  91967. * * minYaw: the minimum angle the bone will yaw to
  91968. * * maxPitch: the maximum angle the bone will pitch to
  91969. * * minPitch: the minimum angle the bone will yaw to
  91970. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  91971. * * upAxis: the up axis of the coordinate system
  91972. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  91973. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  91974. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  91975. * * adjustYaw: used to make an adjustment to the yaw of the bone
  91976. * * adjustPitch: used to make an adjustment to the pitch of the bone
  91977. * * adjustRoll: used to make an adjustment to the roll of the bone
  91978. **/
  91979. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  91980. maxYaw?: number;
  91981. minYaw?: number;
  91982. maxPitch?: number;
  91983. minPitch?: number;
  91984. slerpAmount?: number;
  91985. upAxis?: Vector3;
  91986. upAxisSpace?: Space;
  91987. yawAxis?: Vector3;
  91988. pitchAxis?: Vector3;
  91989. adjustYaw?: number;
  91990. adjustPitch?: number;
  91991. adjustRoll?: number;
  91992. });
  91993. /**
  91994. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  91995. */
  91996. update(): void;
  91997. private _getAngleDiff;
  91998. private _getAngleBetween;
  91999. private _isAngleBetween;
  92000. }
  92001. }
  92002. declare module BABYLON {
  92003. /**
  92004. * Manage the gamepad inputs to control an arc rotate camera.
  92005. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92006. */
  92007. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  92008. /**
  92009. * Defines the camera the input is attached to.
  92010. */
  92011. camera: ArcRotateCamera;
  92012. /**
  92013. * Defines the gamepad the input is gathering event from.
  92014. */
  92015. gamepad: Nullable<Gamepad>;
  92016. /**
  92017. * Defines the gamepad rotation sensiblity.
  92018. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  92019. */
  92020. gamepadRotationSensibility: number;
  92021. /**
  92022. * Defines the gamepad move sensiblity.
  92023. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  92024. */
  92025. gamepadMoveSensibility: number;
  92026. private _onGamepadConnectedObserver;
  92027. private _onGamepadDisconnectedObserver;
  92028. /**
  92029. * Attach the input controls to a specific dom element to get the input from.
  92030. * @param element Defines the element the controls should be listened from
  92031. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92032. */
  92033. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92034. /**
  92035. * Detach the current controls from the specified dom element.
  92036. * @param element Defines the element to stop listening the inputs from
  92037. */
  92038. detachControl(element: Nullable<HTMLElement>): void;
  92039. /**
  92040. * Update the current camera state depending on the inputs that have been used this frame.
  92041. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92042. */
  92043. checkInputs(): void;
  92044. /**
  92045. * Gets the class name of the current intput.
  92046. * @returns the class name
  92047. */
  92048. getClassName(): string;
  92049. /**
  92050. * Get the friendly name associated with the input class.
  92051. * @returns the input friendly name
  92052. */
  92053. getSimpleName(): string;
  92054. }
  92055. }
  92056. declare module BABYLON {
  92057. interface ArcRotateCameraInputsManager {
  92058. /**
  92059. * Add orientation input support to the input manager.
  92060. * @returns the current input manager
  92061. */
  92062. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  92063. }
  92064. /**
  92065. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  92066. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92067. */
  92068. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  92069. /**
  92070. * Defines the camera the input is attached to.
  92071. */
  92072. camera: ArcRotateCamera;
  92073. /**
  92074. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  92075. */
  92076. alphaCorrection: number;
  92077. /**
  92078. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  92079. */
  92080. gammaCorrection: number;
  92081. private _alpha;
  92082. private _gamma;
  92083. private _dirty;
  92084. private _deviceOrientationHandler;
  92085. /**
  92086. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  92087. */
  92088. constructor();
  92089. /**
  92090. * Attach the input controls to a specific dom element to get the input from.
  92091. * @param element Defines the element the controls should be listened from
  92092. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92093. */
  92094. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92095. /** @hidden */
  92096. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  92097. /**
  92098. * Update the current camera state depending on the inputs that have been used this frame.
  92099. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92100. */
  92101. checkInputs(): void;
  92102. /**
  92103. * Detach the current controls from the specified dom element.
  92104. * @param element Defines the element to stop listening the inputs from
  92105. */
  92106. detachControl(element: Nullable<HTMLElement>): void;
  92107. /**
  92108. * Gets the class name of the current intput.
  92109. * @returns the class name
  92110. */
  92111. getClassName(): string;
  92112. /**
  92113. * Get the friendly name associated with the input class.
  92114. * @returns the input friendly name
  92115. */
  92116. getSimpleName(): string;
  92117. }
  92118. }
  92119. declare module BABYLON {
  92120. /**
  92121. * Listen to mouse events to control the camera.
  92122. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92123. */
  92124. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  92125. /**
  92126. * Defines the camera the input is attached to.
  92127. */
  92128. camera: FlyCamera;
  92129. /**
  92130. * Defines if touch is enabled. (Default is true.)
  92131. */
  92132. touchEnabled: boolean;
  92133. /**
  92134. * Defines the buttons associated with the input to handle camera rotation.
  92135. */
  92136. buttons: number[];
  92137. /**
  92138. * Assign buttons for Yaw control.
  92139. */
  92140. buttonsYaw: number[];
  92141. /**
  92142. * Assign buttons for Pitch control.
  92143. */
  92144. buttonsPitch: number[];
  92145. /**
  92146. * Assign buttons for Roll control.
  92147. */
  92148. buttonsRoll: number[];
  92149. /**
  92150. * Detect if any button is being pressed while mouse is moved.
  92151. * -1 = Mouse locked.
  92152. * 0 = Left button.
  92153. * 1 = Middle Button.
  92154. * 2 = Right Button.
  92155. */
  92156. activeButton: number;
  92157. /**
  92158. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  92159. * Higher values reduce its sensitivity.
  92160. */
  92161. angularSensibility: number;
  92162. private _mousemoveCallback;
  92163. private _observer;
  92164. private _rollObserver;
  92165. private previousPosition;
  92166. private noPreventDefault;
  92167. private element;
  92168. /**
  92169. * Listen to mouse events to control the camera.
  92170. * @param touchEnabled Define if touch is enabled. (Default is true.)
  92171. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92172. */
  92173. constructor(touchEnabled?: boolean);
  92174. /**
  92175. * Attach the mouse control to the HTML DOM element.
  92176. * @param element Defines the element that listens to the input events.
  92177. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  92178. */
  92179. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92180. /**
  92181. * Detach the current controls from the specified dom element.
  92182. * @param element Defines the element to stop listening the inputs from
  92183. */
  92184. detachControl(element: Nullable<HTMLElement>): void;
  92185. /**
  92186. * Gets the class name of the current input.
  92187. * @returns the class name.
  92188. */
  92189. getClassName(): string;
  92190. /**
  92191. * Get the friendly name associated with the input class.
  92192. * @returns the input's friendly name.
  92193. */
  92194. getSimpleName(): string;
  92195. private _pointerInput;
  92196. private _onMouseMove;
  92197. /**
  92198. * Rotate camera by mouse offset.
  92199. */
  92200. private rotateCamera;
  92201. }
  92202. }
  92203. declare module BABYLON {
  92204. /**
  92205. * Default Inputs manager for the FlyCamera.
  92206. * It groups all the default supported inputs for ease of use.
  92207. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92208. */
  92209. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  92210. /**
  92211. * Instantiates a new FlyCameraInputsManager.
  92212. * @param camera Defines the camera the inputs belong to.
  92213. */
  92214. constructor(camera: FlyCamera);
  92215. /**
  92216. * Add keyboard input support to the input manager.
  92217. * @returns the new FlyCameraKeyboardMoveInput().
  92218. */
  92219. addKeyboard(): FlyCameraInputsManager;
  92220. /**
  92221. * Add mouse input support to the input manager.
  92222. * @param touchEnabled Enable touch screen support.
  92223. * @returns the new FlyCameraMouseInput().
  92224. */
  92225. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  92226. }
  92227. }
  92228. declare module BABYLON {
  92229. /**
  92230. * This is a flying camera, designed for 3D movement and rotation in all directions,
  92231. * such as in a 3D Space Shooter or a Flight Simulator.
  92232. */
  92233. export class FlyCamera extends TargetCamera {
  92234. /**
  92235. * Define the collision ellipsoid of the camera.
  92236. * This is helpful for simulating a camera body, like a player's body.
  92237. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  92238. */
  92239. ellipsoid: Vector3;
  92240. /**
  92241. * Define an offset for the position of the ellipsoid around the camera.
  92242. * This can be helpful if the camera is attached away from the player's body center,
  92243. * such as at its head.
  92244. */
  92245. ellipsoidOffset: Vector3;
  92246. /**
  92247. * Enable or disable collisions of the camera with the rest of the scene objects.
  92248. */
  92249. checkCollisions: boolean;
  92250. /**
  92251. * Enable or disable gravity on the camera.
  92252. */
  92253. applyGravity: boolean;
  92254. /**
  92255. * Define the current direction the camera is moving to.
  92256. */
  92257. cameraDirection: Vector3;
  92258. /**
  92259. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  92260. * This overrides and empties cameraRotation.
  92261. */
  92262. rotationQuaternion: Quaternion;
  92263. /**
  92264. * Track Roll to maintain the wanted Rolling when looking around.
  92265. */
  92266. _trackRoll: number;
  92267. /**
  92268. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  92269. */
  92270. rollCorrect: number;
  92271. /**
  92272. * Mimic a banked turn, Rolling the camera when Yawing.
  92273. * It's recommended to use rollCorrect = 10 for faster banking correction.
  92274. */
  92275. bankedTurn: boolean;
  92276. /**
  92277. * Limit in radians for how much Roll banking will add. (Default: 90°)
  92278. */
  92279. bankedTurnLimit: number;
  92280. /**
  92281. * Value of 0 disables the banked Roll.
  92282. * Value of 1 is equal to the Yaw angle in radians.
  92283. */
  92284. bankedTurnMultiplier: number;
  92285. /**
  92286. * The inputs manager loads all the input sources, such as keyboard and mouse.
  92287. */
  92288. inputs: FlyCameraInputsManager;
  92289. /**
  92290. * Gets the input sensibility for mouse input.
  92291. * Higher values reduce sensitivity.
  92292. */
  92293. /**
  92294. * Sets the input sensibility for a mouse input.
  92295. * Higher values reduce sensitivity.
  92296. */
  92297. angularSensibility: number;
  92298. /**
  92299. * Get the keys for camera movement forward.
  92300. */
  92301. /**
  92302. * Set the keys for camera movement forward.
  92303. */
  92304. keysForward: number[];
  92305. /**
  92306. * Get the keys for camera movement backward.
  92307. */
  92308. keysBackward: number[];
  92309. /**
  92310. * Get the keys for camera movement up.
  92311. */
  92312. /**
  92313. * Set the keys for camera movement up.
  92314. */
  92315. keysUp: number[];
  92316. /**
  92317. * Get the keys for camera movement down.
  92318. */
  92319. /**
  92320. * Set the keys for camera movement down.
  92321. */
  92322. keysDown: number[];
  92323. /**
  92324. * Get the keys for camera movement left.
  92325. */
  92326. /**
  92327. * Set the keys for camera movement left.
  92328. */
  92329. keysLeft: number[];
  92330. /**
  92331. * Set the keys for camera movement right.
  92332. */
  92333. /**
  92334. * Set the keys for camera movement right.
  92335. */
  92336. keysRight: number[];
  92337. /**
  92338. * Event raised when the camera collides with a mesh in the scene.
  92339. */
  92340. onCollide: (collidedMesh: AbstractMesh) => void;
  92341. private _collider;
  92342. private _needMoveForGravity;
  92343. private _oldPosition;
  92344. private _diffPosition;
  92345. private _newPosition;
  92346. /** @hidden */
  92347. _localDirection: Vector3;
  92348. /** @hidden */
  92349. _transformedDirection: Vector3;
  92350. /**
  92351. * Instantiates a FlyCamera.
  92352. * This is a flying camera, designed for 3D movement and rotation in all directions,
  92353. * such as in a 3D Space Shooter or a Flight Simulator.
  92354. * @param name Define the name of the camera in the scene.
  92355. * @param position Define the starting position of the camera in the scene.
  92356. * @param scene Define the scene the camera belongs to.
  92357. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  92358. */
  92359. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  92360. /**
  92361. * Attach a control to the HTML DOM element.
  92362. * @param element Defines the element that listens to the input events.
  92363. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  92364. */
  92365. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92366. /**
  92367. * Detach a control from the HTML DOM element.
  92368. * The camera will stop reacting to that input.
  92369. * @param element Defines the element that listens to the input events.
  92370. */
  92371. detachControl(element: HTMLElement): void;
  92372. private _collisionMask;
  92373. /**
  92374. * Get the mask that the camera ignores in collision events.
  92375. */
  92376. /**
  92377. * Set the mask that the camera ignores in collision events.
  92378. */
  92379. collisionMask: number;
  92380. /** @hidden */
  92381. _collideWithWorld(displacement: Vector3): void;
  92382. /** @hidden */
  92383. private _onCollisionPositionChange;
  92384. /** @hidden */
  92385. _checkInputs(): void;
  92386. /** @hidden */
  92387. _decideIfNeedsToMove(): boolean;
  92388. /** @hidden */
  92389. _updatePosition(): void;
  92390. /**
  92391. * Restore the Roll to its target value at the rate specified.
  92392. * @param rate - Higher means slower restoring.
  92393. * @hidden
  92394. */
  92395. restoreRoll(rate: number): void;
  92396. /**
  92397. * Destroy the camera and release the current resources held by it.
  92398. */
  92399. dispose(): void;
  92400. /**
  92401. * Get the current object class name.
  92402. * @returns the class name.
  92403. */
  92404. getClassName(): string;
  92405. }
  92406. }
  92407. declare module BABYLON {
  92408. /**
  92409. * Listen to keyboard events to control the camera.
  92410. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92411. */
  92412. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  92413. /**
  92414. * Defines the camera the input is attached to.
  92415. */
  92416. camera: FlyCamera;
  92417. /**
  92418. * The list of keyboard keys used to control the forward move of the camera.
  92419. */
  92420. keysForward: number[];
  92421. /**
  92422. * The list of keyboard keys used to control the backward move of the camera.
  92423. */
  92424. keysBackward: number[];
  92425. /**
  92426. * The list of keyboard keys used to control the forward move of the camera.
  92427. */
  92428. keysUp: number[];
  92429. /**
  92430. * The list of keyboard keys used to control the backward move of the camera.
  92431. */
  92432. keysDown: number[];
  92433. /**
  92434. * The list of keyboard keys used to control the right strafe move of the camera.
  92435. */
  92436. keysRight: number[];
  92437. /**
  92438. * The list of keyboard keys used to control the left strafe move of the camera.
  92439. */
  92440. keysLeft: number[];
  92441. private _keys;
  92442. private _onCanvasBlurObserver;
  92443. private _onKeyboardObserver;
  92444. private _engine;
  92445. private _scene;
  92446. /**
  92447. * Attach the input controls to a specific dom element to get the input from.
  92448. * @param element Defines the element the controls should be listened from
  92449. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92450. */
  92451. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92452. /**
  92453. * Detach the current controls from the specified dom element.
  92454. * @param element Defines the element to stop listening the inputs from
  92455. */
  92456. detachControl(element: Nullable<HTMLElement>): void;
  92457. /**
  92458. * Gets the class name of the current intput.
  92459. * @returns the class name
  92460. */
  92461. getClassName(): string;
  92462. /** @hidden */
  92463. _onLostFocus(e: FocusEvent): void;
  92464. /**
  92465. * Get the friendly name associated with the input class.
  92466. * @returns the input friendly name
  92467. */
  92468. getSimpleName(): string;
  92469. /**
  92470. * Update the current camera state depending on the inputs that have been used this frame.
  92471. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92472. */
  92473. checkInputs(): void;
  92474. }
  92475. }
  92476. declare module BABYLON {
  92477. interface FreeCameraInputsManager {
  92478. /**
  92479. * Add orientation input support to the input manager.
  92480. * @returns the current input manager
  92481. */
  92482. addDeviceOrientation(): FreeCameraInputsManager;
  92483. }
  92484. /**
  92485. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  92486. * Screen rotation is taken into account.
  92487. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92488. */
  92489. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  92490. private _camera;
  92491. private _screenOrientationAngle;
  92492. private _constantTranform;
  92493. private _screenQuaternion;
  92494. private _alpha;
  92495. private _beta;
  92496. private _gamma;
  92497. /**
  92498. * Instantiates a new input
  92499. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92500. */
  92501. constructor();
  92502. /**
  92503. * Define the camera controlled by the input.
  92504. */
  92505. camera: FreeCamera;
  92506. /**
  92507. * Attach the input controls to a specific dom element to get the input from.
  92508. * @param element Defines the element the controls should be listened from
  92509. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92510. */
  92511. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92512. private _orientationChanged;
  92513. private _deviceOrientation;
  92514. /**
  92515. * Detach the current controls from the specified dom element.
  92516. * @param element Defines the element to stop listening the inputs from
  92517. */
  92518. detachControl(element: Nullable<HTMLElement>): void;
  92519. /**
  92520. * Update the current camera state depending on the inputs that have been used this frame.
  92521. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92522. */
  92523. checkInputs(): void;
  92524. /**
  92525. * Gets the class name of the current intput.
  92526. * @returns the class name
  92527. */
  92528. getClassName(): string;
  92529. /**
  92530. * Get the friendly name associated with the input class.
  92531. * @returns the input friendly name
  92532. */
  92533. getSimpleName(): string;
  92534. }
  92535. }
  92536. declare module BABYLON {
  92537. /**
  92538. * Manage the gamepad inputs to control a free camera.
  92539. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92540. */
  92541. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  92542. /**
  92543. * Define the camera the input is attached to.
  92544. */
  92545. camera: FreeCamera;
  92546. /**
  92547. * Define the Gamepad controlling the input
  92548. */
  92549. gamepad: Nullable<Gamepad>;
  92550. /**
  92551. * Defines the gamepad rotation sensiblity.
  92552. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  92553. */
  92554. gamepadAngularSensibility: number;
  92555. /**
  92556. * Defines the gamepad move sensiblity.
  92557. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  92558. */
  92559. gamepadMoveSensibility: number;
  92560. private _onGamepadConnectedObserver;
  92561. private _onGamepadDisconnectedObserver;
  92562. private _cameraTransform;
  92563. private _deltaTransform;
  92564. private _vector3;
  92565. private _vector2;
  92566. /**
  92567. * Attach the input controls to a specific dom element to get the input from.
  92568. * @param element Defines the element the controls should be listened from
  92569. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92570. */
  92571. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92572. /**
  92573. * Detach the current controls from the specified dom element.
  92574. * @param element Defines the element to stop listening the inputs from
  92575. */
  92576. detachControl(element: Nullable<HTMLElement>): void;
  92577. /**
  92578. * Update the current camera state depending on the inputs that have been used this frame.
  92579. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92580. */
  92581. checkInputs(): void;
  92582. /**
  92583. * Gets the class name of the current intput.
  92584. * @returns the class name
  92585. */
  92586. getClassName(): string;
  92587. /**
  92588. * Get the friendly name associated with the input class.
  92589. * @returns the input friendly name
  92590. */
  92591. getSimpleName(): string;
  92592. }
  92593. }
  92594. declare module BABYLON {
  92595. /**
  92596. * Defines the potential axis of a Joystick
  92597. */
  92598. export enum JoystickAxis {
  92599. /** X axis */
  92600. X = 0,
  92601. /** Y axis */
  92602. Y = 1,
  92603. /** Z axis */
  92604. Z = 2
  92605. }
  92606. /**
  92607. * Class used to define virtual joystick (used in touch mode)
  92608. */
  92609. export class VirtualJoystick {
  92610. /**
  92611. * Gets or sets a boolean indicating that left and right values must be inverted
  92612. */
  92613. reverseLeftRight: boolean;
  92614. /**
  92615. * Gets or sets a boolean indicating that up and down values must be inverted
  92616. */
  92617. reverseUpDown: boolean;
  92618. /**
  92619. * Gets the offset value for the position (ie. the change of the position value)
  92620. */
  92621. deltaPosition: Vector3;
  92622. /**
  92623. * Gets a boolean indicating if the virtual joystick was pressed
  92624. */
  92625. pressed: boolean;
  92626. /**
  92627. * Canvas the virtual joystick will render onto, default z-index of this is 5
  92628. */
  92629. static Canvas: Nullable<HTMLCanvasElement>;
  92630. private static _globalJoystickIndex;
  92631. private static vjCanvasContext;
  92632. private static vjCanvasWidth;
  92633. private static vjCanvasHeight;
  92634. private static halfWidth;
  92635. private _action;
  92636. private _axisTargetedByLeftAndRight;
  92637. private _axisTargetedByUpAndDown;
  92638. private _joystickSensibility;
  92639. private _inversedSensibility;
  92640. private _joystickPointerID;
  92641. private _joystickColor;
  92642. private _joystickPointerPos;
  92643. private _joystickPreviousPointerPos;
  92644. private _joystickPointerStartPos;
  92645. private _deltaJoystickVector;
  92646. private _leftJoystick;
  92647. private _touches;
  92648. private _onPointerDownHandlerRef;
  92649. private _onPointerMoveHandlerRef;
  92650. private _onPointerUpHandlerRef;
  92651. private _onResize;
  92652. /**
  92653. * Creates a new virtual joystick
  92654. * @param leftJoystick defines that the joystick is for left hand (false by default)
  92655. */
  92656. constructor(leftJoystick?: boolean);
  92657. /**
  92658. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  92659. * @param newJoystickSensibility defines the new sensibility
  92660. */
  92661. setJoystickSensibility(newJoystickSensibility: number): void;
  92662. private _onPointerDown;
  92663. private _onPointerMove;
  92664. private _onPointerUp;
  92665. /**
  92666. * Change the color of the virtual joystick
  92667. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  92668. */
  92669. setJoystickColor(newColor: string): void;
  92670. /**
  92671. * Defines a callback to call when the joystick is touched
  92672. * @param action defines the callback
  92673. */
  92674. setActionOnTouch(action: () => any): void;
  92675. /**
  92676. * Defines which axis you'd like to control for left & right
  92677. * @param axis defines the axis to use
  92678. */
  92679. setAxisForLeftRight(axis: JoystickAxis): void;
  92680. /**
  92681. * Defines which axis you'd like to control for up & down
  92682. * @param axis defines the axis to use
  92683. */
  92684. setAxisForUpDown(axis: JoystickAxis): void;
  92685. private _drawVirtualJoystick;
  92686. /**
  92687. * Release internal HTML canvas
  92688. */
  92689. releaseCanvas(): void;
  92690. }
  92691. }
  92692. declare module BABYLON {
  92693. interface FreeCameraInputsManager {
  92694. /**
  92695. * Add virtual joystick input support to the input manager.
  92696. * @returns the current input manager
  92697. */
  92698. addVirtualJoystick(): FreeCameraInputsManager;
  92699. }
  92700. /**
  92701. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  92702. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92703. */
  92704. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  92705. /**
  92706. * Defines the camera the input is attached to.
  92707. */
  92708. camera: FreeCamera;
  92709. private _leftjoystick;
  92710. private _rightjoystick;
  92711. /**
  92712. * Gets the left stick of the virtual joystick.
  92713. * @returns The virtual Joystick
  92714. */
  92715. getLeftJoystick(): VirtualJoystick;
  92716. /**
  92717. * Gets the right stick of the virtual joystick.
  92718. * @returns The virtual Joystick
  92719. */
  92720. getRightJoystick(): VirtualJoystick;
  92721. /**
  92722. * Update the current camera state depending on the inputs that have been used this frame.
  92723. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92724. */
  92725. checkInputs(): void;
  92726. /**
  92727. * Attach the input controls to a specific dom element to get the input from.
  92728. * @param element Defines the element the controls should be listened from
  92729. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92730. */
  92731. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92732. /**
  92733. * Detach the current controls from the specified dom element.
  92734. * @param element Defines the element to stop listening the inputs from
  92735. */
  92736. detachControl(element: Nullable<HTMLElement>): void;
  92737. /**
  92738. * Gets the class name of the current intput.
  92739. * @returns the class name
  92740. */
  92741. getClassName(): string;
  92742. /**
  92743. * Get the friendly name associated with the input class.
  92744. * @returns the input friendly name
  92745. */
  92746. getSimpleName(): string;
  92747. }
  92748. }
  92749. declare module BABYLON {
  92750. /**
  92751. * This represents a FPS type of camera controlled by touch.
  92752. * This is like a universal camera minus the Gamepad controls.
  92753. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92754. */
  92755. export class TouchCamera extends FreeCamera {
  92756. /**
  92757. * Defines the touch sensibility for rotation.
  92758. * The higher the faster.
  92759. */
  92760. touchAngularSensibility: number;
  92761. /**
  92762. * Defines the touch sensibility for move.
  92763. * The higher the faster.
  92764. */
  92765. touchMoveSensibility: number;
  92766. /**
  92767. * Instantiates a new touch camera.
  92768. * This represents a FPS type of camera controlled by touch.
  92769. * This is like a universal camera minus the Gamepad controls.
  92770. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92771. * @param name Define the name of the camera in the scene
  92772. * @param position Define the start position of the camera in the scene
  92773. * @param scene Define the scene the camera belongs to
  92774. */
  92775. constructor(name: string, position: Vector3, scene: Scene);
  92776. /**
  92777. * Gets the current object class name.
  92778. * @return the class name
  92779. */
  92780. getClassName(): string;
  92781. /** @hidden */
  92782. _setupInputs(): void;
  92783. }
  92784. }
  92785. declare module BABYLON {
  92786. /**
  92787. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  92788. * being tilted forward or back and left or right.
  92789. */
  92790. export class DeviceOrientationCamera extends FreeCamera {
  92791. private _initialQuaternion;
  92792. private _quaternionCache;
  92793. /**
  92794. * Creates a new device orientation camera
  92795. * @param name The name of the camera
  92796. * @param position The start position camera
  92797. * @param scene The scene the camera belongs to
  92798. */
  92799. constructor(name: string, position: Vector3, scene: Scene);
  92800. /**
  92801. * Gets the current instance class name ("DeviceOrientationCamera").
  92802. * This helps avoiding instanceof at run time.
  92803. * @returns the class name
  92804. */
  92805. getClassName(): string;
  92806. /**
  92807. * @hidden
  92808. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  92809. */
  92810. _checkInputs(): void;
  92811. /**
  92812. * Reset the camera to its default orientation on the specified axis only.
  92813. * @param axis The axis to reset
  92814. */
  92815. resetToCurrentRotation(axis?: Axis): void;
  92816. }
  92817. }
  92818. declare module BABYLON {
  92819. /**
  92820. * Manage the keyboard inputs to control the movement of a follow camera.
  92821. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92822. */
  92823. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  92824. /**
  92825. * Defines the camera the input is attached to.
  92826. */
  92827. camera: FollowCamera;
  92828. /**
  92829. * Defines the list of key codes associated with the up action (increase heightOffset)
  92830. */
  92831. keysHeightOffsetIncr: number[];
  92832. /**
  92833. * Defines the list of key codes associated with the down action (decrease heightOffset)
  92834. */
  92835. keysHeightOffsetDecr: number[];
  92836. /**
  92837. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  92838. */
  92839. keysHeightOffsetModifierAlt: boolean;
  92840. /**
  92841. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  92842. */
  92843. keysHeightOffsetModifierCtrl: boolean;
  92844. /**
  92845. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  92846. */
  92847. keysHeightOffsetModifierShift: boolean;
  92848. /**
  92849. * Defines the list of key codes associated with the left action (increase rotationOffset)
  92850. */
  92851. keysRotationOffsetIncr: number[];
  92852. /**
  92853. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  92854. */
  92855. keysRotationOffsetDecr: number[];
  92856. /**
  92857. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  92858. */
  92859. keysRotationOffsetModifierAlt: boolean;
  92860. /**
  92861. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  92862. */
  92863. keysRotationOffsetModifierCtrl: boolean;
  92864. /**
  92865. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  92866. */
  92867. keysRotationOffsetModifierShift: boolean;
  92868. /**
  92869. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  92870. */
  92871. keysRadiusIncr: number[];
  92872. /**
  92873. * Defines the list of key codes associated with the zoom-out action (increase radius)
  92874. */
  92875. keysRadiusDecr: number[];
  92876. /**
  92877. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  92878. */
  92879. keysRadiusModifierAlt: boolean;
  92880. /**
  92881. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  92882. */
  92883. keysRadiusModifierCtrl: boolean;
  92884. /**
  92885. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  92886. */
  92887. keysRadiusModifierShift: boolean;
  92888. /**
  92889. * Defines the rate of change of heightOffset.
  92890. */
  92891. heightSensibility: number;
  92892. /**
  92893. * Defines the rate of change of rotationOffset.
  92894. */
  92895. rotationSensibility: number;
  92896. /**
  92897. * Defines the rate of change of radius.
  92898. */
  92899. radiusSensibility: number;
  92900. private _keys;
  92901. private _ctrlPressed;
  92902. private _altPressed;
  92903. private _shiftPressed;
  92904. private _onCanvasBlurObserver;
  92905. private _onKeyboardObserver;
  92906. private _engine;
  92907. private _scene;
  92908. /**
  92909. * Attach the input controls to a specific dom element to get the input from.
  92910. * @param element Defines the element the controls should be listened from
  92911. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92912. */
  92913. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92914. /**
  92915. * Detach the current controls from the specified dom element.
  92916. * @param element Defines the element to stop listening the inputs from
  92917. */
  92918. detachControl(element: Nullable<HTMLElement>): void;
  92919. /**
  92920. * Update the current camera state depending on the inputs that have been used this frame.
  92921. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92922. */
  92923. checkInputs(): void;
  92924. /**
  92925. * Gets the class name of the current input.
  92926. * @returns the class name
  92927. */
  92928. getClassName(): string;
  92929. /**
  92930. * Get the friendly name associated with the input class.
  92931. * @returns the input friendly name
  92932. */
  92933. getSimpleName(): string;
  92934. /**
  92935. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  92936. * allow modification of the heightOffset value.
  92937. */
  92938. private _modifierHeightOffset;
  92939. /**
  92940. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  92941. * allow modification of the rotationOffset value.
  92942. */
  92943. private _modifierRotationOffset;
  92944. /**
  92945. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  92946. * allow modification of the radius value.
  92947. */
  92948. private _modifierRadius;
  92949. }
  92950. }
  92951. declare module BABYLON {
  92952. /**
  92953. * Manage the mouse wheel inputs to control a follow camera.
  92954. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92955. */
  92956. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  92957. /**
  92958. * Defines the camera the input is attached to.
  92959. */
  92960. camera: FollowCamera;
  92961. /**
  92962. * Moue wheel controls zoom. (Moue wheel modifies camera.radius value.)
  92963. */
  92964. axisControlRadius: boolean;
  92965. /**
  92966. * Moue wheel controls height. (Moue wheel modifies camera.heightOffset value.)
  92967. */
  92968. axisControlHeight: boolean;
  92969. /**
  92970. * Moue wheel controls angle. (Moue wheel modifies camera.rotationOffset value.)
  92971. */
  92972. axisControlRotation: boolean;
  92973. /**
  92974. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  92975. * relation to mouseWheel events.
  92976. */
  92977. wheelPrecision: number;
  92978. /**
  92979. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  92980. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  92981. */
  92982. wheelDeltaPercentage: number;
  92983. private _wheel;
  92984. private _observer;
  92985. /**
  92986. * Attach the input controls to a specific dom element to get the input from.
  92987. * @param element Defines the element the controls should be listened from
  92988. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92989. */
  92990. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92991. /**
  92992. * Detach the current controls from the specified dom element.
  92993. * @param element Defines the element to stop listening the inputs from
  92994. */
  92995. detachControl(element: Nullable<HTMLElement>): void;
  92996. /**
  92997. * Gets the class name of the current intput.
  92998. * @returns the class name
  92999. */
  93000. getClassName(): string;
  93001. /**
  93002. * Get the friendly name associated with the input class.
  93003. * @returns the input friendly name
  93004. */
  93005. getSimpleName(): string;
  93006. }
  93007. }
  93008. declare module BABYLON {
  93009. /**
  93010. * Default Inputs manager for the FollowCamera.
  93011. * It groups all the default supported inputs for ease of use.
  93012. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93013. */
  93014. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  93015. /**
  93016. * Instantiates a new FollowCameraInputsManager.
  93017. * @param camera Defines the camera the inputs belong to
  93018. */
  93019. constructor(camera: FollowCamera);
  93020. /**
  93021. * Add keyboard input support to the input manager.
  93022. * @returns the current input manager
  93023. */
  93024. addKeyboard(): FollowCameraInputsManager;
  93025. /**
  93026. * Add mouse wheel input support to the input manager.
  93027. * @returns the current input manager
  93028. */
  93029. addMouseWheel(): FollowCameraInputsManager;
  93030. /**
  93031. * Add pointers input support to the input manager.
  93032. * @returns the current input manager
  93033. */
  93034. addPointers(): FollowCameraInputsManager;
  93035. /**
  93036. * Add orientation input support to the input manager.
  93037. * @returns the current input manager
  93038. */
  93039. addVRDeviceOrientation(): FollowCameraInputsManager;
  93040. }
  93041. }
  93042. declare module BABYLON {
  93043. /**
  93044. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  93045. * an arc rotate version arcFollowCamera are available.
  93046. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93047. */
  93048. export class FollowCamera extends TargetCamera {
  93049. /**
  93050. * Distance the follow camera should follow an object at
  93051. */
  93052. radius: number;
  93053. /**
  93054. * Minimum allowed distance of the camera to the axis of rotation
  93055. * (The camera can not get closer).
  93056. * This can help limiting how the Camera is able to move in the scene.
  93057. */
  93058. lowerRadiusLimit: Nullable<number>;
  93059. /**
  93060. * Maximum allowed distance of the camera to the axis of rotation
  93061. * (The camera can not get further).
  93062. * This can help limiting how the Camera is able to move in the scene.
  93063. */
  93064. upperRadiusLimit: Nullable<number>;
  93065. /**
  93066. * Define a rotation offset between the camera and the object it follows
  93067. */
  93068. rotationOffset: number;
  93069. /**
  93070. * Minimum allowed angle to camera position relative to target object.
  93071. * This can help limiting how the Camera is able to move in the scene.
  93072. */
  93073. lowerRotationOffsetLimit: Nullable<number>;
  93074. /**
  93075. * Maximum allowed angle to camera position relative to target object.
  93076. * This can help limiting how the Camera is able to move in the scene.
  93077. */
  93078. upperRotationOffsetLimit: Nullable<number>;
  93079. /**
  93080. * Define a height offset between the camera and the object it follows.
  93081. * It can help following an object from the top (like a car chaing a plane)
  93082. */
  93083. heightOffset: number;
  93084. /**
  93085. * Minimum allowed height of camera position relative to target object.
  93086. * This can help limiting how the Camera is able to move in the scene.
  93087. */
  93088. lowerHeightOffsetLimit: Nullable<number>;
  93089. /**
  93090. * Maximum allowed height of camera position relative to target object.
  93091. * This can help limiting how the Camera is able to move in the scene.
  93092. */
  93093. upperHeightOffsetLimit: Nullable<number>;
  93094. /**
  93095. * Define how fast the camera can accelerate to follow it s target.
  93096. */
  93097. cameraAcceleration: number;
  93098. /**
  93099. * Define the speed limit of the camera following an object.
  93100. */
  93101. maxCameraSpeed: number;
  93102. /**
  93103. * Define the target of the camera.
  93104. */
  93105. lockedTarget: Nullable<AbstractMesh>;
  93106. /**
  93107. * Defines the input associated with the camera.
  93108. */
  93109. inputs: FollowCameraInputsManager;
  93110. /**
  93111. * Instantiates the follow camera.
  93112. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93113. * @param name Define the name of the camera in the scene
  93114. * @param position Define the position of the camera
  93115. * @param scene Define the scene the camera belong to
  93116. * @param lockedTarget Define the target of the camera
  93117. */
  93118. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  93119. private _follow;
  93120. /**
  93121. * Attached controls to the current camera.
  93122. * @param element Defines the element the controls should be listened from
  93123. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93124. */
  93125. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93126. /**
  93127. * Detach the current controls from the camera.
  93128. * The camera will stop reacting to inputs.
  93129. * @param element Defines the element to stop listening the inputs from
  93130. */
  93131. detachControl(element: HTMLElement): void;
  93132. /** @hidden */
  93133. _checkInputs(): void;
  93134. private _checkLimits;
  93135. /**
  93136. * Gets the camera class name.
  93137. * @returns the class name
  93138. */
  93139. getClassName(): string;
  93140. }
  93141. /**
  93142. * Arc Rotate version of the follow camera.
  93143. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  93144. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93145. */
  93146. export class ArcFollowCamera extends TargetCamera {
  93147. /** The longitudinal angle of the camera */
  93148. alpha: number;
  93149. /** The latitudinal angle of the camera */
  93150. beta: number;
  93151. /** The radius of the camera from its target */
  93152. radius: number;
  93153. /** Define the camera target (the messh it should follow) */
  93154. target: Nullable<AbstractMesh>;
  93155. private _cartesianCoordinates;
  93156. /**
  93157. * Instantiates a new ArcFollowCamera
  93158. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93159. * @param name Define the name of the camera
  93160. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  93161. * @param beta Define the rotation angle of the camera around the elevation axis
  93162. * @param radius Define the radius of the camera from its target point
  93163. * @param target Define the target of the camera
  93164. * @param scene Define the scene the camera belongs to
  93165. */
  93166. constructor(name: string,
  93167. /** The longitudinal angle of the camera */
  93168. alpha: number,
  93169. /** The latitudinal angle of the camera */
  93170. beta: number,
  93171. /** The radius of the camera from its target */
  93172. radius: number,
  93173. /** Define the camera target (the messh it should follow) */
  93174. target: Nullable<AbstractMesh>, scene: Scene);
  93175. private _follow;
  93176. /** @hidden */
  93177. _checkInputs(): void;
  93178. /**
  93179. * Returns the class name of the object.
  93180. * It is mostly used internally for serialization purposes.
  93181. */
  93182. getClassName(): string;
  93183. }
  93184. }
  93185. declare module BABYLON {
  93186. /**
  93187. * 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,
  93188. * which still works and will still be found in many Playgrounds.
  93189. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  93190. */
  93191. export class UniversalCamera extends TouchCamera {
  93192. /**
  93193. * Defines the gamepad rotation sensiblity.
  93194. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  93195. */
  93196. gamepadAngularSensibility: number;
  93197. /**
  93198. * Defines the gamepad move sensiblity.
  93199. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  93200. */
  93201. gamepadMoveSensibility: number;
  93202. /**
  93203. * 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,
  93204. * which still works and will still be found in many Playgrounds.
  93205. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  93206. * @param name Define the name of the camera in the scene
  93207. * @param position Define the start position of the camera in the scene
  93208. * @param scene Define the scene the camera belongs to
  93209. */
  93210. constructor(name: string, position: Vector3, scene: Scene);
  93211. /**
  93212. * Gets the current object class name.
  93213. * @return the class name
  93214. */
  93215. getClassName(): string;
  93216. }
  93217. }
  93218. declare module BABYLON {
  93219. /**
  93220. * This represents a FPS type of camera. This is only here for back compat purpose.
  93221. * Please use the UniversalCamera instead as both are identical.
  93222. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  93223. */
  93224. export class GamepadCamera extends UniversalCamera {
  93225. /**
  93226. * Instantiates a new Gamepad Camera
  93227. * This represents a FPS type of camera. This is only here for back compat purpose.
  93228. * Please use the UniversalCamera instead as both are identical.
  93229. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  93230. * @param name Define the name of the camera in the scene
  93231. * @param position Define the start position of the camera in the scene
  93232. * @param scene Define the scene the camera belongs to
  93233. */
  93234. constructor(name: string, position: Vector3, scene: Scene);
  93235. /**
  93236. * Gets the current object class name.
  93237. * @return the class name
  93238. */
  93239. getClassName(): string;
  93240. }
  93241. }
  93242. declare module BABYLON {
  93243. /** @hidden */
  93244. export var passPixelShader: {
  93245. name: string;
  93246. shader: string;
  93247. };
  93248. }
  93249. declare module BABYLON {
  93250. /** @hidden */
  93251. export var passCubePixelShader: {
  93252. name: string;
  93253. shader: string;
  93254. };
  93255. }
  93256. declare module BABYLON {
  93257. /**
  93258. * PassPostProcess which produces an output the same as it's input
  93259. */
  93260. export class PassPostProcess extends PostProcess {
  93261. /**
  93262. * Creates the PassPostProcess
  93263. * @param name The name of the effect.
  93264. * @param options The required width/height ratio to downsize to before computing the render pass.
  93265. * @param camera The camera to apply the render pass to.
  93266. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  93267. * @param engine The engine which the post process will be applied. (default: current engine)
  93268. * @param reusable If the post process can be reused on the same frame. (default: false)
  93269. * @param textureType The type of texture to be used when performing the post processing.
  93270. * @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)
  93271. */
  93272. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  93273. }
  93274. /**
  93275. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  93276. */
  93277. export class PassCubePostProcess extends PostProcess {
  93278. private _face;
  93279. /**
  93280. * Gets or sets the cube face to display.
  93281. * * 0 is +X
  93282. * * 1 is -X
  93283. * * 2 is +Y
  93284. * * 3 is -Y
  93285. * * 4 is +Z
  93286. * * 5 is -Z
  93287. */
  93288. face: number;
  93289. /**
  93290. * Creates the PassCubePostProcess
  93291. * @param name The name of the effect.
  93292. * @param options The required width/height ratio to downsize to before computing the render pass.
  93293. * @param camera The camera to apply the render pass to.
  93294. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  93295. * @param engine The engine which the post process will be applied. (default: current engine)
  93296. * @param reusable If the post process can be reused on the same frame. (default: false)
  93297. * @param textureType The type of texture to be used when performing the post processing.
  93298. * @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)
  93299. */
  93300. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  93301. }
  93302. }
  93303. declare module BABYLON {
  93304. /** @hidden */
  93305. export var anaglyphPixelShader: {
  93306. name: string;
  93307. shader: string;
  93308. };
  93309. }
  93310. declare module BABYLON {
  93311. /**
  93312. * Postprocess used to generate anaglyphic rendering
  93313. */
  93314. export class AnaglyphPostProcess extends PostProcess {
  93315. private _passedProcess;
  93316. /**
  93317. * Creates a new AnaglyphPostProcess
  93318. * @param name defines postprocess name
  93319. * @param options defines creation options or target ratio scale
  93320. * @param rigCameras defines cameras using this postprocess
  93321. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  93322. * @param engine defines hosting engine
  93323. * @param reusable defines if the postprocess will be reused multiple times per frame
  93324. */
  93325. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  93326. }
  93327. }
  93328. declare module BABYLON {
  93329. /**
  93330. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  93331. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  93332. */
  93333. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  93334. /**
  93335. * Creates a new AnaglyphArcRotateCamera
  93336. * @param name defines camera name
  93337. * @param alpha defines alpha angle (in radians)
  93338. * @param beta defines beta angle (in radians)
  93339. * @param radius defines radius
  93340. * @param target defines camera target
  93341. * @param interaxialDistance defines distance between each color axis
  93342. * @param scene defines the hosting scene
  93343. */
  93344. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  93345. /**
  93346. * Gets camera class name
  93347. * @returns AnaglyphArcRotateCamera
  93348. */
  93349. getClassName(): string;
  93350. }
  93351. }
  93352. declare module BABYLON {
  93353. /**
  93354. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  93355. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  93356. */
  93357. export class AnaglyphFreeCamera extends FreeCamera {
  93358. /**
  93359. * Creates a new AnaglyphFreeCamera
  93360. * @param name defines camera name
  93361. * @param position defines initial position
  93362. * @param interaxialDistance defines distance between each color axis
  93363. * @param scene defines the hosting scene
  93364. */
  93365. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  93366. /**
  93367. * Gets camera class name
  93368. * @returns AnaglyphFreeCamera
  93369. */
  93370. getClassName(): string;
  93371. }
  93372. }
  93373. declare module BABYLON {
  93374. /**
  93375. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  93376. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  93377. */
  93378. export class AnaglyphGamepadCamera extends GamepadCamera {
  93379. /**
  93380. * Creates a new AnaglyphGamepadCamera
  93381. * @param name defines camera name
  93382. * @param position defines initial position
  93383. * @param interaxialDistance defines distance between each color axis
  93384. * @param scene defines the hosting scene
  93385. */
  93386. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  93387. /**
  93388. * Gets camera class name
  93389. * @returns AnaglyphGamepadCamera
  93390. */
  93391. getClassName(): string;
  93392. }
  93393. }
  93394. declare module BABYLON {
  93395. /**
  93396. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  93397. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  93398. */
  93399. export class AnaglyphUniversalCamera extends UniversalCamera {
  93400. /**
  93401. * Creates a new AnaglyphUniversalCamera
  93402. * @param name defines camera name
  93403. * @param position defines initial position
  93404. * @param interaxialDistance defines distance between each color axis
  93405. * @param scene defines the hosting scene
  93406. */
  93407. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  93408. /**
  93409. * Gets camera class name
  93410. * @returns AnaglyphUniversalCamera
  93411. */
  93412. getClassName(): string;
  93413. }
  93414. }
  93415. declare module BABYLON {
  93416. /** @hidden */
  93417. export var stereoscopicInterlacePixelShader: {
  93418. name: string;
  93419. shader: string;
  93420. };
  93421. }
  93422. declare module BABYLON {
  93423. /**
  93424. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  93425. */
  93426. export class StereoscopicInterlacePostProcess extends PostProcess {
  93427. private _stepSize;
  93428. private _passedProcess;
  93429. /**
  93430. * Initializes a StereoscopicInterlacePostProcess
  93431. * @param name The name of the effect.
  93432. * @param rigCameras The rig cameras to be appled to the post process
  93433. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  93434. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  93435. * @param engine The engine which the post process will be applied. (default: current engine)
  93436. * @param reusable If the post process can be reused on the same frame. (default: false)
  93437. */
  93438. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  93439. }
  93440. }
  93441. declare module BABYLON {
  93442. /**
  93443. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  93444. * @see http://doc.babylonjs.com/features/cameras
  93445. */
  93446. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  93447. /**
  93448. * Creates a new StereoscopicArcRotateCamera
  93449. * @param name defines camera name
  93450. * @param alpha defines alpha angle (in radians)
  93451. * @param beta defines beta angle (in radians)
  93452. * @param radius defines radius
  93453. * @param target defines camera target
  93454. * @param interaxialDistance defines distance between each color axis
  93455. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  93456. * @param scene defines the hosting scene
  93457. */
  93458. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  93459. /**
  93460. * Gets camera class name
  93461. * @returns StereoscopicArcRotateCamera
  93462. */
  93463. getClassName(): string;
  93464. }
  93465. }
  93466. declare module BABYLON {
  93467. /**
  93468. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  93469. * @see http://doc.babylonjs.com/features/cameras
  93470. */
  93471. export class StereoscopicFreeCamera extends FreeCamera {
  93472. /**
  93473. * Creates a new StereoscopicFreeCamera
  93474. * @param name defines camera name
  93475. * @param position defines initial position
  93476. * @param interaxialDistance defines distance between each color axis
  93477. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  93478. * @param scene defines the hosting scene
  93479. */
  93480. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  93481. /**
  93482. * Gets camera class name
  93483. * @returns StereoscopicFreeCamera
  93484. */
  93485. getClassName(): string;
  93486. }
  93487. }
  93488. declare module BABYLON {
  93489. /**
  93490. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  93491. * @see http://doc.babylonjs.com/features/cameras
  93492. */
  93493. export class StereoscopicGamepadCamera extends GamepadCamera {
  93494. /**
  93495. * Creates a new StereoscopicGamepadCamera
  93496. * @param name defines camera name
  93497. * @param position defines initial position
  93498. * @param interaxialDistance defines distance between each color axis
  93499. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  93500. * @param scene defines the hosting scene
  93501. */
  93502. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  93503. /**
  93504. * Gets camera class name
  93505. * @returns StereoscopicGamepadCamera
  93506. */
  93507. getClassName(): string;
  93508. }
  93509. }
  93510. declare module BABYLON {
  93511. /**
  93512. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  93513. * @see http://doc.babylonjs.com/features/cameras
  93514. */
  93515. export class StereoscopicUniversalCamera extends UniversalCamera {
  93516. /**
  93517. * Creates a new StereoscopicUniversalCamera
  93518. * @param name defines camera name
  93519. * @param position defines initial position
  93520. * @param interaxialDistance defines distance between each color axis
  93521. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  93522. * @param scene defines the hosting scene
  93523. */
  93524. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  93525. /**
  93526. * Gets camera class name
  93527. * @returns StereoscopicUniversalCamera
  93528. */
  93529. getClassName(): string;
  93530. }
  93531. }
  93532. declare module BABYLON {
  93533. /**
  93534. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  93535. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  93536. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  93537. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  93538. */
  93539. export class VirtualJoysticksCamera extends FreeCamera {
  93540. /**
  93541. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  93542. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  93543. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  93544. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  93545. * @param name Define the name of the camera in the scene
  93546. * @param position Define the start position of the camera in the scene
  93547. * @param scene Define the scene the camera belongs to
  93548. */
  93549. constructor(name: string, position: Vector3, scene: Scene);
  93550. /**
  93551. * Gets the current object class name.
  93552. * @return the class name
  93553. */
  93554. getClassName(): string;
  93555. }
  93556. }
  93557. declare module BABYLON {
  93558. /**
  93559. * This represents all the required metrics to create a VR camera.
  93560. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  93561. */
  93562. export class VRCameraMetrics {
  93563. /**
  93564. * Define the horizontal resolution off the screen.
  93565. */
  93566. hResolution: number;
  93567. /**
  93568. * Define the vertical resolution off the screen.
  93569. */
  93570. vResolution: number;
  93571. /**
  93572. * Define the horizontal screen size.
  93573. */
  93574. hScreenSize: number;
  93575. /**
  93576. * Define the vertical screen size.
  93577. */
  93578. vScreenSize: number;
  93579. /**
  93580. * Define the vertical screen center position.
  93581. */
  93582. vScreenCenter: number;
  93583. /**
  93584. * Define the distance of the eyes to the screen.
  93585. */
  93586. eyeToScreenDistance: number;
  93587. /**
  93588. * Define the distance between both lenses
  93589. */
  93590. lensSeparationDistance: number;
  93591. /**
  93592. * Define the distance between both viewer's eyes.
  93593. */
  93594. interpupillaryDistance: number;
  93595. /**
  93596. * Define the distortion factor of the VR postprocess.
  93597. * Please, touch with care.
  93598. */
  93599. distortionK: number[];
  93600. /**
  93601. * Define the chromatic aberration correction factors for the VR post process.
  93602. */
  93603. chromaAbCorrection: number[];
  93604. /**
  93605. * Define the scale factor of the post process.
  93606. * The smaller the better but the slower.
  93607. */
  93608. postProcessScaleFactor: number;
  93609. /**
  93610. * Define an offset for the lens center.
  93611. */
  93612. lensCenterOffset: number;
  93613. /**
  93614. * Define if the current vr camera should compensate the distortion of the lense or not.
  93615. */
  93616. compensateDistortion: boolean;
  93617. /**
  93618. * Gets the rendering aspect ratio based on the provided resolutions.
  93619. */
  93620. readonly aspectRatio: number;
  93621. /**
  93622. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  93623. */
  93624. readonly aspectRatioFov: number;
  93625. /**
  93626. * @hidden
  93627. */
  93628. readonly leftHMatrix: Matrix;
  93629. /**
  93630. * @hidden
  93631. */
  93632. readonly rightHMatrix: Matrix;
  93633. /**
  93634. * @hidden
  93635. */
  93636. readonly leftPreViewMatrix: Matrix;
  93637. /**
  93638. * @hidden
  93639. */
  93640. readonly rightPreViewMatrix: Matrix;
  93641. /**
  93642. * Get the default VRMetrics based on the most generic setup.
  93643. * @returns the default vr metrics
  93644. */
  93645. static GetDefault(): VRCameraMetrics;
  93646. }
  93647. }
  93648. declare module BABYLON {
  93649. /** @hidden */
  93650. export var vrDistortionCorrectionPixelShader: {
  93651. name: string;
  93652. shader: string;
  93653. };
  93654. }
  93655. declare module BABYLON {
  93656. /**
  93657. * VRDistortionCorrectionPostProcess used for mobile VR
  93658. */
  93659. export class VRDistortionCorrectionPostProcess extends PostProcess {
  93660. private _isRightEye;
  93661. private _distortionFactors;
  93662. private _postProcessScaleFactor;
  93663. private _lensCenterOffset;
  93664. private _scaleIn;
  93665. private _scaleFactor;
  93666. private _lensCenter;
  93667. /**
  93668. * Initializes the VRDistortionCorrectionPostProcess
  93669. * @param name The name of the effect.
  93670. * @param camera The camera to apply the render pass to.
  93671. * @param isRightEye If this is for the right eye distortion
  93672. * @param vrMetrics All the required metrics for the VR camera
  93673. */
  93674. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  93675. }
  93676. }
  93677. declare module BABYLON {
  93678. /**
  93679. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  93680. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  93681. */
  93682. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  93683. /**
  93684. * Creates a new VRDeviceOrientationArcRotateCamera
  93685. * @param name defines camera name
  93686. * @param alpha defines the camera rotation along the logitudinal axis
  93687. * @param beta defines the camera rotation along the latitudinal axis
  93688. * @param radius defines the camera distance from its target
  93689. * @param target defines the camera target
  93690. * @param scene defines the scene the camera belongs to
  93691. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  93692. * @param vrCameraMetrics defines the vr metrics associated to the camera
  93693. */
  93694. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  93695. /**
  93696. * Gets camera class name
  93697. * @returns VRDeviceOrientationArcRotateCamera
  93698. */
  93699. getClassName(): string;
  93700. }
  93701. }
  93702. declare module BABYLON {
  93703. /**
  93704. * Camera used to simulate VR rendering (based on FreeCamera)
  93705. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  93706. */
  93707. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  93708. /**
  93709. * Creates a new VRDeviceOrientationFreeCamera
  93710. * @param name defines camera name
  93711. * @param position defines the start position of the camera
  93712. * @param scene defines the scene the camera belongs to
  93713. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  93714. * @param vrCameraMetrics defines the vr metrics associated to the camera
  93715. */
  93716. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  93717. /**
  93718. * Gets camera class name
  93719. * @returns VRDeviceOrientationFreeCamera
  93720. */
  93721. getClassName(): string;
  93722. }
  93723. }
  93724. declare module BABYLON {
  93725. /**
  93726. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  93727. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  93728. */
  93729. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  93730. /**
  93731. * Creates a new VRDeviceOrientationGamepadCamera
  93732. * @param name defines camera name
  93733. * @param position defines the start position of the camera
  93734. * @param scene defines the scene the camera belongs to
  93735. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  93736. * @param vrCameraMetrics defines the vr metrics associated to the camera
  93737. */
  93738. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  93739. /**
  93740. * Gets camera class name
  93741. * @returns VRDeviceOrientationGamepadCamera
  93742. */
  93743. getClassName(): string;
  93744. }
  93745. }
  93746. declare module BABYLON {
  93747. /**
  93748. * Defines supported buttons for XBox360 compatible gamepads
  93749. */
  93750. export enum Xbox360Button {
  93751. /** A */
  93752. A = 0,
  93753. /** B */
  93754. B = 1,
  93755. /** X */
  93756. X = 2,
  93757. /** Y */
  93758. Y = 3,
  93759. /** Start */
  93760. Start = 4,
  93761. /** Back */
  93762. Back = 5,
  93763. /** Left button */
  93764. LB = 6,
  93765. /** Right button */
  93766. RB = 7,
  93767. /** Left stick */
  93768. LeftStick = 8,
  93769. /** Right stick */
  93770. RightStick = 9
  93771. }
  93772. /** Defines values for XBox360 DPad */
  93773. export enum Xbox360Dpad {
  93774. /** Up */
  93775. Up = 0,
  93776. /** Down */
  93777. Down = 1,
  93778. /** Left */
  93779. Left = 2,
  93780. /** Right */
  93781. Right = 3
  93782. }
  93783. /**
  93784. * Defines a XBox360 gamepad
  93785. */
  93786. export class Xbox360Pad extends Gamepad {
  93787. private _leftTrigger;
  93788. private _rightTrigger;
  93789. private _onlefttriggerchanged;
  93790. private _onrighttriggerchanged;
  93791. private _onbuttondown;
  93792. private _onbuttonup;
  93793. private _ondpaddown;
  93794. private _ondpadup;
  93795. /** Observable raised when a button is pressed */
  93796. onButtonDownObservable: Observable<Xbox360Button>;
  93797. /** Observable raised when a button is released */
  93798. onButtonUpObservable: Observable<Xbox360Button>;
  93799. /** Observable raised when a pad is pressed */
  93800. onPadDownObservable: Observable<Xbox360Dpad>;
  93801. /** Observable raised when a pad is released */
  93802. onPadUpObservable: Observable<Xbox360Dpad>;
  93803. private _buttonA;
  93804. private _buttonB;
  93805. private _buttonX;
  93806. private _buttonY;
  93807. private _buttonBack;
  93808. private _buttonStart;
  93809. private _buttonLB;
  93810. private _buttonRB;
  93811. private _buttonLeftStick;
  93812. private _buttonRightStick;
  93813. private _dPadUp;
  93814. private _dPadDown;
  93815. private _dPadLeft;
  93816. private _dPadRight;
  93817. private _isXboxOnePad;
  93818. /**
  93819. * Creates a new XBox360 gamepad object
  93820. * @param id defines the id of this gamepad
  93821. * @param index defines its index
  93822. * @param gamepad defines the internal HTML gamepad object
  93823. * @param xboxOne defines if it is a XBox One gamepad
  93824. */
  93825. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  93826. /**
  93827. * Defines the callback to call when left trigger is pressed
  93828. * @param callback defines the callback to use
  93829. */
  93830. onlefttriggerchanged(callback: (value: number) => void): void;
  93831. /**
  93832. * Defines the callback to call when right trigger is pressed
  93833. * @param callback defines the callback to use
  93834. */
  93835. onrighttriggerchanged(callback: (value: number) => void): void;
  93836. /**
  93837. * Gets the left trigger value
  93838. */
  93839. /**
  93840. * Sets the left trigger value
  93841. */
  93842. leftTrigger: number;
  93843. /**
  93844. * Gets the right trigger value
  93845. */
  93846. /**
  93847. * Sets the right trigger value
  93848. */
  93849. rightTrigger: number;
  93850. /**
  93851. * Defines the callback to call when a button is pressed
  93852. * @param callback defines the callback to use
  93853. */
  93854. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  93855. /**
  93856. * Defines the callback to call when a button is released
  93857. * @param callback defines the callback to use
  93858. */
  93859. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  93860. /**
  93861. * Defines the callback to call when a pad is pressed
  93862. * @param callback defines the callback to use
  93863. */
  93864. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  93865. /**
  93866. * Defines the callback to call when a pad is released
  93867. * @param callback defines the callback to use
  93868. */
  93869. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  93870. private _setButtonValue;
  93871. private _setDPadValue;
  93872. /**
  93873. * Gets the value of the `A` button
  93874. */
  93875. /**
  93876. * Sets the value of the `A` button
  93877. */
  93878. buttonA: number;
  93879. /**
  93880. * Gets the value of the `B` button
  93881. */
  93882. /**
  93883. * Sets the value of the `B` button
  93884. */
  93885. buttonB: number;
  93886. /**
  93887. * Gets the value of the `X` button
  93888. */
  93889. /**
  93890. * Sets the value of the `X` button
  93891. */
  93892. buttonX: number;
  93893. /**
  93894. * Gets the value of the `Y` button
  93895. */
  93896. /**
  93897. * Sets the value of the `Y` button
  93898. */
  93899. buttonY: number;
  93900. /**
  93901. * Gets the value of the `Start` button
  93902. */
  93903. /**
  93904. * Sets the value of the `Start` button
  93905. */
  93906. buttonStart: number;
  93907. /**
  93908. * Gets the value of the `Back` button
  93909. */
  93910. /**
  93911. * Sets the value of the `Back` button
  93912. */
  93913. buttonBack: number;
  93914. /**
  93915. * Gets the value of the `Left` button
  93916. */
  93917. /**
  93918. * Sets the value of the `Left` button
  93919. */
  93920. buttonLB: number;
  93921. /**
  93922. * Gets the value of the `Right` button
  93923. */
  93924. /**
  93925. * Sets the value of the `Right` button
  93926. */
  93927. buttonRB: number;
  93928. /**
  93929. * Gets the value of the Left joystick
  93930. */
  93931. /**
  93932. * Sets the value of the Left joystick
  93933. */
  93934. buttonLeftStick: number;
  93935. /**
  93936. * Gets the value of the Right joystick
  93937. */
  93938. /**
  93939. * Sets the value of the Right joystick
  93940. */
  93941. buttonRightStick: number;
  93942. /**
  93943. * Gets the value of D-pad up
  93944. */
  93945. /**
  93946. * Sets the value of D-pad up
  93947. */
  93948. dPadUp: number;
  93949. /**
  93950. * Gets the value of D-pad down
  93951. */
  93952. /**
  93953. * Sets the value of D-pad down
  93954. */
  93955. dPadDown: number;
  93956. /**
  93957. * Gets the value of D-pad left
  93958. */
  93959. /**
  93960. * Sets the value of D-pad left
  93961. */
  93962. dPadLeft: number;
  93963. /**
  93964. * Gets the value of D-pad right
  93965. */
  93966. /**
  93967. * Sets the value of D-pad right
  93968. */
  93969. dPadRight: number;
  93970. /**
  93971. * Force the gamepad to synchronize with device values
  93972. */
  93973. update(): void;
  93974. /**
  93975. * Disposes the gamepad
  93976. */
  93977. dispose(): void;
  93978. }
  93979. }
  93980. declare module BABYLON {
  93981. /**
  93982. * Base class of materials working in push mode in babylon JS
  93983. * @hidden
  93984. */
  93985. export class PushMaterial extends Material {
  93986. protected _activeEffect: Effect;
  93987. protected _normalMatrix: Matrix;
  93988. /**
  93989. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  93990. * This means that the material can keep using a previous shader while a new one is being compiled.
  93991. * This is mostly used when shader parallel compilation is supported (true by default)
  93992. */
  93993. allowShaderHotSwapping: boolean;
  93994. constructor(name: string, scene: Scene);
  93995. getEffect(): Effect;
  93996. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  93997. /**
  93998. * Binds the given world matrix to the active effect
  93999. *
  94000. * @param world the matrix to bind
  94001. */
  94002. bindOnlyWorldMatrix(world: Matrix): void;
  94003. /**
  94004. * Binds the given normal matrix to the active effect
  94005. *
  94006. * @param normalMatrix the matrix to bind
  94007. */
  94008. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  94009. bind(world: Matrix, mesh?: Mesh): void;
  94010. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  94011. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  94012. }
  94013. }
  94014. declare module BABYLON {
  94015. /**
  94016. * This groups all the flags used to control the materials channel.
  94017. */
  94018. export class MaterialFlags {
  94019. private static _DiffuseTextureEnabled;
  94020. /**
  94021. * Are diffuse textures enabled in the application.
  94022. */
  94023. static DiffuseTextureEnabled: boolean;
  94024. private static _AmbientTextureEnabled;
  94025. /**
  94026. * Are ambient textures enabled in the application.
  94027. */
  94028. static AmbientTextureEnabled: boolean;
  94029. private static _OpacityTextureEnabled;
  94030. /**
  94031. * Are opacity textures enabled in the application.
  94032. */
  94033. static OpacityTextureEnabled: boolean;
  94034. private static _ReflectionTextureEnabled;
  94035. /**
  94036. * Are reflection textures enabled in the application.
  94037. */
  94038. static ReflectionTextureEnabled: boolean;
  94039. private static _EmissiveTextureEnabled;
  94040. /**
  94041. * Are emissive textures enabled in the application.
  94042. */
  94043. static EmissiveTextureEnabled: boolean;
  94044. private static _SpecularTextureEnabled;
  94045. /**
  94046. * Are specular textures enabled in the application.
  94047. */
  94048. static SpecularTextureEnabled: boolean;
  94049. private static _BumpTextureEnabled;
  94050. /**
  94051. * Are bump textures enabled in the application.
  94052. */
  94053. static BumpTextureEnabled: boolean;
  94054. private static _LightmapTextureEnabled;
  94055. /**
  94056. * Are lightmap textures enabled in the application.
  94057. */
  94058. static LightmapTextureEnabled: boolean;
  94059. private static _RefractionTextureEnabled;
  94060. /**
  94061. * Are refraction textures enabled in the application.
  94062. */
  94063. static RefractionTextureEnabled: boolean;
  94064. private static _ColorGradingTextureEnabled;
  94065. /**
  94066. * Are color grading textures enabled in the application.
  94067. */
  94068. static ColorGradingTextureEnabled: boolean;
  94069. private static _FresnelEnabled;
  94070. /**
  94071. * Are fresnels enabled in the application.
  94072. */
  94073. static FresnelEnabled: boolean;
  94074. private static _ClearCoatTextureEnabled;
  94075. /**
  94076. * Are clear coat textures enabled in the application.
  94077. */
  94078. static ClearCoatTextureEnabled: boolean;
  94079. private static _ClearCoatBumpTextureEnabled;
  94080. /**
  94081. * Are clear coat bump textures enabled in the application.
  94082. */
  94083. static ClearCoatBumpTextureEnabled: boolean;
  94084. private static _ClearCoatTintTextureEnabled;
  94085. /**
  94086. * Are clear coat tint textures enabled in the application.
  94087. */
  94088. static ClearCoatTintTextureEnabled: boolean;
  94089. }
  94090. }
  94091. declare module BABYLON {
  94092. /** @hidden */
  94093. export var defaultFragmentDeclaration: {
  94094. name: string;
  94095. shader: string;
  94096. };
  94097. }
  94098. declare module BABYLON {
  94099. /** @hidden */
  94100. export var defaultUboDeclaration: {
  94101. name: string;
  94102. shader: string;
  94103. };
  94104. }
  94105. declare module BABYLON {
  94106. /** @hidden */
  94107. export var lightFragmentDeclaration: {
  94108. name: string;
  94109. shader: string;
  94110. };
  94111. }
  94112. declare module BABYLON {
  94113. /** @hidden */
  94114. export var lightUboDeclaration: {
  94115. name: string;
  94116. shader: string;
  94117. };
  94118. }
  94119. declare module BABYLON {
  94120. /** @hidden */
  94121. export var lightsFragmentFunctions: {
  94122. name: string;
  94123. shader: string;
  94124. };
  94125. }
  94126. declare module BABYLON {
  94127. /** @hidden */
  94128. export var shadowsFragmentFunctions: {
  94129. name: string;
  94130. shader: string;
  94131. };
  94132. }
  94133. declare module BABYLON {
  94134. /** @hidden */
  94135. export var fresnelFunction: {
  94136. name: string;
  94137. shader: string;
  94138. };
  94139. }
  94140. declare module BABYLON {
  94141. /** @hidden */
  94142. export var reflectionFunction: {
  94143. name: string;
  94144. shader: string;
  94145. };
  94146. }
  94147. declare module BABYLON {
  94148. /** @hidden */
  94149. export var bumpFragmentFunctions: {
  94150. name: string;
  94151. shader: string;
  94152. };
  94153. }
  94154. declare module BABYLON {
  94155. /** @hidden */
  94156. export var logDepthDeclaration: {
  94157. name: string;
  94158. shader: string;
  94159. };
  94160. }
  94161. declare module BABYLON {
  94162. /** @hidden */
  94163. export var bumpFragment: {
  94164. name: string;
  94165. shader: string;
  94166. };
  94167. }
  94168. declare module BABYLON {
  94169. /** @hidden */
  94170. export var depthPrePass: {
  94171. name: string;
  94172. shader: string;
  94173. };
  94174. }
  94175. declare module BABYLON {
  94176. /** @hidden */
  94177. export var lightFragment: {
  94178. name: string;
  94179. shader: string;
  94180. };
  94181. }
  94182. declare module BABYLON {
  94183. /** @hidden */
  94184. export var logDepthFragment: {
  94185. name: string;
  94186. shader: string;
  94187. };
  94188. }
  94189. declare module BABYLON {
  94190. /** @hidden */
  94191. export var defaultPixelShader: {
  94192. name: string;
  94193. shader: string;
  94194. };
  94195. }
  94196. declare module BABYLON {
  94197. /** @hidden */
  94198. export var defaultVertexDeclaration: {
  94199. name: string;
  94200. shader: string;
  94201. };
  94202. }
  94203. declare module BABYLON {
  94204. /** @hidden */
  94205. export var bumpVertexDeclaration: {
  94206. name: string;
  94207. shader: string;
  94208. };
  94209. }
  94210. declare module BABYLON {
  94211. /** @hidden */
  94212. export var bumpVertex: {
  94213. name: string;
  94214. shader: string;
  94215. };
  94216. }
  94217. declare module BABYLON {
  94218. /** @hidden */
  94219. export var fogVertex: {
  94220. name: string;
  94221. shader: string;
  94222. };
  94223. }
  94224. declare module BABYLON {
  94225. /** @hidden */
  94226. export var shadowsVertex: {
  94227. name: string;
  94228. shader: string;
  94229. };
  94230. }
  94231. declare module BABYLON {
  94232. /** @hidden */
  94233. export var pointCloudVertex: {
  94234. name: string;
  94235. shader: string;
  94236. };
  94237. }
  94238. declare module BABYLON {
  94239. /** @hidden */
  94240. export var logDepthVertex: {
  94241. name: string;
  94242. shader: string;
  94243. };
  94244. }
  94245. declare module BABYLON {
  94246. /** @hidden */
  94247. export var defaultVertexShader: {
  94248. name: string;
  94249. shader: string;
  94250. };
  94251. }
  94252. declare module BABYLON {
  94253. /** @hidden */
  94254. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  94255. MAINUV1: boolean;
  94256. MAINUV2: boolean;
  94257. DIFFUSE: boolean;
  94258. DIFFUSEDIRECTUV: number;
  94259. AMBIENT: boolean;
  94260. AMBIENTDIRECTUV: number;
  94261. OPACITY: boolean;
  94262. OPACITYDIRECTUV: number;
  94263. OPACITYRGB: boolean;
  94264. REFLECTION: boolean;
  94265. EMISSIVE: boolean;
  94266. EMISSIVEDIRECTUV: number;
  94267. SPECULAR: boolean;
  94268. SPECULARDIRECTUV: number;
  94269. BUMP: boolean;
  94270. BUMPDIRECTUV: number;
  94271. PARALLAX: boolean;
  94272. PARALLAXOCCLUSION: boolean;
  94273. SPECULAROVERALPHA: boolean;
  94274. CLIPPLANE: boolean;
  94275. CLIPPLANE2: boolean;
  94276. CLIPPLANE3: boolean;
  94277. CLIPPLANE4: boolean;
  94278. ALPHATEST: boolean;
  94279. DEPTHPREPASS: boolean;
  94280. ALPHAFROMDIFFUSE: boolean;
  94281. POINTSIZE: boolean;
  94282. FOG: boolean;
  94283. SPECULARTERM: boolean;
  94284. DIFFUSEFRESNEL: boolean;
  94285. OPACITYFRESNEL: boolean;
  94286. REFLECTIONFRESNEL: boolean;
  94287. REFRACTIONFRESNEL: boolean;
  94288. EMISSIVEFRESNEL: boolean;
  94289. FRESNEL: boolean;
  94290. NORMAL: boolean;
  94291. UV1: boolean;
  94292. UV2: boolean;
  94293. VERTEXCOLOR: boolean;
  94294. VERTEXALPHA: boolean;
  94295. NUM_BONE_INFLUENCERS: number;
  94296. BonesPerMesh: number;
  94297. BONETEXTURE: boolean;
  94298. INSTANCES: boolean;
  94299. GLOSSINESS: boolean;
  94300. ROUGHNESS: boolean;
  94301. EMISSIVEASILLUMINATION: boolean;
  94302. LINKEMISSIVEWITHDIFFUSE: boolean;
  94303. REFLECTIONFRESNELFROMSPECULAR: boolean;
  94304. LIGHTMAP: boolean;
  94305. LIGHTMAPDIRECTUV: number;
  94306. OBJECTSPACE_NORMALMAP: boolean;
  94307. USELIGHTMAPASSHADOWMAP: boolean;
  94308. REFLECTIONMAP_3D: boolean;
  94309. REFLECTIONMAP_SPHERICAL: boolean;
  94310. REFLECTIONMAP_PLANAR: boolean;
  94311. REFLECTIONMAP_CUBIC: boolean;
  94312. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  94313. REFLECTIONMAP_PROJECTION: boolean;
  94314. REFLECTIONMAP_SKYBOX: boolean;
  94315. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  94316. REFLECTIONMAP_EXPLICIT: boolean;
  94317. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  94318. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  94319. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  94320. INVERTCUBICMAP: boolean;
  94321. LOGARITHMICDEPTH: boolean;
  94322. REFRACTION: boolean;
  94323. REFRACTIONMAP_3D: boolean;
  94324. REFLECTIONOVERALPHA: boolean;
  94325. TWOSIDEDLIGHTING: boolean;
  94326. SHADOWFLOAT: boolean;
  94327. MORPHTARGETS: boolean;
  94328. MORPHTARGETS_NORMAL: boolean;
  94329. MORPHTARGETS_TANGENT: boolean;
  94330. NUM_MORPH_INFLUENCERS: number;
  94331. NONUNIFORMSCALING: boolean;
  94332. PREMULTIPLYALPHA: boolean;
  94333. IMAGEPROCESSING: boolean;
  94334. VIGNETTE: boolean;
  94335. VIGNETTEBLENDMODEMULTIPLY: boolean;
  94336. VIGNETTEBLENDMODEOPAQUE: boolean;
  94337. TONEMAPPING: boolean;
  94338. TONEMAPPING_ACES: boolean;
  94339. CONTRAST: boolean;
  94340. COLORCURVES: boolean;
  94341. COLORGRADING: boolean;
  94342. COLORGRADING3D: boolean;
  94343. SAMPLER3DGREENDEPTH: boolean;
  94344. SAMPLER3DBGRMAP: boolean;
  94345. IMAGEPROCESSINGPOSTPROCESS: boolean;
  94346. /**
  94347. * If the reflection texture on this material is in linear color space
  94348. * @hidden
  94349. */
  94350. IS_REFLECTION_LINEAR: boolean;
  94351. /**
  94352. * If the refraction texture on this material is in linear color space
  94353. * @hidden
  94354. */
  94355. IS_REFRACTION_LINEAR: boolean;
  94356. EXPOSURE: boolean;
  94357. constructor();
  94358. setReflectionMode(modeToEnable: string): void;
  94359. }
  94360. /**
  94361. * This is the default material used in Babylon. It is the best trade off between quality
  94362. * and performances.
  94363. * @see http://doc.babylonjs.com/babylon101/materials
  94364. */
  94365. export class StandardMaterial extends PushMaterial {
  94366. private _diffuseTexture;
  94367. /**
  94368. * The basic texture of the material as viewed under a light.
  94369. */
  94370. diffuseTexture: Nullable<BaseTexture>;
  94371. private _ambientTexture;
  94372. /**
  94373. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  94374. */
  94375. ambientTexture: Nullable<BaseTexture>;
  94376. private _opacityTexture;
  94377. /**
  94378. * Define the transparency of the material from a texture.
  94379. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  94380. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  94381. */
  94382. opacityTexture: Nullable<BaseTexture>;
  94383. private _reflectionTexture;
  94384. /**
  94385. * Define the texture used to display the reflection.
  94386. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  94387. */
  94388. reflectionTexture: Nullable<BaseTexture>;
  94389. private _emissiveTexture;
  94390. /**
  94391. * Define texture of the material as if self lit.
  94392. * This will be mixed in the final result even in the absence of light.
  94393. */
  94394. emissiveTexture: Nullable<BaseTexture>;
  94395. private _specularTexture;
  94396. /**
  94397. * Define how the color and intensity of the highlight given by the light in the material.
  94398. */
  94399. specularTexture: Nullable<BaseTexture>;
  94400. private _bumpTexture;
  94401. /**
  94402. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  94403. * 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.
  94404. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  94405. */
  94406. bumpTexture: Nullable<BaseTexture>;
  94407. private _lightmapTexture;
  94408. /**
  94409. * Complex lighting can be computationally expensive to compute at runtime.
  94410. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  94411. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  94412. */
  94413. lightmapTexture: Nullable<BaseTexture>;
  94414. private _refractionTexture;
  94415. /**
  94416. * Define the texture used to display the refraction.
  94417. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  94418. */
  94419. refractionTexture: Nullable<BaseTexture>;
  94420. /**
  94421. * The color of the material lit by the environmental background lighting.
  94422. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  94423. */
  94424. ambientColor: Color3;
  94425. /**
  94426. * The basic color of the material as viewed under a light.
  94427. */
  94428. diffuseColor: Color3;
  94429. /**
  94430. * Define how the color and intensity of the highlight given by the light in the material.
  94431. */
  94432. specularColor: Color3;
  94433. /**
  94434. * Define the color of the material as if self lit.
  94435. * This will be mixed in the final result even in the absence of light.
  94436. */
  94437. emissiveColor: Color3;
  94438. /**
  94439. * Defines how sharp are the highlights in the material.
  94440. * The bigger the value the sharper giving a more glossy feeling to the result.
  94441. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  94442. */
  94443. specularPower: number;
  94444. private _useAlphaFromDiffuseTexture;
  94445. /**
  94446. * Does the transparency come from the diffuse texture alpha channel.
  94447. */
  94448. useAlphaFromDiffuseTexture: boolean;
  94449. private _useEmissiveAsIllumination;
  94450. /**
  94451. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  94452. */
  94453. useEmissiveAsIllumination: boolean;
  94454. private _linkEmissiveWithDiffuse;
  94455. /**
  94456. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  94457. * the emissive level when the final color is close to one.
  94458. */
  94459. linkEmissiveWithDiffuse: boolean;
  94460. private _useSpecularOverAlpha;
  94461. /**
  94462. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  94463. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  94464. */
  94465. useSpecularOverAlpha: boolean;
  94466. private _useReflectionOverAlpha;
  94467. /**
  94468. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  94469. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  94470. */
  94471. useReflectionOverAlpha: boolean;
  94472. private _disableLighting;
  94473. /**
  94474. * Does lights from the scene impacts this material.
  94475. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  94476. */
  94477. disableLighting: boolean;
  94478. private _useObjectSpaceNormalMap;
  94479. /**
  94480. * Allows using an object space normal map (instead of tangent space).
  94481. */
  94482. useObjectSpaceNormalMap: boolean;
  94483. private _useParallax;
  94484. /**
  94485. * Is parallax enabled or not.
  94486. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  94487. */
  94488. useParallax: boolean;
  94489. private _useParallaxOcclusion;
  94490. /**
  94491. * Is parallax occlusion enabled or not.
  94492. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  94493. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  94494. */
  94495. useParallaxOcclusion: boolean;
  94496. /**
  94497. * 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.
  94498. */
  94499. parallaxScaleBias: number;
  94500. private _roughness;
  94501. /**
  94502. * Helps to define how blurry the reflections should appears in the material.
  94503. */
  94504. roughness: number;
  94505. /**
  94506. * In case of refraction, define the value of the indice of refraction.
  94507. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  94508. */
  94509. indexOfRefraction: number;
  94510. /**
  94511. * Invert the refraction texture alongside the y axis.
  94512. * It can be useful with procedural textures or probe for instance.
  94513. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  94514. */
  94515. invertRefractionY: boolean;
  94516. /**
  94517. * Defines the alpha limits in alpha test mode.
  94518. */
  94519. alphaCutOff: number;
  94520. private _useLightmapAsShadowmap;
  94521. /**
  94522. * In case of light mapping, define whether the map contains light or shadow informations.
  94523. */
  94524. useLightmapAsShadowmap: boolean;
  94525. private _diffuseFresnelParameters;
  94526. /**
  94527. * Define the diffuse fresnel parameters of the material.
  94528. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94529. */
  94530. diffuseFresnelParameters: FresnelParameters;
  94531. private _opacityFresnelParameters;
  94532. /**
  94533. * Define the opacity fresnel parameters of the material.
  94534. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94535. */
  94536. opacityFresnelParameters: FresnelParameters;
  94537. private _reflectionFresnelParameters;
  94538. /**
  94539. * Define the reflection fresnel parameters of the material.
  94540. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94541. */
  94542. reflectionFresnelParameters: FresnelParameters;
  94543. private _refractionFresnelParameters;
  94544. /**
  94545. * Define the refraction fresnel parameters of the material.
  94546. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94547. */
  94548. refractionFresnelParameters: FresnelParameters;
  94549. private _emissiveFresnelParameters;
  94550. /**
  94551. * Define the emissive fresnel parameters of the material.
  94552. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94553. */
  94554. emissiveFresnelParameters: FresnelParameters;
  94555. private _useReflectionFresnelFromSpecular;
  94556. /**
  94557. * If true automatically deducts the fresnels values from the material specularity.
  94558. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94559. */
  94560. useReflectionFresnelFromSpecular: boolean;
  94561. private _useGlossinessFromSpecularMapAlpha;
  94562. /**
  94563. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  94564. */
  94565. useGlossinessFromSpecularMapAlpha: boolean;
  94566. private _maxSimultaneousLights;
  94567. /**
  94568. * Defines the maximum number of lights that can be used in the material
  94569. */
  94570. maxSimultaneousLights: number;
  94571. private _invertNormalMapX;
  94572. /**
  94573. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  94574. */
  94575. invertNormalMapX: boolean;
  94576. private _invertNormalMapY;
  94577. /**
  94578. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  94579. */
  94580. invertNormalMapY: boolean;
  94581. private _twoSidedLighting;
  94582. /**
  94583. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  94584. */
  94585. twoSidedLighting: boolean;
  94586. /**
  94587. * Default configuration related to image processing available in the standard Material.
  94588. */
  94589. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  94590. /**
  94591. * Gets the image processing configuration used either in this material.
  94592. */
  94593. /**
  94594. * Sets the Default image processing configuration used either in the this material.
  94595. *
  94596. * If sets to null, the scene one is in use.
  94597. */
  94598. imageProcessingConfiguration: ImageProcessingConfiguration;
  94599. /**
  94600. * Keep track of the image processing observer to allow dispose and replace.
  94601. */
  94602. private _imageProcessingObserver;
  94603. /**
  94604. * Attaches a new image processing configuration to the Standard Material.
  94605. * @param configuration
  94606. */
  94607. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  94608. /**
  94609. * Gets wether the color curves effect is enabled.
  94610. */
  94611. /**
  94612. * Sets wether the color curves effect is enabled.
  94613. */
  94614. cameraColorCurvesEnabled: boolean;
  94615. /**
  94616. * Gets wether the color grading effect is enabled.
  94617. */
  94618. /**
  94619. * Gets wether the color grading effect is enabled.
  94620. */
  94621. cameraColorGradingEnabled: boolean;
  94622. /**
  94623. * Gets wether tonemapping is enabled or not.
  94624. */
  94625. /**
  94626. * Sets wether tonemapping is enabled or not
  94627. */
  94628. cameraToneMappingEnabled: boolean;
  94629. /**
  94630. * The camera exposure used on this material.
  94631. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  94632. * This corresponds to a photographic exposure.
  94633. */
  94634. /**
  94635. * The camera exposure used on this material.
  94636. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  94637. * This corresponds to a photographic exposure.
  94638. */
  94639. cameraExposure: number;
  94640. /**
  94641. * Gets The camera contrast used on this material.
  94642. */
  94643. /**
  94644. * Sets The camera contrast used on this material.
  94645. */
  94646. cameraContrast: number;
  94647. /**
  94648. * Gets the Color Grading 2D Lookup Texture.
  94649. */
  94650. /**
  94651. * Sets the Color Grading 2D Lookup Texture.
  94652. */
  94653. cameraColorGradingTexture: Nullable<BaseTexture>;
  94654. /**
  94655. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  94656. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  94657. * 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;
  94658. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  94659. */
  94660. /**
  94661. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  94662. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  94663. * 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;
  94664. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  94665. */
  94666. cameraColorCurves: Nullable<ColorCurves>;
  94667. /**
  94668. * Custom callback helping to override the default shader used in the material.
  94669. */
  94670. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  94671. protected _renderTargets: SmartArray<RenderTargetTexture>;
  94672. protected _worldViewProjectionMatrix: Matrix;
  94673. protected _globalAmbientColor: Color3;
  94674. protected _useLogarithmicDepth: boolean;
  94675. /**
  94676. * Instantiates a new standard material.
  94677. * This is the default material used in Babylon. It is the best trade off between quality
  94678. * and performances.
  94679. * @see http://doc.babylonjs.com/babylon101/materials
  94680. * @param name Define the name of the material in the scene
  94681. * @param scene Define the scene the material belong to
  94682. */
  94683. constructor(name: string, scene: Scene);
  94684. /**
  94685. * Gets a boolean indicating that current material needs to register RTT
  94686. */
  94687. readonly hasRenderTargetTextures: boolean;
  94688. /**
  94689. * Gets the current class name of the material e.g. "StandardMaterial"
  94690. * Mainly use in serialization.
  94691. * @returns the class name
  94692. */
  94693. getClassName(): string;
  94694. /**
  94695. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  94696. * You can try switching to logarithmic depth.
  94697. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  94698. */
  94699. useLogarithmicDepth: boolean;
  94700. /**
  94701. * Specifies if the material will require alpha blending
  94702. * @returns a boolean specifying if alpha blending is needed
  94703. */
  94704. needAlphaBlending(): boolean;
  94705. /**
  94706. * Specifies if this material should be rendered in alpha test mode
  94707. * @returns a boolean specifying if an alpha test is needed.
  94708. */
  94709. needAlphaTesting(): boolean;
  94710. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  94711. /**
  94712. * Get the texture used for alpha test purpose.
  94713. * @returns the diffuse texture in case of the standard material.
  94714. */
  94715. getAlphaTestTexture(): Nullable<BaseTexture>;
  94716. /**
  94717. * Get if the submesh is ready to be used and all its information available.
  94718. * Child classes can use it to update shaders
  94719. * @param mesh defines the mesh to check
  94720. * @param subMesh defines which submesh to check
  94721. * @param useInstances specifies that instances should be used
  94722. * @returns a boolean indicating that the submesh is ready or not
  94723. */
  94724. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  94725. /**
  94726. * Builds the material UBO layouts.
  94727. * Used internally during the effect preparation.
  94728. */
  94729. buildUniformLayout(): void;
  94730. /**
  94731. * Unbinds the material from the mesh
  94732. */
  94733. unbind(): void;
  94734. /**
  94735. * Binds the submesh to this material by preparing the effect and shader to draw
  94736. * @param world defines the world transformation matrix
  94737. * @param mesh defines the mesh containing the submesh
  94738. * @param subMesh defines the submesh to bind the material to
  94739. */
  94740. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  94741. /**
  94742. * Get the list of animatables in the material.
  94743. * @returns the list of animatables object used in the material
  94744. */
  94745. getAnimatables(): IAnimatable[];
  94746. /**
  94747. * Gets the active textures from the material
  94748. * @returns an array of textures
  94749. */
  94750. getActiveTextures(): BaseTexture[];
  94751. /**
  94752. * Specifies if the material uses a texture
  94753. * @param texture defines the texture to check against the material
  94754. * @returns a boolean specifying if the material uses the texture
  94755. */
  94756. hasTexture(texture: BaseTexture): boolean;
  94757. /**
  94758. * Disposes the material
  94759. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  94760. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  94761. */
  94762. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  94763. /**
  94764. * Makes a duplicate of the material, and gives it a new name
  94765. * @param name defines the new name for the duplicated material
  94766. * @returns the cloned material
  94767. */
  94768. clone(name: string): StandardMaterial;
  94769. /**
  94770. * Serializes this material in a JSON representation
  94771. * @returns the serialized material object
  94772. */
  94773. serialize(): any;
  94774. /**
  94775. * Creates a standard material from parsed material data
  94776. * @param source defines the JSON representation of the material
  94777. * @param scene defines the hosting scene
  94778. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  94779. * @returns a new standard material
  94780. */
  94781. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  94782. /**
  94783. * Are diffuse textures enabled in the application.
  94784. */
  94785. static DiffuseTextureEnabled: boolean;
  94786. /**
  94787. * Are ambient textures enabled in the application.
  94788. */
  94789. static AmbientTextureEnabled: boolean;
  94790. /**
  94791. * Are opacity textures enabled in the application.
  94792. */
  94793. static OpacityTextureEnabled: boolean;
  94794. /**
  94795. * Are reflection textures enabled in the application.
  94796. */
  94797. static ReflectionTextureEnabled: boolean;
  94798. /**
  94799. * Are emissive textures enabled in the application.
  94800. */
  94801. static EmissiveTextureEnabled: boolean;
  94802. /**
  94803. * Are specular textures enabled in the application.
  94804. */
  94805. static SpecularTextureEnabled: boolean;
  94806. /**
  94807. * Are bump textures enabled in the application.
  94808. */
  94809. static BumpTextureEnabled: boolean;
  94810. /**
  94811. * Are lightmap textures enabled in the application.
  94812. */
  94813. static LightmapTextureEnabled: boolean;
  94814. /**
  94815. * Are refraction textures enabled in the application.
  94816. */
  94817. static RefractionTextureEnabled: boolean;
  94818. /**
  94819. * Are color grading textures enabled in the application.
  94820. */
  94821. static ColorGradingTextureEnabled: boolean;
  94822. /**
  94823. * Are fresnels enabled in the application.
  94824. */
  94825. static FresnelEnabled: boolean;
  94826. }
  94827. }
  94828. declare module BABYLON {
  94829. /**
  94830. * A class extending Texture allowing drawing on a texture
  94831. * @see http://doc.babylonjs.com/how_to/dynamictexture
  94832. */
  94833. export class DynamicTexture extends Texture {
  94834. private _generateMipMaps;
  94835. private _canvas;
  94836. private _context;
  94837. private _engine;
  94838. /**
  94839. * Creates a DynamicTexture
  94840. * @param name defines the name of the texture
  94841. * @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
  94842. * @param scene defines the scene where you want the texture
  94843. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  94844. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  94845. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  94846. */
  94847. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  94848. /**
  94849. * Get the current class name of the texture useful for serialization or dynamic coding.
  94850. * @returns "DynamicTexture"
  94851. */
  94852. getClassName(): string;
  94853. /**
  94854. * Gets the current state of canRescale
  94855. */
  94856. readonly canRescale: boolean;
  94857. private _recreate;
  94858. /**
  94859. * Scales the texture
  94860. * @param ratio the scale factor to apply to both width and height
  94861. */
  94862. scale(ratio: number): void;
  94863. /**
  94864. * Resizes the texture
  94865. * @param width the new width
  94866. * @param height the new height
  94867. */
  94868. scaleTo(width: number, height: number): void;
  94869. /**
  94870. * Gets the context of the canvas used by the texture
  94871. * @returns the canvas context of the dynamic texture
  94872. */
  94873. getContext(): CanvasRenderingContext2D;
  94874. /**
  94875. * Clears the texture
  94876. */
  94877. clear(): void;
  94878. /**
  94879. * Updates the texture
  94880. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  94881. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  94882. */
  94883. update(invertY?: boolean, premulAlpha?: boolean): void;
  94884. /**
  94885. * Draws text onto the texture
  94886. * @param text defines the text to be drawn
  94887. * @param x defines the placement of the text from the left
  94888. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  94889. * @param font defines the font to be used with font-style, font-size, font-name
  94890. * @param color defines the color used for the text
  94891. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  94892. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  94893. * @param update defines whether texture is immediately update (default is true)
  94894. */
  94895. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  94896. /**
  94897. * Clones the texture
  94898. * @returns the clone of the texture.
  94899. */
  94900. clone(): DynamicTexture;
  94901. /**
  94902. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  94903. * @returns a serialized dynamic texture object
  94904. */
  94905. serialize(): any;
  94906. /** @hidden */
  94907. _rebuild(): void;
  94908. }
  94909. }
  94910. declare module BABYLON {
  94911. /** @hidden */
  94912. export var imageProcessingPixelShader: {
  94913. name: string;
  94914. shader: string;
  94915. };
  94916. }
  94917. declare module BABYLON {
  94918. /**
  94919. * ImageProcessingPostProcess
  94920. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  94921. */
  94922. export class ImageProcessingPostProcess extends PostProcess {
  94923. /**
  94924. * Default configuration related to image processing available in the PBR Material.
  94925. */
  94926. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  94927. /**
  94928. * Gets the image processing configuration used either in this material.
  94929. */
  94930. /**
  94931. * Sets the Default image processing configuration used either in the this material.
  94932. *
  94933. * If sets to null, the scene one is in use.
  94934. */
  94935. imageProcessingConfiguration: ImageProcessingConfiguration;
  94936. /**
  94937. * Keep track of the image processing observer to allow dispose and replace.
  94938. */
  94939. private _imageProcessingObserver;
  94940. /**
  94941. * Attaches a new image processing configuration to the PBR Material.
  94942. * @param configuration
  94943. */
  94944. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  94945. /**
  94946. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  94947. */
  94948. /**
  94949. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  94950. */
  94951. colorCurves: Nullable<ColorCurves>;
  94952. /**
  94953. * Gets wether the color curves effect is enabled.
  94954. */
  94955. /**
  94956. * Sets wether the color curves effect is enabled.
  94957. */
  94958. colorCurvesEnabled: boolean;
  94959. /**
  94960. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  94961. */
  94962. /**
  94963. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  94964. */
  94965. colorGradingTexture: Nullable<BaseTexture>;
  94966. /**
  94967. * Gets wether the color grading effect is enabled.
  94968. */
  94969. /**
  94970. * Gets wether the color grading effect is enabled.
  94971. */
  94972. colorGradingEnabled: boolean;
  94973. /**
  94974. * Gets exposure used in the effect.
  94975. */
  94976. /**
  94977. * Sets exposure used in the effect.
  94978. */
  94979. exposure: number;
  94980. /**
  94981. * Gets wether tonemapping is enabled or not.
  94982. */
  94983. /**
  94984. * Sets wether tonemapping is enabled or not
  94985. */
  94986. toneMappingEnabled: boolean;
  94987. /**
  94988. * Gets contrast used in the effect.
  94989. */
  94990. /**
  94991. * Sets contrast used in the effect.
  94992. */
  94993. contrast: number;
  94994. /**
  94995. * Gets Vignette stretch size.
  94996. */
  94997. /**
  94998. * Sets Vignette stretch size.
  94999. */
  95000. vignetteStretch: number;
  95001. /**
  95002. * Gets Vignette centre X Offset.
  95003. */
  95004. /**
  95005. * Sets Vignette centre X Offset.
  95006. */
  95007. vignetteCentreX: number;
  95008. /**
  95009. * Gets Vignette centre Y Offset.
  95010. */
  95011. /**
  95012. * Sets Vignette centre Y Offset.
  95013. */
  95014. vignetteCentreY: number;
  95015. /**
  95016. * Gets Vignette weight or intensity of the vignette effect.
  95017. */
  95018. /**
  95019. * Sets Vignette weight or intensity of the vignette effect.
  95020. */
  95021. vignetteWeight: number;
  95022. /**
  95023. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  95024. * if vignetteEnabled is set to true.
  95025. */
  95026. /**
  95027. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  95028. * if vignetteEnabled is set to true.
  95029. */
  95030. vignetteColor: Color4;
  95031. /**
  95032. * Gets Camera field of view used by the Vignette effect.
  95033. */
  95034. /**
  95035. * Sets Camera field of view used by the Vignette effect.
  95036. */
  95037. vignetteCameraFov: number;
  95038. /**
  95039. * Gets the vignette blend mode allowing different kind of effect.
  95040. */
  95041. /**
  95042. * Sets the vignette blend mode allowing different kind of effect.
  95043. */
  95044. vignetteBlendMode: number;
  95045. /**
  95046. * Gets wether the vignette effect is enabled.
  95047. */
  95048. /**
  95049. * Sets wether the vignette effect is enabled.
  95050. */
  95051. vignetteEnabled: boolean;
  95052. private _fromLinearSpace;
  95053. /**
  95054. * Gets wether the input of the processing is in Gamma or Linear Space.
  95055. */
  95056. /**
  95057. * Sets wether the input of the processing is in Gamma or Linear Space.
  95058. */
  95059. fromLinearSpace: boolean;
  95060. /**
  95061. * Defines cache preventing GC.
  95062. */
  95063. private _defines;
  95064. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  95065. /**
  95066. * "ImageProcessingPostProcess"
  95067. * @returns "ImageProcessingPostProcess"
  95068. */
  95069. getClassName(): string;
  95070. protected _updateParameters(): void;
  95071. dispose(camera?: Camera): void;
  95072. }
  95073. }
  95074. declare module BABYLON {
  95075. /**
  95076. * Class containing static functions to help procedurally build meshes
  95077. */
  95078. export class GroundBuilder {
  95079. /**
  95080. * Creates a ground mesh
  95081. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  95082. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  95083. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95084. * @param name defines the name of the mesh
  95085. * @param options defines the options used to create the mesh
  95086. * @param scene defines the hosting scene
  95087. * @returns the ground mesh
  95088. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  95089. */
  95090. static CreateGround(name: string, options: {
  95091. width?: number;
  95092. height?: number;
  95093. subdivisions?: number;
  95094. subdivisionsX?: number;
  95095. subdivisionsY?: number;
  95096. updatable?: boolean;
  95097. }, scene: any): Mesh;
  95098. /**
  95099. * Creates a tiled ground mesh
  95100. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  95101. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  95102. * * 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
  95103. * * 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
  95104. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  95105. * @param name defines the name of the mesh
  95106. * @param options defines the options used to create the mesh
  95107. * @param scene defines the hosting scene
  95108. * @returns the tiled ground mesh
  95109. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  95110. */
  95111. static CreateTiledGround(name: string, options: {
  95112. xmin: number;
  95113. zmin: number;
  95114. xmax: number;
  95115. zmax: number;
  95116. subdivisions?: {
  95117. w: number;
  95118. h: number;
  95119. };
  95120. precision?: {
  95121. w: number;
  95122. h: number;
  95123. };
  95124. updatable?: boolean;
  95125. }, scene: Scene): Mesh;
  95126. /**
  95127. * Creates a ground mesh from a height map
  95128. * * The parameter `url` sets the URL of the height map image resource.
  95129. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  95130. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  95131. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  95132. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  95133. * * 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.
  95134. * * 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).
  95135. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  95136. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  95137. * @param name defines the name of the mesh
  95138. * @param url defines the url to the height map
  95139. * @param options defines the options used to create the mesh
  95140. * @param scene defines the hosting scene
  95141. * @returns the ground mesh
  95142. * @see https://doc.babylonjs.com/babylon101/height_map
  95143. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  95144. */
  95145. static CreateGroundFromHeightMap(name: string, url: string, options: {
  95146. width?: number;
  95147. height?: number;
  95148. subdivisions?: number;
  95149. minHeight?: number;
  95150. maxHeight?: number;
  95151. colorFilter?: Color3;
  95152. alphaFilter?: number;
  95153. updatable?: boolean;
  95154. onReady?: (mesh: GroundMesh) => void;
  95155. }, scene: Scene): GroundMesh;
  95156. }
  95157. }
  95158. declare module BABYLON {
  95159. /**
  95160. * Class containing static functions to help procedurally build meshes
  95161. */
  95162. export class TorusBuilder {
  95163. /**
  95164. * Creates a torus mesh
  95165. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  95166. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  95167. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  95168. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  95169. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  95170. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  95171. * @param name defines the name of the mesh
  95172. * @param options defines the options used to create the mesh
  95173. * @param scene defines the hosting scene
  95174. * @returns the torus mesh
  95175. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  95176. */
  95177. static CreateTorus(name: string, options: {
  95178. diameter?: number;
  95179. thickness?: number;
  95180. tessellation?: number;
  95181. updatable?: boolean;
  95182. sideOrientation?: number;
  95183. frontUVs?: Vector4;
  95184. backUVs?: Vector4;
  95185. }, scene: any): Mesh;
  95186. }
  95187. }
  95188. declare module BABYLON {
  95189. /**
  95190. * Class containing static functions to help procedurally build meshes
  95191. */
  95192. export class CylinderBuilder {
  95193. /**
  95194. * Creates a cylinder or a cone mesh
  95195. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  95196. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  95197. * * 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.
  95198. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  95199. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  95200. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  95201. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  95202. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  95203. * * 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).
  95204. * * 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
  95205. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  95206. * * 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
  95207. * * 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.
  95208. * * If `enclose` is false, a ring surface is one element.
  95209. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  95210. * * 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
  95211. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  95212. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  95213. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  95214. * @param name defines the name of the mesh
  95215. * @param options defines the options used to create the mesh
  95216. * @param scene defines the hosting scene
  95217. * @returns the cylinder mesh
  95218. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  95219. */
  95220. static CreateCylinder(name: string, options: {
  95221. height?: number;
  95222. diameterTop?: number;
  95223. diameterBottom?: number;
  95224. diameter?: number;
  95225. tessellation?: number;
  95226. subdivisions?: number;
  95227. arc?: number;
  95228. faceColors?: Color4[];
  95229. faceUV?: Vector4[];
  95230. updatable?: boolean;
  95231. hasRings?: boolean;
  95232. enclose?: boolean;
  95233. sideOrientation?: number;
  95234. frontUVs?: Vector4;
  95235. backUVs?: Vector4;
  95236. }, scene: any): Mesh;
  95237. }
  95238. }
  95239. declare module BABYLON {
  95240. /**
  95241. * Manager for handling gamepads
  95242. */
  95243. export class GamepadManager {
  95244. private _scene?;
  95245. private _babylonGamepads;
  95246. private _oneGamepadConnected;
  95247. /** @hidden */
  95248. _isMonitoring: boolean;
  95249. private _gamepadEventSupported;
  95250. private _gamepadSupport;
  95251. /**
  95252. * observable to be triggered when the gamepad controller has been connected
  95253. */
  95254. onGamepadConnectedObservable: Observable<Gamepad>;
  95255. /**
  95256. * observable to be triggered when the gamepad controller has been disconnected
  95257. */
  95258. onGamepadDisconnectedObservable: Observable<Gamepad>;
  95259. private _onGamepadConnectedEvent;
  95260. private _onGamepadDisconnectedEvent;
  95261. /**
  95262. * Initializes the gamepad manager
  95263. * @param _scene BabylonJS scene
  95264. */
  95265. constructor(_scene?: Scene | undefined);
  95266. /**
  95267. * The gamepads in the game pad manager
  95268. */
  95269. readonly gamepads: Gamepad[];
  95270. /**
  95271. * Get the gamepad controllers based on type
  95272. * @param type The type of gamepad controller
  95273. * @returns Nullable gamepad
  95274. */
  95275. getGamepadByType(type?: number): Nullable<Gamepad>;
  95276. /**
  95277. * Disposes the gamepad manager
  95278. */
  95279. dispose(): void;
  95280. private _addNewGamepad;
  95281. private _startMonitoringGamepads;
  95282. private _stopMonitoringGamepads;
  95283. /** @hidden */
  95284. _checkGamepadsStatus(): void;
  95285. private _updateGamepadObjects;
  95286. }
  95287. }
  95288. declare module BABYLON {
  95289. interface Scene {
  95290. /** @hidden */
  95291. _gamepadManager: Nullable<GamepadManager>;
  95292. /**
  95293. * Gets the gamepad manager associated with the scene
  95294. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  95295. */
  95296. gamepadManager: GamepadManager;
  95297. }
  95298. /**
  95299. * Interface representing a free camera inputs manager
  95300. */
  95301. interface FreeCameraInputsManager {
  95302. /**
  95303. * Adds gamepad input support to the FreeCameraInputsManager.
  95304. * @returns the FreeCameraInputsManager
  95305. */
  95306. addGamepad(): FreeCameraInputsManager;
  95307. }
  95308. /**
  95309. * Interface representing an arc rotate camera inputs manager
  95310. */
  95311. interface ArcRotateCameraInputsManager {
  95312. /**
  95313. * Adds gamepad input support to the ArcRotateCamera InputManager.
  95314. * @returns the camera inputs manager
  95315. */
  95316. addGamepad(): ArcRotateCameraInputsManager;
  95317. }
  95318. /**
  95319. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  95320. */
  95321. export class GamepadSystemSceneComponent implements ISceneComponent {
  95322. /**
  95323. * The component name helpfull to identify the component in the list of scene components.
  95324. */
  95325. readonly name: string;
  95326. /**
  95327. * The scene the component belongs to.
  95328. */
  95329. scene: Scene;
  95330. /**
  95331. * Creates a new instance of the component for the given scene
  95332. * @param scene Defines the scene to register the component in
  95333. */
  95334. constructor(scene: Scene);
  95335. /**
  95336. * Registers the component in a given scene
  95337. */
  95338. register(): void;
  95339. /**
  95340. * Rebuilds the elements related to this component in case of
  95341. * context lost for instance.
  95342. */
  95343. rebuild(): void;
  95344. /**
  95345. * Disposes the component and the associated ressources
  95346. */
  95347. dispose(): void;
  95348. private _beforeCameraUpdate;
  95349. }
  95350. }
  95351. declare module BABYLON {
  95352. /**
  95353. * Options to modify the vr teleportation behavior.
  95354. */
  95355. export interface VRTeleportationOptions {
  95356. /**
  95357. * The name of the mesh which should be used as the teleportation floor. (default: null)
  95358. */
  95359. floorMeshName?: string;
  95360. /**
  95361. * A list of meshes to be used as the teleportation floor. (default: empty)
  95362. */
  95363. floorMeshes?: Mesh[];
  95364. }
  95365. /**
  95366. * Options to modify the vr experience helper's behavior.
  95367. */
  95368. export interface VRExperienceHelperOptions extends WebVROptions {
  95369. /**
  95370. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  95371. */
  95372. createDeviceOrientationCamera?: boolean;
  95373. /**
  95374. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  95375. */
  95376. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  95377. /**
  95378. * Uses the main button on the controller to toggle the laser casted. (default: true)
  95379. */
  95380. laserToggle?: boolean;
  95381. /**
  95382. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  95383. */
  95384. floorMeshes?: Mesh[];
  95385. /**
  95386. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  95387. */
  95388. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  95389. }
  95390. /**
  95391. * Helps to quickly add VR support to an existing scene.
  95392. * See http://doc.babylonjs.com/how_to/webvr_helper
  95393. */
  95394. export class VRExperienceHelper {
  95395. /** Options to modify the vr experience helper's behavior. */
  95396. webVROptions: VRExperienceHelperOptions;
  95397. private _scene;
  95398. private _position;
  95399. private _btnVR;
  95400. private _btnVRDisplayed;
  95401. private _webVRsupported;
  95402. private _webVRready;
  95403. private _webVRrequesting;
  95404. private _webVRpresenting;
  95405. private _hasEnteredVR;
  95406. private _fullscreenVRpresenting;
  95407. private _canvas;
  95408. private _webVRCamera;
  95409. private _vrDeviceOrientationCamera;
  95410. private _deviceOrientationCamera;
  95411. private _existingCamera;
  95412. private _onKeyDown;
  95413. private _onVrDisplayPresentChange;
  95414. private _onVRDisplayChanged;
  95415. private _onVRRequestPresentStart;
  95416. private _onVRRequestPresentComplete;
  95417. /**
  95418. * Observable raised when entering VR.
  95419. */
  95420. onEnteringVRObservable: Observable<VRExperienceHelper>;
  95421. /**
  95422. * Observable raised when exiting VR.
  95423. */
  95424. onExitingVRObservable: Observable<VRExperienceHelper>;
  95425. /**
  95426. * Observable raised when controller mesh is loaded.
  95427. */
  95428. onControllerMeshLoadedObservable: Observable<WebVRController>;
  95429. /** Return this.onEnteringVRObservable
  95430. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  95431. */
  95432. readonly onEnteringVR: Observable<VRExperienceHelper>;
  95433. /** Return this.onExitingVRObservable
  95434. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  95435. */
  95436. readonly onExitingVR: Observable<VRExperienceHelper>;
  95437. /** Return this.onControllerMeshLoadedObservable
  95438. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  95439. */
  95440. readonly onControllerMeshLoaded: Observable<WebVRController>;
  95441. private _rayLength;
  95442. private _useCustomVRButton;
  95443. private _teleportationRequested;
  95444. private _teleportActive;
  95445. private _floorMeshName;
  95446. private _floorMeshesCollection;
  95447. private _rotationAllowed;
  95448. private _teleportBackwardsVector;
  95449. private _teleportationTarget;
  95450. private _isDefaultTeleportationTarget;
  95451. private _postProcessMove;
  95452. private _teleportationFillColor;
  95453. private _teleportationBorderColor;
  95454. private _rotationAngle;
  95455. private _haloCenter;
  95456. private _cameraGazer;
  95457. private _padSensibilityUp;
  95458. private _padSensibilityDown;
  95459. private _leftController;
  95460. private _rightController;
  95461. /**
  95462. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  95463. */
  95464. onNewMeshSelected: Observable<AbstractMesh>;
  95465. /**
  95466. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  95467. */
  95468. onNewMeshPicked: Observable<PickingInfo>;
  95469. private _circleEase;
  95470. /**
  95471. * Observable raised before camera teleportation
  95472. */
  95473. onBeforeCameraTeleport: Observable<Vector3>;
  95474. /**
  95475. * Observable raised after camera teleportation
  95476. */
  95477. onAfterCameraTeleport: Observable<Vector3>;
  95478. /**
  95479. * Observable raised when current selected mesh gets unselected
  95480. */
  95481. onSelectedMeshUnselected: Observable<AbstractMesh>;
  95482. private _raySelectionPredicate;
  95483. /**
  95484. * To be optionaly changed by user to define custom ray selection
  95485. */
  95486. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  95487. /**
  95488. * To be optionaly changed by user to define custom selection logic (after ray selection)
  95489. */
  95490. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  95491. /**
  95492. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  95493. */
  95494. teleportationEnabled: boolean;
  95495. private _defaultHeight;
  95496. private _teleportationInitialized;
  95497. private _interactionsEnabled;
  95498. private _interactionsRequested;
  95499. private _displayGaze;
  95500. private _displayLaserPointer;
  95501. /**
  95502. * The mesh used to display where the user is going to teleport.
  95503. */
  95504. /**
  95505. * Sets the mesh to be used to display where the user is going to teleport.
  95506. */
  95507. teleportationTarget: Mesh;
  95508. /**
  95509. * 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
  95510. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  95511. * See http://doc.babylonjs.com/resources/baking_transformations
  95512. */
  95513. gazeTrackerMesh: Mesh;
  95514. /**
  95515. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  95516. */
  95517. updateGazeTrackerScale: boolean;
  95518. /**
  95519. * If the gaze trackers color should be updated when selecting meshes
  95520. */
  95521. updateGazeTrackerColor: boolean;
  95522. /**
  95523. * The gaze tracking mesh corresponding to the left controller
  95524. */
  95525. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  95526. /**
  95527. * The gaze tracking mesh corresponding to the right controller
  95528. */
  95529. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  95530. /**
  95531. * If the ray of the gaze should be displayed.
  95532. */
  95533. /**
  95534. * Sets if the ray of the gaze should be displayed.
  95535. */
  95536. displayGaze: boolean;
  95537. /**
  95538. * If the ray of the LaserPointer should be displayed.
  95539. */
  95540. /**
  95541. * Sets if the ray of the LaserPointer should be displayed.
  95542. */
  95543. displayLaserPointer: boolean;
  95544. /**
  95545. * The deviceOrientationCamera used as the camera when not in VR.
  95546. */
  95547. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  95548. /**
  95549. * Based on the current WebVR support, returns the current VR camera used.
  95550. */
  95551. readonly currentVRCamera: Nullable<Camera>;
  95552. /**
  95553. * The webVRCamera which is used when in VR.
  95554. */
  95555. readonly webVRCamera: WebVRFreeCamera;
  95556. /**
  95557. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  95558. */
  95559. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  95560. private readonly _teleportationRequestInitiated;
  95561. /**
  95562. * Defines wether or not Pointer lock should be requested when switching to
  95563. * full screen.
  95564. */
  95565. requestPointerLockOnFullScreen: boolean;
  95566. /**
  95567. * Instantiates a VRExperienceHelper.
  95568. * Helps to quickly add VR support to an existing scene.
  95569. * @param scene The scene the VRExperienceHelper belongs to.
  95570. * @param webVROptions Options to modify the vr experience helper's behavior.
  95571. */
  95572. constructor(scene: Scene,
  95573. /** Options to modify the vr experience helper's behavior. */
  95574. webVROptions?: VRExperienceHelperOptions);
  95575. private _onDefaultMeshLoaded;
  95576. private _onResize;
  95577. private _onFullscreenChange;
  95578. /**
  95579. * Gets a value indicating if we are currently in VR mode.
  95580. */
  95581. readonly isInVRMode: boolean;
  95582. private onVrDisplayPresentChange;
  95583. private onVRDisplayChanged;
  95584. private moveButtonToBottomRight;
  95585. private displayVRButton;
  95586. private updateButtonVisibility;
  95587. private _cachedAngularSensibility;
  95588. /**
  95589. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  95590. * Otherwise, will use the fullscreen API.
  95591. */
  95592. enterVR(): void;
  95593. /**
  95594. * Attempt to exit VR, or fullscreen.
  95595. */
  95596. exitVR(): void;
  95597. /**
  95598. * The position of the vr experience helper.
  95599. */
  95600. /**
  95601. * Sets the position of the vr experience helper.
  95602. */
  95603. position: Vector3;
  95604. /**
  95605. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  95606. */
  95607. enableInteractions(): void;
  95608. private readonly _noControllerIsActive;
  95609. private beforeRender;
  95610. private _isTeleportationFloor;
  95611. /**
  95612. * Adds a floor mesh to be used for teleportation.
  95613. * @param floorMesh the mesh to be used for teleportation.
  95614. */
  95615. addFloorMesh(floorMesh: Mesh): void;
  95616. /**
  95617. * Removes a floor mesh from being used for teleportation.
  95618. * @param floorMesh the mesh to be removed.
  95619. */
  95620. removeFloorMesh(floorMesh: Mesh): void;
  95621. /**
  95622. * Enables interactions and teleportation using the VR controllers and gaze.
  95623. * @param vrTeleportationOptions options to modify teleportation behavior.
  95624. */
  95625. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  95626. private _onNewGamepadConnected;
  95627. private _tryEnableInteractionOnController;
  95628. private _onNewGamepadDisconnected;
  95629. private _enableInteractionOnController;
  95630. private _checkTeleportWithRay;
  95631. private _checkRotate;
  95632. private _checkTeleportBackwards;
  95633. private _enableTeleportationOnController;
  95634. private _createTeleportationCircles;
  95635. private _displayTeleportationTarget;
  95636. private _hideTeleportationTarget;
  95637. private _rotateCamera;
  95638. private _moveTeleportationSelectorTo;
  95639. private _workingVector;
  95640. private _workingQuaternion;
  95641. private _workingMatrix;
  95642. /**
  95643. * Teleports the users feet to the desired location
  95644. * @param location The location where the user's feet should be placed
  95645. */
  95646. teleportCamera(location: Vector3): void;
  95647. private _convertNormalToDirectionOfRay;
  95648. private _castRayAndSelectObject;
  95649. private _notifySelectedMeshUnselected;
  95650. /**
  95651. * Sets the color of the laser ray from the vr controllers.
  95652. * @param color new color for the ray.
  95653. */
  95654. changeLaserColor(color: Color3): void;
  95655. /**
  95656. * Sets the color of the ray from the vr headsets gaze.
  95657. * @param color new color for the ray.
  95658. */
  95659. changeGazeColor(color: Color3): void;
  95660. /**
  95661. * Exits VR and disposes of the vr experience helper
  95662. */
  95663. dispose(): void;
  95664. /**
  95665. * Gets the name of the VRExperienceHelper class
  95666. * @returns "VRExperienceHelper"
  95667. */
  95668. getClassName(): string;
  95669. }
  95670. }
  95671. declare module BABYLON {
  95672. /**
  95673. * Manages an XRSession
  95674. * @see https://doc.babylonjs.com/how_to/webxr
  95675. */
  95676. export class WebXRSessionManager implements IDisposable {
  95677. private scene;
  95678. /**
  95679. * Fires every time a new xrFrame arrives which can be used to update the camera
  95680. */
  95681. onXRFrameObservable: Observable<any>;
  95682. /**
  95683. * Fires when the xr session is ended either by the device or manually done
  95684. */
  95685. onXRSessionEnded: Observable<any>;
  95686. /** @hidden */
  95687. _xrSession: XRSession;
  95688. /** @hidden */
  95689. _frameOfReference: XRFrameOfReference;
  95690. /** @hidden */
  95691. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  95692. /** @hidden */
  95693. _currentXRFrame: Nullable<XRFrame>;
  95694. private _xrNavigator;
  95695. private _xrDevice;
  95696. private _tmpMatrix;
  95697. /**
  95698. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  95699. * @param scene The scene which the session should be created for
  95700. */
  95701. constructor(scene: Scene);
  95702. /**
  95703. * Initializes the manager
  95704. * After initialization enterXR can be called to start an XR session
  95705. * @returns Promise which resolves after it is initialized
  95706. */
  95707. initializeAsync(): Promise<void>;
  95708. /**
  95709. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  95710. * @param sessionCreationOptions xr options to create the session with
  95711. * @param frameOfReferenceType option to configure how the xr pose is expressed
  95712. * @returns Promise which resolves after it enters XR
  95713. */
  95714. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  95715. /**
  95716. * Stops the xrSession and restores the renderloop
  95717. * @returns Promise which resolves after it exits XR
  95718. */
  95719. exitXRAsync(): Promise<void>;
  95720. /**
  95721. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  95722. * @param ray ray to cast into the environment
  95723. * @returns Promise which resolves with a collision point in the environment if it exists
  95724. */
  95725. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  95726. /**
  95727. * Checks if a session would be supported for the creation options specified
  95728. * @param options creation options to check if they are supported
  95729. * @returns true if supported
  95730. */
  95731. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  95732. /**
  95733. * @hidden
  95734. * Converts the render layer of xrSession to a render target
  95735. * @param session session to create render target for
  95736. * @param scene scene the new render target should be created for
  95737. */
  95738. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  95739. /**
  95740. * Disposes of the session manager
  95741. */
  95742. dispose(): void;
  95743. }
  95744. }
  95745. declare module BABYLON {
  95746. /**
  95747. * WebXR Camera which holds the views for the xrSession
  95748. * @see https://doc.babylonjs.com/how_to/webxr
  95749. */
  95750. export class WebXRCamera extends FreeCamera {
  95751. private static _TmpMatrix;
  95752. /**
  95753. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  95754. * @param name the name of the camera
  95755. * @param scene the scene to add the camera to
  95756. */
  95757. constructor(name: string, scene: Scene);
  95758. private _updateNumberOfRigCameras;
  95759. /** @hidden */
  95760. _updateForDualEyeDebugging(pupilDistance?: number): void;
  95761. /**
  95762. * Updates the cameras position from the current pose information of the XR session
  95763. * @param xrSessionManager the session containing pose information
  95764. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  95765. */
  95766. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  95767. }
  95768. }
  95769. declare module BABYLON {
  95770. /**
  95771. * States of the webXR experience
  95772. */
  95773. export enum WebXRState {
  95774. /**
  95775. * Transitioning to being in XR mode
  95776. */
  95777. ENTERING_XR = 0,
  95778. /**
  95779. * Transitioning to non XR mode
  95780. */
  95781. EXITING_XR = 1,
  95782. /**
  95783. * In XR mode and presenting
  95784. */
  95785. IN_XR = 2,
  95786. /**
  95787. * Not entered XR mode
  95788. */
  95789. NOT_IN_XR = 3
  95790. }
  95791. /**
  95792. * Helper class used to enable XR
  95793. * @see https://doc.babylonjs.com/how_to/webxr
  95794. */
  95795. export class WebXRExperienceHelper implements IDisposable {
  95796. private scene;
  95797. /**
  95798. * 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
  95799. */
  95800. container: AbstractMesh;
  95801. /**
  95802. * Camera used to render xr content
  95803. */
  95804. camera: WebXRCamera;
  95805. /**
  95806. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  95807. */
  95808. state: WebXRState;
  95809. private _setState;
  95810. private static _TmpVector;
  95811. /**
  95812. * Fires when the state of the experience helper has changed
  95813. */
  95814. onStateChangedObservable: Observable<WebXRState>;
  95815. /** @hidden */
  95816. _sessionManager: WebXRSessionManager;
  95817. private _nonVRCamera;
  95818. private _originalSceneAutoClear;
  95819. private _supported;
  95820. /**
  95821. * Creates the experience helper
  95822. * @param scene the scene to attach the experience helper to
  95823. * @returns a promise for the experience helper
  95824. */
  95825. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  95826. /**
  95827. * Creates a WebXRExperienceHelper
  95828. * @param scene The scene the helper should be created in
  95829. */
  95830. private constructor();
  95831. /**
  95832. * Exits XR mode and returns the scene to its original state
  95833. * @returns promise that resolves after xr mode has exited
  95834. */
  95835. exitXRAsync(): Promise<void>;
  95836. /**
  95837. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  95838. * @param sessionCreationOptions options for the XR session
  95839. * @param frameOfReference frame of reference of the XR session
  95840. * @returns promise that resolves after xr mode has entered
  95841. */
  95842. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  95843. /**
  95844. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  95845. * @param ray ray to cast into the environment
  95846. * @returns Promise which resolves with a collision point in the environment if it exists
  95847. */
  95848. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  95849. /**
  95850. * Updates the global position of the camera by moving the camera's container
  95851. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  95852. * @param position The desired global position of the camera
  95853. */
  95854. setPositionOfCameraUsingContainer(position: Vector3): void;
  95855. /**
  95856. * Rotates the xr camera by rotating the camera's container around the camera's position
  95857. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  95858. * @param rotation the desired quaternion rotation to apply to the camera
  95859. */
  95860. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  95861. /**
  95862. * Checks if the creation options are supported by the xr session
  95863. * @param options creation options
  95864. * @returns true if supported
  95865. */
  95866. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  95867. /**
  95868. * Disposes of the experience helper
  95869. */
  95870. dispose(): void;
  95871. }
  95872. }
  95873. declare module BABYLON {
  95874. /**
  95875. * Button which can be used to enter a different mode of XR
  95876. */
  95877. export class WebXREnterExitUIButton {
  95878. /** button element */
  95879. element: HTMLElement;
  95880. /** XR initialization options for the button */
  95881. initializationOptions: XRSessionCreationOptions;
  95882. /**
  95883. * Creates a WebXREnterExitUIButton
  95884. * @param element button element
  95885. * @param initializationOptions XR initialization options for the button
  95886. */
  95887. constructor(
  95888. /** button element */
  95889. element: HTMLElement,
  95890. /** XR initialization options for the button */
  95891. initializationOptions: XRSessionCreationOptions);
  95892. /**
  95893. * Overwritable function which can be used to update the button's visuals when the state changes
  95894. * @param activeButton the current active button in the UI
  95895. */
  95896. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  95897. }
  95898. /**
  95899. * Options to create the webXR UI
  95900. */
  95901. export class WebXREnterExitUIOptions {
  95902. /**
  95903. * Context to enter xr with
  95904. */
  95905. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  95906. /**
  95907. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  95908. */
  95909. customButtons?: Array<WebXREnterExitUIButton>;
  95910. }
  95911. /**
  95912. * UI to allow the user to enter/exit XR mode
  95913. */
  95914. export class WebXREnterExitUI implements IDisposable {
  95915. private scene;
  95916. private _overlay;
  95917. private _buttons;
  95918. private _activeButton;
  95919. /**
  95920. * Fired every time the active button is changed.
  95921. *
  95922. * When xr is entered via a button that launches xr that button will be the callback parameter
  95923. *
  95924. * When exiting xr the callback parameter will be null)
  95925. */
  95926. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  95927. /**
  95928. * Creates UI to allow the user to enter/exit XR mode
  95929. * @param scene the scene to add the ui to
  95930. * @param helper the xr experience helper to enter/exit xr with
  95931. * @param options options to configure the UI
  95932. * @returns the created ui
  95933. */
  95934. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  95935. private constructor();
  95936. private _updateButtons;
  95937. /**
  95938. * Disposes of the object
  95939. */
  95940. dispose(): void;
  95941. }
  95942. }
  95943. declare module BABYLON {
  95944. /**
  95945. * Represents an XR input
  95946. */
  95947. export class WebXRController {
  95948. /**
  95949. * 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
  95950. */
  95951. grip?: AbstractMesh;
  95952. /**
  95953. * Pointer which can be used to select objects or attach a visible laser to
  95954. */
  95955. pointer: AbstractMesh;
  95956. /**
  95957. * Creates the controller
  95958. * @see https://doc.babylonjs.com/how_to/webxr
  95959. * @param scene the scene which the controller should be associated to
  95960. */
  95961. constructor(scene: Scene);
  95962. /**
  95963. * Disposes of the object
  95964. */
  95965. dispose(): void;
  95966. }
  95967. /**
  95968. * XR input used to track XR inputs such as controllers/rays
  95969. */
  95970. export class WebXRInput implements IDisposable {
  95971. private helper;
  95972. /**
  95973. * XR controllers being tracked
  95974. */
  95975. controllers: Array<WebXRController>;
  95976. private _tmpMatrix;
  95977. private _frameObserver;
  95978. /**
  95979. * Initializes the WebXRInput
  95980. * @param helper experience helper which the input should be created for
  95981. */
  95982. constructor(helper: WebXRExperienceHelper);
  95983. /**
  95984. * Disposes of the object
  95985. */
  95986. dispose(): void;
  95987. }
  95988. }
  95989. declare module BABYLON {
  95990. /**
  95991. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  95992. */
  95993. export class WebXRManagedOutputCanvas implements IDisposable {
  95994. private _canvas;
  95995. /**
  95996. * xrpresent context of the canvas which can be used to display/mirror xr content
  95997. */
  95998. canvasContext: Nullable<WebGLRenderingContext>;
  95999. /**
  96000. * Initializes the canvas to be added/removed upon entering/exiting xr
  96001. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  96002. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  96003. */
  96004. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  96005. /**
  96006. * Disposes of the object
  96007. */
  96008. dispose(): void;
  96009. private _setManagedOutputCanvas;
  96010. private _addCanvas;
  96011. private _removeCanvas;
  96012. }
  96013. }
  96014. declare module BABYLON {
  96015. /**
  96016. * Contains an array of blocks representing the octree
  96017. */
  96018. export interface IOctreeContainer<T> {
  96019. /**
  96020. * Blocks within the octree
  96021. */
  96022. blocks: Array<OctreeBlock<T>>;
  96023. }
  96024. /**
  96025. * Class used to store a cell in an octree
  96026. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  96027. */
  96028. export class OctreeBlock<T> {
  96029. /**
  96030. * Gets the content of the current block
  96031. */
  96032. entries: T[];
  96033. /**
  96034. * Gets the list of block children
  96035. */
  96036. blocks: Array<OctreeBlock<T>>;
  96037. private _depth;
  96038. private _maxDepth;
  96039. private _capacity;
  96040. private _minPoint;
  96041. private _maxPoint;
  96042. private _boundingVectors;
  96043. private _creationFunc;
  96044. /**
  96045. * Creates a new block
  96046. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  96047. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  96048. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  96049. * @param depth defines the current depth of this block in the octree
  96050. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  96051. * @param creationFunc defines a callback to call when an element is added to the block
  96052. */
  96053. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  96054. /**
  96055. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  96056. */
  96057. readonly capacity: number;
  96058. /**
  96059. * Gets the minimum vector (in world space) of the block's bounding box
  96060. */
  96061. readonly minPoint: Vector3;
  96062. /**
  96063. * Gets the maximum vector (in world space) of the block's bounding box
  96064. */
  96065. readonly maxPoint: Vector3;
  96066. /**
  96067. * Add a new element to this block
  96068. * @param entry defines the element to add
  96069. */
  96070. addEntry(entry: T): void;
  96071. /**
  96072. * Remove an element from this block
  96073. * @param entry defines the element to remove
  96074. */
  96075. removeEntry(entry: T): void;
  96076. /**
  96077. * Add an array of elements to this block
  96078. * @param entries defines the array of elements to add
  96079. */
  96080. addEntries(entries: T[]): void;
  96081. /**
  96082. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  96083. * @param frustumPlanes defines the frustum planes to test
  96084. * @param selection defines the array to store current content if selection is positive
  96085. * @param allowDuplicate defines if the selection array can contains duplicated entries
  96086. */
  96087. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  96088. /**
  96089. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  96090. * @param sphereCenter defines the bounding sphere center
  96091. * @param sphereRadius defines the bounding sphere radius
  96092. * @param selection defines the array to store current content if selection is positive
  96093. * @param allowDuplicate defines if the selection array can contains duplicated entries
  96094. */
  96095. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  96096. /**
  96097. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  96098. * @param ray defines the ray to test with
  96099. * @param selection defines the array to store current content if selection is positive
  96100. */
  96101. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  96102. /**
  96103. * Subdivide the content into child blocks (this block will then be empty)
  96104. */
  96105. createInnerBlocks(): void;
  96106. /**
  96107. * @hidden
  96108. */
  96109. 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;
  96110. }
  96111. }
  96112. declare module BABYLON {
  96113. /**
  96114. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  96115. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  96116. */
  96117. export class Octree<T> {
  96118. /** 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.) */
  96119. maxDepth: number;
  96120. /**
  96121. * Blocks within the octree containing objects
  96122. */
  96123. blocks: Array<OctreeBlock<T>>;
  96124. /**
  96125. * Content stored in the octree
  96126. */
  96127. dynamicContent: T[];
  96128. private _maxBlockCapacity;
  96129. private _selectionContent;
  96130. private _creationFunc;
  96131. /**
  96132. * Creates a octree
  96133. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  96134. * @param creationFunc function to be used to instatiate the octree
  96135. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  96136. * @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.)
  96137. */
  96138. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  96139. /** 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.) */
  96140. maxDepth?: number);
  96141. /**
  96142. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  96143. * @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);
  96144. * @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);
  96145. * @param entries meshes to be added to the octree blocks
  96146. */
  96147. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  96148. /**
  96149. * Adds a mesh to the octree
  96150. * @param entry Mesh to add to the octree
  96151. */
  96152. addMesh(entry: T): void;
  96153. /**
  96154. * Remove an element from the octree
  96155. * @param entry defines the element to remove
  96156. */
  96157. removeMesh(entry: T): void;
  96158. /**
  96159. * Selects an array of meshes within the frustum
  96160. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  96161. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  96162. * @returns array of meshes within the frustum
  96163. */
  96164. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  96165. /**
  96166. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  96167. * @param sphereCenter defines the bounding sphere center
  96168. * @param sphereRadius defines the bounding sphere radius
  96169. * @param allowDuplicate defines if the selection array can contains duplicated entries
  96170. * @returns an array of objects that intersect the sphere
  96171. */
  96172. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  96173. /**
  96174. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  96175. * @param ray defines the ray to test with
  96176. * @returns array of intersected objects
  96177. */
  96178. intersectsRay(ray: Ray): SmartArray<T>;
  96179. /**
  96180. * Adds a mesh into the octree block if it intersects the block
  96181. */
  96182. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  96183. /**
  96184. * Adds a submesh into the octree block if it intersects the block
  96185. */
  96186. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  96187. }
  96188. }
  96189. declare module BABYLON {
  96190. interface Scene {
  96191. /**
  96192. * @hidden
  96193. * Backing Filed
  96194. */
  96195. _selectionOctree: Octree<AbstractMesh>;
  96196. /**
  96197. * Gets the octree used to boost mesh selection (picking)
  96198. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  96199. */
  96200. selectionOctree: Octree<AbstractMesh>;
  96201. /**
  96202. * Creates or updates the octree used to boost selection (picking)
  96203. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  96204. * @param maxCapacity defines the maximum capacity per leaf
  96205. * @param maxDepth defines the maximum depth of the octree
  96206. * @returns an octree of AbstractMesh
  96207. */
  96208. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  96209. }
  96210. interface AbstractMesh {
  96211. /**
  96212. * @hidden
  96213. * Backing Field
  96214. */
  96215. _submeshesOctree: Octree<SubMesh>;
  96216. /**
  96217. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  96218. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  96219. * @param maxCapacity defines the maximum size of each block (64 by default)
  96220. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  96221. * @returns the new octree
  96222. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  96223. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  96224. */
  96225. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  96226. }
  96227. /**
  96228. * Defines the octree scene component responsible to manage any octrees
  96229. * in a given scene.
  96230. */
  96231. export class OctreeSceneComponent {
  96232. /**
  96233. * The component name helpfull to identify the component in the list of scene components.
  96234. */
  96235. readonly name: string;
  96236. /**
  96237. * The scene the component belongs to.
  96238. */
  96239. scene: Scene;
  96240. /**
  96241. * Indicates if the meshes have been checked to make sure they are isEnabled()
  96242. */
  96243. readonly checksIsEnabled: boolean;
  96244. /**
  96245. * Creates a new instance of the component for the given scene
  96246. * @param scene Defines the scene to register the component in
  96247. */
  96248. constructor(scene: Scene);
  96249. /**
  96250. * Registers the component in a given scene
  96251. */
  96252. register(): void;
  96253. /**
  96254. * Return the list of active meshes
  96255. * @returns the list of active meshes
  96256. */
  96257. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  96258. /**
  96259. * Return the list of active sub meshes
  96260. * @param mesh The mesh to get the candidates sub meshes from
  96261. * @returns the list of active sub meshes
  96262. */
  96263. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  96264. private _tempRay;
  96265. /**
  96266. * Return the list of sub meshes intersecting with a given local ray
  96267. * @param mesh defines the mesh to find the submesh for
  96268. * @param localRay defines the ray in local space
  96269. * @returns the list of intersecting sub meshes
  96270. */
  96271. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  96272. /**
  96273. * Return the list of sub meshes colliding with a collider
  96274. * @param mesh defines the mesh to find the submesh for
  96275. * @param collider defines the collider to evaluate the collision against
  96276. * @returns the list of colliding sub meshes
  96277. */
  96278. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  96279. /**
  96280. * Rebuilds the elements related to this component in case of
  96281. * context lost for instance.
  96282. */
  96283. rebuild(): void;
  96284. /**
  96285. * Disposes the component and the associated ressources.
  96286. */
  96287. dispose(): void;
  96288. }
  96289. }
  96290. declare module BABYLON {
  96291. /**
  96292. * Class containing static functions to help procedurally build meshes
  96293. */
  96294. export class LinesBuilder {
  96295. /**
  96296. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  96297. * * 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
  96298. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  96299. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  96300. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  96301. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  96302. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  96303. * * 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
  96304. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  96305. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  96306. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  96307. * @param name defines the name of the new line system
  96308. * @param options defines the options used to create the line system
  96309. * @param scene defines the hosting scene
  96310. * @returns a new line system mesh
  96311. */
  96312. static CreateLineSystem(name: string, options: {
  96313. lines: Vector3[][];
  96314. updatable?: boolean;
  96315. instance?: Nullable<LinesMesh>;
  96316. colors?: Nullable<Color4[][]>;
  96317. useVertexAlpha?: boolean;
  96318. }, scene: Nullable<Scene>): LinesMesh;
  96319. /**
  96320. * Creates a line mesh
  96321. * 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
  96322. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  96323. * * The parameter `points` is an array successive Vector3
  96324. * * 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
  96325. * * The optional parameter `colors` is an array of successive Color4, one per line point
  96326. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  96327. * * When updating an instance, remember that only point positions can change, not the number of points
  96328. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  96329. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  96330. * @param name defines the name of the new line system
  96331. * @param options defines the options used to create the line system
  96332. * @param scene defines the hosting scene
  96333. * @returns a new line mesh
  96334. */
  96335. static CreateLines(name: string, options: {
  96336. points: Vector3[];
  96337. updatable?: boolean;
  96338. instance?: Nullable<LinesMesh>;
  96339. colors?: Color4[];
  96340. useVertexAlpha?: boolean;
  96341. }, scene?: Nullable<Scene>): LinesMesh;
  96342. /**
  96343. * Creates a dashed line mesh
  96344. * * 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
  96345. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  96346. * * The parameter `points` is an array successive Vector3
  96347. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  96348. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  96349. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  96350. * * 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
  96351. * * When updating an instance, remember that only point positions can change, not the number of points
  96352. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  96353. * @param name defines the name of the mesh
  96354. * @param options defines the options used to create the mesh
  96355. * @param scene defines the hosting scene
  96356. * @returns the dashed line mesh
  96357. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  96358. */
  96359. static CreateDashedLines(name: string, options: {
  96360. points: Vector3[];
  96361. dashSize?: number;
  96362. gapSize?: number;
  96363. dashNb?: number;
  96364. updatable?: boolean;
  96365. instance?: LinesMesh;
  96366. }, scene?: Nullable<Scene>): LinesMesh;
  96367. }
  96368. }
  96369. declare module BABYLON {
  96370. /**
  96371. * Renders a layer on top of an existing scene
  96372. */
  96373. export class UtilityLayerRenderer implements IDisposable {
  96374. /** the original scene that will be rendered on top of */
  96375. originalScene: Scene;
  96376. private _pointerCaptures;
  96377. private _lastPointerEvents;
  96378. private static _DefaultUtilityLayer;
  96379. private static _DefaultKeepDepthUtilityLayer;
  96380. /**
  96381. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  96382. */
  96383. pickUtilitySceneFirst: boolean;
  96384. /**
  96385. * 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)
  96386. */
  96387. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  96388. /**
  96389. * 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)
  96390. */
  96391. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  96392. /**
  96393. * The scene that is rendered on top of the original scene
  96394. */
  96395. utilityLayerScene: Scene;
  96396. /**
  96397. * If the utility layer should automatically be rendered on top of existing scene
  96398. */
  96399. shouldRender: boolean;
  96400. /**
  96401. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  96402. */
  96403. onlyCheckPointerDownEvents: boolean;
  96404. /**
  96405. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  96406. */
  96407. processAllEvents: boolean;
  96408. /**
  96409. * Observable raised when the pointer move from the utility layer scene to the main scene
  96410. */
  96411. onPointerOutObservable: Observable<number>;
  96412. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  96413. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  96414. private _afterRenderObserver;
  96415. private _sceneDisposeObserver;
  96416. private _originalPointerObserver;
  96417. /**
  96418. * Instantiates a UtilityLayerRenderer
  96419. * @param originalScene the original scene that will be rendered on top of
  96420. * @param handleEvents boolean indicating if the utility layer should handle events
  96421. */
  96422. constructor(
  96423. /** the original scene that will be rendered on top of */
  96424. originalScene: Scene, handleEvents?: boolean);
  96425. private _notifyObservers;
  96426. /**
  96427. * Renders the utility layers scene on top of the original scene
  96428. */
  96429. render(): void;
  96430. /**
  96431. * Disposes of the renderer
  96432. */
  96433. dispose(): void;
  96434. private _updateCamera;
  96435. }
  96436. }
  96437. declare module BABYLON {
  96438. /**
  96439. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  96440. */
  96441. export class Gizmo implements IDisposable {
  96442. /** The utility layer the gizmo will be added to */
  96443. gizmoLayer: UtilityLayerRenderer;
  96444. /**
  96445. * The root mesh of the gizmo
  96446. */
  96447. _rootMesh: Mesh;
  96448. private _attachedMesh;
  96449. /**
  96450. * Ratio for the scale of the gizmo (Default: 1)
  96451. */
  96452. scaleRatio: number;
  96453. private _tmpMatrix;
  96454. /**
  96455. * If a custom mesh has been set (Default: false)
  96456. */
  96457. protected _customMeshSet: boolean;
  96458. /**
  96459. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  96460. * * When set, interactions will be enabled
  96461. */
  96462. attachedMesh: Nullable<AbstractMesh>;
  96463. /**
  96464. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  96465. * @param mesh The mesh to replace the default mesh of the gizmo
  96466. */
  96467. setCustomMesh(mesh: Mesh): void;
  96468. /**
  96469. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  96470. */
  96471. updateGizmoRotationToMatchAttachedMesh: boolean;
  96472. /**
  96473. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  96474. */
  96475. updateGizmoPositionToMatchAttachedMesh: boolean;
  96476. /**
  96477. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  96478. */
  96479. protected _updateScale: boolean;
  96480. protected _interactionsEnabled: boolean;
  96481. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  96482. private _beforeRenderObserver;
  96483. /**
  96484. * Creates a gizmo
  96485. * @param gizmoLayer The utility layer the gizmo will be added to
  96486. */
  96487. constructor(
  96488. /** The utility layer the gizmo will be added to */
  96489. gizmoLayer?: UtilityLayerRenderer);
  96490. private _tempVector;
  96491. /**
  96492. * @hidden
  96493. * Updates the gizmo to match the attached mesh's position/rotation
  96494. */
  96495. protected _update(): void;
  96496. /**
  96497. * Disposes of the gizmo
  96498. */
  96499. dispose(): void;
  96500. }
  96501. }
  96502. declare module BABYLON {
  96503. /**
  96504. * Single axis drag gizmo
  96505. */
  96506. export class AxisDragGizmo extends Gizmo {
  96507. /**
  96508. * Drag behavior responsible for the gizmos dragging interactions
  96509. */
  96510. dragBehavior: PointerDragBehavior;
  96511. private _pointerObserver;
  96512. /**
  96513. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  96514. */
  96515. snapDistance: number;
  96516. /**
  96517. * Event that fires each time the gizmo snaps to a new location.
  96518. * * snapDistance is the the change in distance
  96519. */
  96520. onSnapObservable: Observable<{
  96521. snapDistance: number;
  96522. }>;
  96523. /** @hidden */
  96524. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  96525. /** @hidden */
  96526. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  96527. /**
  96528. * Creates an AxisDragGizmo
  96529. * @param gizmoLayer The utility layer the gizmo will be added to
  96530. * @param dragAxis The axis which the gizmo will be able to drag on
  96531. * @param color The color of the gizmo
  96532. */
  96533. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  96534. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  96535. /**
  96536. * Disposes of the gizmo
  96537. */
  96538. dispose(): void;
  96539. }
  96540. }
  96541. declare module BABYLON.Debug {
  96542. /**
  96543. * The Axes viewer will show 3 axes in a specific point in space
  96544. */
  96545. export class AxesViewer {
  96546. private _xAxis;
  96547. private _yAxis;
  96548. private _zAxis;
  96549. private _scaleLinesFactor;
  96550. private _instanced;
  96551. /**
  96552. * Gets the hosting scene
  96553. */
  96554. scene: Scene;
  96555. /**
  96556. * Gets or sets a number used to scale line length
  96557. */
  96558. scaleLines: number;
  96559. /** Gets the node hierarchy used to render x-axis */
  96560. readonly xAxis: TransformNode;
  96561. /** Gets the node hierarchy used to render y-axis */
  96562. readonly yAxis: TransformNode;
  96563. /** Gets the node hierarchy used to render z-axis */
  96564. readonly zAxis: TransformNode;
  96565. /**
  96566. * Creates a new AxesViewer
  96567. * @param scene defines the hosting scene
  96568. * @param scaleLines defines a number used to scale line length (1 by default)
  96569. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  96570. * @param xAxis defines the node hierarchy used to render the x-axis
  96571. * @param yAxis defines the node hierarchy used to render the y-axis
  96572. * @param zAxis defines the node hierarchy used to render the z-axis
  96573. */
  96574. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  96575. /**
  96576. * Force the viewer to update
  96577. * @param position defines the position of the viewer
  96578. * @param xaxis defines the x axis of the viewer
  96579. * @param yaxis defines the y axis of the viewer
  96580. * @param zaxis defines the z axis of the viewer
  96581. */
  96582. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  96583. /**
  96584. * Creates an instance of this axes viewer.
  96585. * @returns a new axes viewer with instanced meshes
  96586. */
  96587. createInstance(): AxesViewer;
  96588. /** Releases resources */
  96589. dispose(): void;
  96590. private static _SetRenderingGroupId;
  96591. }
  96592. }
  96593. declare module BABYLON.Debug {
  96594. /**
  96595. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  96596. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  96597. */
  96598. export class BoneAxesViewer extends AxesViewer {
  96599. /**
  96600. * Gets or sets the target mesh where to display the axes viewer
  96601. */
  96602. mesh: Nullable<Mesh>;
  96603. /**
  96604. * Gets or sets the target bone where to display the axes viewer
  96605. */
  96606. bone: Nullable<Bone>;
  96607. /** Gets current position */
  96608. pos: Vector3;
  96609. /** Gets direction of X axis */
  96610. xaxis: Vector3;
  96611. /** Gets direction of Y axis */
  96612. yaxis: Vector3;
  96613. /** Gets direction of Z axis */
  96614. zaxis: Vector3;
  96615. /**
  96616. * Creates a new BoneAxesViewer
  96617. * @param scene defines the hosting scene
  96618. * @param bone defines the target bone
  96619. * @param mesh defines the target mesh
  96620. * @param scaleLines defines a scaling factor for line length (1 by default)
  96621. */
  96622. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  96623. /**
  96624. * Force the viewer to update
  96625. */
  96626. update(): void;
  96627. /** Releases resources */
  96628. dispose(): void;
  96629. }
  96630. }
  96631. declare module BABYLON {
  96632. /**
  96633. * Interface used to define scene explorer extensibility option
  96634. */
  96635. export interface IExplorerExtensibilityOption {
  96636. /**
  96637. * Define the option label
  96638. */
  96639. label: string;
  96640. /**
  96641. * Defines the action to execute on click
  96642. */
  96643. action: (entity: any) => void;
  96644. }
  96645. /**
  96646. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  96647. */
  96648. export interface IExplorerExtensibilityGroup {
  96649. /**
  96650. * Defines a predicate to test if a given type mut be extended
  96651. */
  96652. predicate: (entity: any) => boolean;
  96653. /**
  96654. * Gets the list of options added to a type
  96655. */
  96656. entries: IExplorerExtensibilityOption[];
  96657. }
  96658. /**
  96659. * Interface used to define the options to use to create the Inspector
  96660. */
  96661. export interface IInspectorOptions {
  96662. /**
  96663. * Display in overlay mode (default: false)
  96664. */
  96665. overlay?: boolean;
  96666. /**
  96667. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  96668. */
  96669. globalRoot?: HTMLElement;
  96670. /**
  96671. * Display the Scene explorer
  96672. */
  96673. showExplorer?: boolean;
  96674. /**
  96675. * Display the property inspector
  96676. */
  96677. showInspector?: boolean;
  96678. /**
  96679. * Display in embed mode (both panes on the right)
  96680. */
  96681. embedMode?: boolean;
  96682. /**
  96683. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  96684. */
  96685. handleResize?: boolean;
  96686. /**
  96687. * Allow the panes to popup (default: true)
  96688. */
  96689. enablePopup?: boolean;
  96690. /**
  96691. * Allow the panes to be closed by users (default: true)
  96692. */
  96693. enableClose?: boolean;
  96694. /**
  96695. * Optional list of extensibility entries
  96696. */
  96697. explorerExtensibility?: IExplorerExtensibilityGroup[];
  96698. /**
  96699. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  96700. */
  96701. inspectorURL?: string;
  96702. }
  96703. interface Scene {
  96704. /**
  96705. * @hidden
  96706. * Backing field
  96707. */
  96708. _debugLayer: DebugLayer;
  96709. /**
  96710. * Gets the debug layer (aka Inspector) associated with the scene
  96711. * @see http://doc.babylonjs.com/features/playground_debuglayer
  96712. */
  96713. debugLayer: DebugLayer;
  96714. }
  96715. /**
  96716. * The debug layer (aka Inspector) is the go to tool in order to better understand
  96717. * what is happening in your scene
  96718. * @see http://doc.babylonjs.com/features/playground_debuglayer
  96719. */
  96720. export class DebugLayer {
  96721. /**
  96722. * Define the url to get the inspector script from.
  96723. * By default it uses the babylonjs CDN.
  96724. * @ignoreNaming
  96725. */
  96726. static InspectorURL: string;
  96727. private _scene;
  96728. private BJSINSPECTOR;
  96729. /**
  96730. * Observable triggered when a property is changed through the inspector.
  96731. */
  96732. onPropertyChangedObservable: Observable<{
  96733. object: any;
  96734. property: string;
  96735. value: any;
  96736. initialValue: any;
  96737. }>;
  96738. /**
  96739. * Instantiates a new debug layer.
  96740. * The debug layer (aka Inspector) is the go to tool in order to better understand
  96741. * what is happening in your scene
  96742. * @see http://doc.babylonjs.com/features/playground_debuglayer
  96743. * @param scene Defines the scene to inspect
  96744. */
  96745. constructor(scene: Scene);
  96746. /** Creates the inspector window. */
  96747. private _createInspector;
  96748. /**
  96749. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  96750. * @param entity defines the entity to select
  96751. * @param lineContainerTitle defines the specific block to highlight
  96752. */
  96753. select(entity: any, lineContainerTitle?: string): void;
  96754. /** Get the inspector from bundle or global */
  96755. private _getGlobalInspector;
  96756. /**
  96757. * Get if the inspector is visible or not.
  96758. * @returns true if visible otherwise, false
  96759. */
  96760. isVisible(): boolean;
  96761. /**
  96762. * Hide the inspector and close its window.
  96763. */
  96764. hide(): void;
  96765. /**
  96766. * Launch the debugLayer.
  96767. * @param config Define the configuration of the inspector
  96768. * @return a promise fulfilled when the debug layer is visible
  96769. */
  96770. show(config?: IInspectorOptions): Promise<DebugLayer>;
  96771. }
  96772. }
  96773. declare module BABYLON {
  96774. /**
  96775. * Class containing static functions to help procedurally build meshes
  96776. */
  96777. export class BoxBuilder {
  96778. /**
  96779. * Creates a box mesh
  96780. * * The parameter `size` sets the size (float) of each box side (default 1)
  96781. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  96782. * * 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)
  96783. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  96784. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  96785. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  96786. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  96787. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  96788. * @param name defines the name of the mesh
  96789. * @param options defines the options used to create the mesh
  96790. * @param scene defines the hosting scene
  96791. * @returns the box mesh
  96792. */
  96793. static CreateBox(name: string, options: {
  96794. size?: number;
  96795. width?: number;
  96796. height?: number;
  96797. depth?: number;
  96798. faceUV?: Vector4[];
  96799. faceColors?: Color4[];
  96800. sideOrientation?: number;
  96801. frontUVs?: Vector4;
  96802. backUVs?: Vector4;
  96803. updatable?: boolean;
  96804. }, scene?: Nullable<Scene>): Mesh;
  96805. }
  96806. }
  96807. declare module BABYLON {
  96808. /**
  96809. * Class containing static functions to help procedurally build meshes
  96810. */
  96811. export class SphereBuilder {
  96812. /**
  96813. * Creates a sphere mesh
  96814. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  96815. * * 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`)
  96816. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  96817. * * 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
  96818. * * 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)
  96819. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  96820. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  96821. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  96822. * @param name defines the name of the mesh
  96823. * @param options defines the options used to create the mesh
  96824. * @param scene defines the hosting scene
  96825. * @returns the sphere mesh
  96826. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  96827. */
  96828. static CreateSphere(name: string, options: {
  96829. segments?: number;
  96830. diameter?: number;
  96831. diameterX?: number;
  96832. diameterY?: number;
  96833. diameterZ?: number;
  96834. arc?: number;
  96835. slice?: number;
  96836. sideOrientation?: number;
  96837. frontUVs?: Vector4;
  96838. backUVs?: Vector4;
  96839. updatable?: boolean;
  96840. }, scene: any): Mesh;
  96841. }
  96842. }
  96843. declare module BABYLON.Debug {
  96844. /**
  96845. * Used to show the physics impostor around the specific mesh
  96846. */
  96847. export class PhysicsViewer {
  96848. /** @hidden */
  96849. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  96850. /** @hidden */
  96851. protected _meshes: Array<Nullable<AbstractMesh>>;
  96852. /** @hidden */
  96853. protected _scene: Nullable<Scene>;
  96854. /** @hidden */
  96855. protected _numMeshes: number;
  96856. /** @hidden */
  96857. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  96858. private _renderFunction;
  96859. private _utilityLayer;
  96860. private _debugBoxMesh;
  96861. private _debugSphereMesh;
  96862. private _debugMaterial;
  96863. /**
  96864. * Creates a new PhysicsViewer
  96865. * @param scene defines the hosting scene
  96866. */
  96867. constructor(scene: Scene);
  96868. /** @hidden */
  96869. protected _updateDebugMeshes(): void;
  96870. /**
  96871. * Renders a specified physic impostor
  96872. * @param impostor defines the impostor to render
  96873. * @returns the new debug mesh used to render the impostor
  96874. */
  96875. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  96876. /**
  96877. * Hides a specified physic impostor
  96878. * @param impostor defines the impostor to hide
  96879. */
  96880. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  96881. private _getDebugMaterial;
  96882. private _getDebugBoxMesh;
  96883. private _getDebugSphereMesh;
  96884. private _getDebugMesh;
  96885. /** Releases all resources */
  96886. dispose(): void;
  96887. }
  96888. }
  96889. declare module BABYLON {
  96890. /**
  96891. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  96892. * in order to better appreciate the issue one might have.
  96893. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  96894. */
  96895. export class RayHelper {
  96896. /**
  96897. * Defines the ray we are currently tryin to visualize.
  96898. */
  96899. ray: Nullable<Ray>;
  96900. private _renderPoints;
  96901. private _renderLine;
  96902. private _renderFunction;
  96903. private _scene;
  96904. private _updateToMeshFunction;
  96905. private _attachedToMesh;
  96906. private _meshSpaceDirection;
  96907. private _meshSpaceOrigin;
  96908. /**
  96909. * Helper function to create a colored helper in a scene in one line.
  96910. * @param ray Defines the ray we are currently tryin to visualize
  96911. * @param scene Defines the scene the ray is used in
  96912. * @param color Defines the color we want to see the ray in
  96913. * @returns The newly created ray helper.
  96914. */
  96915. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  96916. /**
  96917. * Instantiate a new ray helper.
  96918. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  96919. * in order to better appreciate the issue one might have.
  96920. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  96921. * @param ray Defines the ray we are currently tryin to visualize
  96922. */
  96923. constructor(ray: Ray);
  96924. /**
  96925. * Shows the ray we are willing to debug.
  96926. * @param scene Defines the scene the ray needs to be rendered in
  96927. * @param color Defines the color the ray needs to be rendered in
  96928. */
  96929. show(scene: Scene, color?: Color3): void;
  96930. /**
  96931. * Hides the ray we are debugging.
  96932. */
  96933. hide(): void;
  96934. private _render;
  96935. /**
  96936. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  96937. * @param mesh Defines the mesh we want the helper attached to
  96938. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  96939. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  96940. * @param length Defines the length of the ray
  96941. */
  96942. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  96943. /**
  96944. * Detach the ray helper from the mesh it has previously been attached to.
  96945. */
  96946. detachFromMesh(): void;
  96947. private _updateToMesh;
  96948. /**
  96949. * Dispose the helper and release its associated resources.
  96950. */
  96951. dispose(): void;
  96952. }
  96953. }
  96954. declare module BABYLON.Debug {
  96955. /**
  96956. * Class used to render a debug view of a given skeleton
  96957. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  96958. */
  96959. export class SkeletonViewer {
  96960. /** defines the skeleton to render */
  96961. skeleton: Skeleton;
  96962. /** defines the mesh attached to the skeleton */
  96963. mesh: AbstractMesh;
  96964. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  96965. autoUpdateBonesMatrices: boolean;
  96966. /** defines the rendering group id to use with the viewer */
  96967. renderingGroupId: number;
  96968. /** Gets or sets the color used to render the skeleton */
  96969. color: Color3;
  96970. private _scene;
  96971. private _debugLines;
  96972. private _debugMesh;
  96973. private _isEnabled;
  96974. private _renderFunction;
  96975. private _utilityLayer;
  96976. /**
  96977. * Returns the mesh used to render the bones
  96978. */
  96979. readonly debugMesh: Nullable<LinesMesh>;
  96980. /**
  96981. * Creates a new SkeletonViewer
  96982. * @param skeleton defines the skeleton to render
  96983. * @param mesh defines the mesh attached to the skeleton
  96984. * @param scene defines the hosting scene
  96985. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  96986. * @param renderingGroupId defines the rendering group id to use with the viewer
  96987. */
  96988. constructor(
  96989. /** defines the skeleton to render */
  96990. skeleton: Skeleton,
  96991. /** defines the mesh attached to the skeleton */
  96992. mesh: AbstractMesh, scene: Scene,
  96993. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  96994. autoUpdateBonesMatrices?: boolean,
  96995. /** defines the rendering group id to use with the viewer */
  96996. renderingGroupId?: number);
  96997. /** Gets or sets a boolean indicating if the viewer is enabled */
  96998. isEnabled: boolean;
  96999. private _getBonePosition;
  97000. private _getLinesForBonesWithLength;
  97001. private _getLinesForBonesNoLength;
  97002. /** Update the viewer to sync with current skeleton state */
  97003. update(): void;
  97004. /** Release associated resources */
  97005. dispose(): void;
  97006. }
  97007. }
  97008. declare module BABYLON {
  97009. /**
  97010. * Options to create the null engine
  97011. */
  97012. export class NullEngineOptions {
  97013. /**
  97014. * Render width (Default: 512)
  97015. */
  97016. renderWidth: number;
  97017. /**
  97018. * Render height (Default: 256)
  97019. */
  97020. renderHeight: number;
  97021. /**
  97022. * Texture size (Default: 512)
  97023. */
  97024. textureSize: number;
  97025. /**
  97026. * If delta time between frames should be constant
  97027. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97028. */
  97029. deterministicLockstep: boolean;
  97030. /**
  97031. * Maximum about of steps between frames (Default: 4)
  97032. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97033. */
  97034. lockstepMaxSteps: number;
  97035. }
  97036. /**
  97037. * The null engine class provides support for headless version of babylon.js.
  97038. * This can be used in server side scenario or for testing purposes
  97039. */
  97040. export class NullEngine extends Engine {
  97041. private _options;
  97042. /**
  97043. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97044. */
  97045. isDeterministicLockStep(): boolean;
  97046. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  97047. getLockstepMaxSteps(): number;
  97048. /**
  97049. * Sets hardware scaling, used to save performance if needed
  97050. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  97051. */
  97052. getHardwareScalingLevel(): number;
  97053. constructor(options?: NullEngineOptions);
  97054. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  97055. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  97056. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  97057. getRenderWidth(useScreen?: boolean): number;
  97058. getRenderHeight(useScreen?: boolean): number;
  97059. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  97060. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  97061. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  97062. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  97063. bindSamplers(effect: Effect): void;
  97064. enableEffect(effect: Effect): void;
  97065. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  97066. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  97067. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  97068. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  97069. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  97070. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  97071. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  97072. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  97073. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  97074. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  97075. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  97076. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  97077. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  97078. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  97079. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  97080. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  97081. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  97082. setFloat(uniform: WebGLUniformLocation, value: number): void;
  97083. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  97084. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  97085. setBool(uniform: WebGLUniformLocation, bool: number): void;
  97086. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  97087. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  97088. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  97089. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  97090. bindBuffers(vertexBuffers: {
  97091. [key: string]: VertexBuffer;
  97092. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  97093. wipeCaches(bruteForce?: boolean): void;
  97094. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  97095. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  97096. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  97097. /** @hidden */
  97098. _createTexture(): WebGLTexture;
  97099. /** @hidden */
  97100. _releaseTexture(texture: InternalTexture): void;
  97101. 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;
  97102. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  97103. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  97104. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  97105. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  97106. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  97107. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  97108. areAllEffectsReady(): boolean;
  97109. /**
  97110. * @hidden
  97111. * Get the current error code of the webGL context
  97112. * @returns the error code
  97113. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  97114. */
  97115. getError(): number;
  97116. /** @hidden */
  97117. _getUnpackAlignement(): number;
  97118. /** @hidden */
  97119. _unpackFlipY(value: boolean): void;
  97120. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  97121. /**
  97122. * Updates a dynamic vertex buffer.
  97123. * @param vertexBuffer the vertex buffer to update
  97124. * @param data the data used to update the vertex buffer
  97125. * @param byteOffset the byte offset of the data (optional)
  97126. * @param byteLength the byte length of the data (optional)
  97127. */
  97128. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  97129. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  97130. /** @hidden */
  97131. _bindTexture(channel: number, texture: InternalTexture): void;
  97132. /** @hidden */
  97133. _releaseBuffer(buffer: WebGLBuffer): boolean;
  97134. releaseEffects(): void;
  97135. displayLoadingUI(): void;
  97136. hideLoadingUI(): void;
  97137. /** @hidden */
  97138. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97139. /** @hidden */
  97140. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97141. /** @hidden */
  97142. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97143. /** @hidden */
  97144. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  97145. }
  97146. }
  97147. declare module BABYLON {
  97148. /** @hidden */
  97149. export class _OcclusionDataStorage {
  97150. /** @hidden */
  97151. occlusionInternalRetryCounter: number;
  97152. /** @hidden */
  97153. isOcclusionQueryInProgress: boolean;
  97154. /** @hidden */
  97155. isOccluded: boolean;
  97156. /** @hidden */
  97157. occlusionRetryCount: number;
  97158. /** @hidden */
  97159. occlusionType: number;
  97160. /** @hidden */
  97161. occlusionQueryAlgorithmType: number;
  97162. }
  97163. interface Engine {
  97164. /**
  97165. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  97166. * @return the new query
  97167. */
  97168. createQuery(): WebGLQuery;
  97169. /**
  97170. * Delete and release a webGL query
  97171. * @param query defines the query to delete
  97172. * @return the current engine
  97173. */
  97174. deleteQuery(query: WebGLQuery): Engine;
  97175. /**
  97176. * Check if a given query has resolved and got its value
  97177. * @param query defines the query to check
  97178. * @returns true if the query got its value
  97179. */
  97180. isQueryResultAvailable(query: WebGLQuery): boolean;
  97181. /**
  97182. * Gets the value of a given query
  97183. * @param query defines the query to check
  97184. * @returns the value of the query
  97185. */
  97186. getQueryResult(query: WebGLQuery): number;
  97187. /**
  97188. * Initiates an occlusion query
  97189. * @param algorithmType defines the algorithm to use
  97190. * @param query defines the query to use
  97191. * @returns the current engine
  97192. * @see http://doc.babylonjs.com/features/occlusionquery
  97193. */
  97194. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  97195. /**
  97196. * Ends an occlusion query
  97197. * @see http://doc.babylonjs.com/features/occlusionquery
  97198. * @param algorithmType defines the algorithm to use
  97199. * @returns the current engine
  97200. */
  97201. endOcclusionQuery(algorithmType: number): Engine;
  97202. /**
  97203. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  97204. * Please note that only one query can be issued at a time
  97205. * @returns a time token used to track the time span
  97206. */
  97207. startTimeQuery(): Nullable<_TimeToken>;
  97208. /**
  97209. * Ends a time query
  97210. * @param token defines the token used to measure the time span
  97211. * @returns the time spent (in ns)
  97212. */
  97213. endTimeQuery(token: _TimeToken): int;
  97214. /** @hidden */
  97215. _currentNonTimestampToken: Nullable<_TimeToken>;
  97216. /** @hidden */
  97217. _createTimeQuery(): WebGLQuery;
  97218. /** @hidden */
  97219. _deleteTimeQuery(query: WebGLQuery): void;
  97220. /** @hidden */
  97221. _getGlAlgorithmType(algorithmType: number): number;
  97222. /** @hidden */
  97223. _getTimeQueryResult(query: WebGLQuery): any;
  97224. /** @hidden */
  97225. _getTimeQueryAvailability(query: WebGLQuery): any;
  97226. }
  97227. interface AbstractMesh {
  97228. /**
  97229. * Backing filed
  97230. * @hidden
  97231. */
  97232. __occlusionDataStorage: _OcclusionDataStorage;
  97233. /**
  97234. * Access property
  97235. * @hidden
  97236. */
  97237. _occlusionDataStorage: _OcclusionDataStorage;
  97238. /**
  97239. * 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.
  97240. * The default value is -1 which means don't break the query and wait till the result
  97241. * @see http://doc.babylonjs.com/features/occlusionquery
  97242. */
  97243. occlusionRetryCount: number;
  97244. /**
  97245. * 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:
  97246. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  97247. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  97248. * * 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.
  97249. * @see http://doc.babylonjs.com/features/occlusionquery
  97250. */
  97251. occlusionType: number;
  97252. /**
  97253. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  97254. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  97255. * * 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.
  97256. * @see http://doc.babylonjs.com/features/occlusionquery
  97257. */
  97258. occlusionQueryAlgorithmType: number;
  97259. /**
  97260. * 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
  97261. * @see http://doc.babylonjs.com/features/occlusionquery
  97262. */
  97263. isOccluded: boolean;
  97264. /**
  97265. * Flag to check the progress status of the query
  97266. * @see http://doc.babylonjs.com/features/occlusionquery
  97267. */
  97268. isOcclusionQueryInProgress: boolean;
  97269. }
  97270. }
  97271. declare module BABYLON {
  97272. /** @hidden */
  97273. export var _forceTransformFeedbackToBundle: boolean;
  97274. interface Engine {
  97275. /**
  97276. * Creates a webGL transform feedback object
  97277. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  97278. * @returns the webGL transform feedback object
  97279. */
  97280. createTransformFeedback(): WebGLTransformFeedback;
  97281. /**
  97282. * Delete a webGL transform feedback object
  97283. * @param value defines the webGL transform feedback object to delete
  97284. */
  97285. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  97286. /**
  97287. * Bind a webGL transform feedback object to the webgl context
  97288. * @param value defines the webGL transform feedback object to bind
  97289. */
  97290. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  97291. /**
  97292. * Begins a transform feedback operation
  97293. * @param usePoints defines if points or triangles must be used
  97294. */
  97295. beginTransformFeedback(usePoints: boolean): void;
  97296. /**
  97297. * Ends a transform feedback operation
  97298. */
  97299. endTransformFeedback(): void;
  97300. /**
  97301. * Specify the varyings to use with transform feedback
  97302. * @param program defines the associated webGL program
  97303. * @param value defines the list of strings representing the varying names
  97304. */
  97305. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  97306. /**
  97307. * Bind a webGL buffer for a transform feedback operation
  97308. * @param value defines the webGL buffer to bind
  97309. */
  97310. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  97311. }
  97312. }
  97313. declare module BABYLON {
  97314. /**
  97315. * Gather the list of clipboard event types as constants.
  97316. */
  97317. export class ClipboardEventTypes {
  97318. /**
  97319. * The clipboard event is fired when a copy command is active (pressed).
  97320. */
  97321. static readonly COPY: number;
  97322. /**
  97323. * The clipboard event is fired when a cut command is active (pressed).
  97324. */
  97325. static readonly CUT: number;
  97326. /**
  97327. * The clipboard event is fired when a paste command is active (pressed).
  97328. */
  97329. static readonly PASTE: number;
  97330. }
  97331. /**
  97332. * This class is used to store clipboard related info for the onClipboardObservable event.
  97333. */
  97334. export class ClipboardInfo {
  97335. /**
  97336. * Defines the type of event (BABYLON.ClipboardEventTypes)
  97337. */
  97338. type: number;
  97339. /**
  97340. * Defines the related dom event
  97341. */
  97342. event: ClipboardEvent;
  97343. /**
  97344. *Creates an instance of ClipboardInfo.
  97345. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  97346. * @param event Defines the related dom event
  97347. */
  97348. constructor(
  97349. /**
  97350. * Defines the type of event (BABYLON.ClipboardEventTypes)
  97351. */
  97352. type: number,
  97353. /**
  97354. * Defines the related dom event
  97355. */
  97356. event: ClipboardEvent);
  97357. /**
  97358. * Get the clipboard event's type from the keycode.
  97359. * @param keyCode Defines the keyCode for the current keyboard event.
  97360. * @return {number}
  97361. */
  97362. static GetTypeFromCharacter(keyCode: number): number;
  97363. }
  97364. }
  97365. declare module BABYLON {
  97366. /**
  97367. * Class used to represent data loading progression
  97368. */
  97369. export class SceneLoaderProgressEvent {
  97370. /** defines if data length to load can be evaluated */
  97371. readonly lengthComputable: boolean;
  97372. /** defines the loaded data length */
  97373. readonly loaded: number;
  97374. /** defines the data length to load */
  97375. readonly total: number;
  97376. /**
  97377. * Create a new progress event
  97378. * @param lengthComputable defines if data length to load can be evaluated
  97379. * @param loaded defines the loaded data length
  97380. * @param total defines the data length to load
  97381. */
  97382. constructor(
  97383. /** defines if data length to load can be evaluated */
  97384. lengthComputable: boolean,
  97385. /** defines the loaded data length */
  97386. loaded: number,
  97387. /** defines the data length to load */
  97388. total: number);
  97389. /**
  97390. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  97391. * @param event defines the source event
  97392. * @returns a new SceneLoaderProgressEvent
  97393. */
  97394. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  97395. }
  97396. /**
  97397. * Interface used by SceneLoader plugins to define supported file extensions
  97398. */
  97399. export interface ISceneLoaderPluginExtensions {
  97400. /**
  97401. * Defines the list of supported extensions
  97402. */
  97403. [extension: string]: {
  97404. isBinary: boolean;
  97405. };
  97406. }
  97407. /**
  97408. * Interface used by SceneLoader plugin factory
  97409. */
  97410. export interface ISceneLoaderPluginFactory {
  97411. /**
  97412. * Defines the name of the factory
  97413. */
  97414. name: string;
  97415. /**
  97416. * Function called to create a new plugin
  97417. * @return the new plugin
  97418. */
  97419. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  97420. /**
  97421. * Boolean indicating if the plugin can direct load specific data
  97422. */
  97423. canDirectLoad?: (data: string) => boolean;
  97424. }
  97425. /**
  97426. * Interface used to define a SceneLoader plugin
  97427. */
  97428. export interface ISceneLoaderPlugin {
  97429. /**
  97430. * The friendly name of this plugin.
  97431. */
  97432. name: string;
  97433. /**
  97434. * The file extensions supported by this plugin.
  97435. */
  97436. extensions: string | ISceneLoaderPluginExtensions;
  97437. /**
  97438. * Import meshes into a scene.
  97439. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  97440. * @param scene The scene to import into
  97441. * @param data The data to import
  97442. * @param rootUrl The root url for scene and resources
  97443. * @param meshes The meshes array to import into
  97444. * @param particleSystems The particle systems array to import into
  97445. * @param skeletons The skeletons array to import into
  97446. * @param onError The callback when import fails
  97447. * @returns True if successful or false otherwise
  97448. */
  97449. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  97450. /**
  97451. * Load into a scene.
  97452. * @param scene The scene to load into
  97453. * @param data The data to import
  97454. * @param rootUrl The root url for scene and resources
  97455. * @param onError The callback when import fails
  97456. * @returns true if successful or false otherwise
  97457. */
  97458. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  97459. /**
  97460. * The callback that returns true if the data can be directly loaded.
  97461. */
  97462. canDirectLoad?: (data: string) => boolean;
  97463. /**
  97464. * The callback that allows custom handling of the root url based on the response url.
  97465. */
  97466. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  97467. /**
  97468. * Load into an asset container.
  97469. * @param scene The scene to load into
  97470. * @param data The data to import
  97471. * @param rootUrl The root url for scene and resources
  97472. * @param onError The callback when import fails
  97473. * @returns The loaded asset container
  97474. */
  97475. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  97476. }
  97477. /**
  97478. * Interface used to define an async SceneLoader plugin
  97479. */
  97480. export interface ISceneLoaderPluginAsync {
  97481. /**
  97482. * The friendly name of this plugin.
  97483. */
  97484. name: string;
  97485. /**
  97486. * The file extensions supported by this plugin.
  97487. */
  97488. extensions: string | ISceneLoaderPluginExtensions;
  97489. /**
  97490. * Import meshes into a scene.
  97491. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  97492. * @param scene The scene to import into
  97493. * @param data The data to import
  97494. * @param rootUrl The root url for scene and resources
  97495. * @param onProgress The callback when the load progresses
  97496. * @param fileName Defines the name of the file to load
  97497. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  97498. */
  97499. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  97500. meshes: AbstractMesh[];
  97501. particleSystems: IParticleSystem[];
  97502. skeletons: Skeleton[];
  97503. animationGroups: AnimationGroup[];
  97504. }>;
  97505. /**
  97506. * Load into a scene.
  97507. * @param scene The scene to load into
  97508. * @param data The data to import
  97509. * @param rootUrl The root url for scene and resources
  97510. * @param onProgress The callback when the load progresses
  97511. * @param fileName Defines the name of the file to load
  97512. * @returns Nothing
  97513. */
  97514. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  97515. /**
  97516. * The callback that returns true if the data can be directly loaded.
  97517. */
  97518. canDirectLoad?: (data: string) => boolean;
  97519. /**
  97520. * The callback that allows custom handling of the root url based on the response url.
  97521. */
  97522. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  97523. /**
  97524. * Load into an asset container.
  97525. * @param scene The scene to load into
  97526. * @param data The data to import
  97527. * @param rootUrl The root url for scene and resources
  97528. * @param onProgress The callback when the load progresses
  97529. * @param fileName Defines the name of the file to load
  97530. * @returns The loaded asset container
  97531. */
  97532. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  97533. }
  97534. /**
  97535. * Class used to load scene from various file formats using registered plugins
  97536. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  97537. */
  97538. export class SceneLoader {
  97539. /**
  97540. * No logging while loading
  97541. */
  97542. static readonly NO_LOGGING: number;
  97543. /**
  97544. * Minimal logging while loading
  97545. */
  97546. static readonly MINIMAL_LOGGING: number;
  97547. /**
  97548. * Summary logging while loading
  97549. */
  97550. static readonly SUMMARY_LOGGING: number;
  97551. /**
  97552. * Detailled logging while loading
  97553. */
  97554. static readonly DETAILED_LOGGING: number;
  97555. /**
  97556. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  97557. */
  97558. static ForceFullSceneLoadingForIncremental: boolean;
  97559. /**
  97560. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  97561. */
  97562. static ShowLoadingScreen: boolean;
  97563. /**
  97564. * Defines the current logging level (while loading the scene)
  97565. * @ignorenaming
  97566. */
  97567. static loggingLevel: number;
  97568. /**
  97569. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  97570. */
  97571. static CleanBoneMatrixWeights: boolean;
  97572. /**
  97573. * Event raised when a plugin is used to load a scene
  97574. */
  97575. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  97576. private static _registeredPlugins;
  97577. private static _getDefaultPlugin;
  97578. private static _getPluginForExtension;
  97579. private static _getPluginForDirectLoad;
  97580. private static _getPluginForFilename;
  97581. private static _getDirectLoad;
  97582. private static _loadData;
  97583. private static _getFileInfo;
  97584. /**
  97585. * Gets a plugin that can load the given extension
  97586. * @param extension defines the extension to load
  97587. * @returns a plugin or null if none works
  97588. */
  97589. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  97590. /**
  97591. * Gets a boolean indicating that the given extension can be loaded
  97592. * @param extension defines the extension to load
  97593. * @returns true if the extension is supported
  97594. */
  97595. static IsPluginForExtensionAvailable(extension: string): boolean;
  97596. /**
  97597. * Adds a new plugin to the list of registered plugins
  97598. * @param plugin defines the plugin to add
  97599. */
  97600. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  97601. /**
  97602. * Import meshes into a scene
  97603. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  97604. * @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)
  97605. * @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)
  97606. * @param scene the instance of BABYLON.Scene to append to
  97607. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  97608. * @param onProgress a callback with a progress event for each file being loaded
  97609. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  97610. * @param pluginExtension the extension used to determine the plugin
  97611. * @returns The loaded plugin
  97612. */
  97613. 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>;
  97614. /**
  97615. * Import meshes into a scene
  97616. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  97617. * @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)
  97618. * @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)
  97619. * @param scene the instance of BABYLON.Scene to append to
  97620. * @param onProgress a callback with a progress event for each file being loaded
  97621. * @param pluginExtension the extension used to determine the plugin
  97622. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  97623. */
  97624. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  97625. meshes: AbstractMesh[];
  97626. particleSystems: IParticleSystem[];
  97627. skeletons: Skeleton[];
  97628. animationGroups: AnimationGroup[];
  97629. }>;
  97630. /**
  97631. * Load a scene
  97632. * @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)
  97633. * @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)
  97634. * @param engine is the instance of BABYLON.Engine to use to create the scene
  97635. * @param onSuccess a callback with the scene when import succeeds
  97636. * @param onProgress a callback with a progress event for each file being loaded
  97637. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  97638. * @param pluginExtension the extension used to determine the plugin
  97639. * @returns The loaded plugin
  97640. */
  97641. 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>;
  97642. /**
  97643. * Load a scene
  97644. * @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)
  97645. * @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)
  97646. * @param engine is the instance of BABYLON.Engine to use to create the scene
  97647. * @param onProgress a callback with a progress event for each file being loaded
  97648. * @param pluginExtension the extension used to determine the plugin
  97649. * @returns The loaded scene
  97650. */
  97651. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  97652. /**
  97653. * Append a scene
  97654. * @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)
  97655. * @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)
  97656. * @param scene is the instance of BABYLON.Scene to append to
  97657. * @param onSuccess a callback with the scene when import succeeds
  97658. * @param onProgress a callback with a progress event for each file being loaded
  97659. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  97660. * @param pluginExtension the extension used to determine the plugin
  97661. * @returns The loaded plugin
  97662. */
  97663. 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>;
  97664. /**
  97665. * Append a scene
  97666. * @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)
  97667. * @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)
  97668. * @param scene is the instance of BABYLON.Scene to append to
  97669. * @param onProgress a callback with a progress event for each file being loaded
  97670. * @param pluginExtension the extension used to determine the plugin
  97671. * @returns The given scene
  97672. */
  97673. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  97674. /**
  97675. * Load a scene into an asset container
  97676. * @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)
  97677. * @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)
  97678. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  97679. * @param onSuccess a callback with the scene when import succeeds
  97680. * @param onProgress a callback with a progress event for each file being loaded
  97681. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  97682. * @param pluginExtension the extension used to determine the plugin
  97683. * @returns The loaded plugin
  97684. */
  97685. 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>;
  97686. /**
  97687. * Load a scene into an asset container
  97688. * @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)
  97689. * @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)
  97690. * @param scene is the instance of Scene to append to
  97691. * @param onProgress a callback with a progress event for each file being loaded
  97692. * @param pluginExtension the extension used to determine the plugin
  97693. * @returns The loaded asset container
  97694. */
  97695. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  97696. }
  97697. }
  97698. declare module BABYLON {
  97699. /**
  97700. * Google Daydream controller
  97701. */
  97702. export class DaydreamController extends WebVRController {
  97703. /**
  97704. * Base Url for the controller model.
  97705. */
  97706. static MODEL_BASE_URL: string;
  97707. /**
  97708. * File name for the controller model.
  97709. */
  97710. static MODEL_FILENAME: string;
  97711. /**
  97712. * Gamepad Id prefix used to identify Daydream Controller.
  97713. */
  97714. static readonly GAMEPAD_ID_PREFIX: string;
  97715. /**
  97716. * Creates a new DaydreamController from a gamepad
  97717. * @param vrGamepad the gamepad that the controller should be created from
  97718. */
  97719. constructor(vrGamepad: any);
  97720. /**
  97721. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  97722. * @param scene scene in which to add meshes
  97723. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  97724. */
  97725. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97726. /**
  97727. * Called once for each button that changed state since the last frame
  97728. * @param buttonIdx Which button index changed
  97729. * @param state New state of the button
  97730. * @param changes Which properties on the state changed since last frame
  97731. */
  97732. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97733. }
  97734. }
  97735. declare module BABYLON {
  97736. /**
  97737. * Gear VR Controller
  97738. */
  97739. export class GearVRController extends WebVRController {
  97740. /**
  97741. * Base Url for the controller model.
  97742. */
  97743. static MODEL_BASE_URL: string;
  97744. /**
  97745. * File name for the controller model.
  97746. */
  97747. static MODEL_FILENAME: string;
  97748. /**
  97749. * Gamepad Id prefix used to identify this controller.
  97750. */
  97751. static readonly GAMEPAD_ID_PREFIX: string;
  97752. private readonly _buttonIndexToObservableNameMap;
  97753. /**
  97754. * Creates a new GearVRController from a gamepad
  97755. * @param vrGamepad the gamepad that the controller should be created from
  97756. */
  97757. constructor(vrGamepad: any);
  97758. /**
  97759. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  97760. * @param scene scene in which to add meshes
  97761. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  97762. */
  97763. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97764. /**
  97765. * Called once for each button that changed state since the last frame
  97766. * @param buttonIdx Which button index changed
  97767. * @param state New state of the button
  97768. * @param changes Which properties on the state changed since last frame
  97769. */
  97770. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97771. }
  97772. }
  97773. declare module BABYLON {
  97774. /**
  97775. * Generic Controller
  97776. */
  97777. export class GenericController extends WebVRController {
  97778. /**
  97779. * Base Url for the controller model.
  97780. */
  97781. static readonly MODEL_BASE_URL: string;
  97782. /**
  97783. * File name for the controller model.
  97784. */
  97785. static readonly MODEL_FILENAME: string;
  97786. /**
  97787. * Creates a new GenericController from a gamepad
  97788. * @param vrGamepad the gamepad that the controller should be created from
  97789. */
  97790. constructor(vrGamepad: any);
  97791. /**
  97792. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  97793. * @param scene scene in which to add meshes
  97794. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  97795. */
  97796. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97797. /**
  97798. * Called once for each button that changed state since the last frame
  97799. * @param buttonIdx Which button index changed
  97800. * @param state New state of the button
  97801. * @param changes Which properties on the state changed since last frame
  97802. */
  97803. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97804. }
  97805. }
  97806. declare module BABYLON {
  97807. /**
  97808. * Oculus Touch Controller
  97809. */
  97810. export class OculusTouchController extends WebVRController {
  97811. /**
  97812. * Base Url for the controller model.
  97813. */
  97814. static MODEL_BASE_URL: string;
  97815. /**
  97816. * File name for the left controller model.
  97817. */
  97818. static MODEL_LEFT_FILENAME: string;
  97819. /**
  97820. * File name for the right controller model.
  97821. */
  97822. static MODEL_RIGHT_FILENAME: string;
  97823. /**
  97824. * Fired when the secondary trigger on this controller is modified
  97825. */
  97826. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  97827. /**
  97828. * Fired when the thumb rest on this controller is modified
  97829. */
  97830. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  97831. /**
  97832. * Creates a new OculusTouchController from a gamepad
  97833. * @param vrGamepad the gamepad that the controller should be created from
  97834. */
  97835. constructor(vrGamepad: any);
  97836. /**
  97837. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  97838. * @param scene scene in which to add meshes
  97839. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  97840. */
  97841. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97842. /**
  97843. * Fired when the A button on this controller is modified
  97844. */
  97845. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97846. /**
  97847. * Fired when the B button on this controller is modified
  97848. */
  97849. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97850. /**
  97851. * Fired when the X button on this controller is modified
  97852. */
  97853. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97854. /**
  97855. * Fired when the Y button on this controller is modified
  97856. */
  97857. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97858. /**
  97859. * Called once for each button that changed state since the last frame
  97860. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  97861. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  97862. * 2) secondary trigger (same)
  97863. * 3) A (right) X (left), touch, pressed = value
  97864. * 4) B / Y
  97865. * 5) thumb rest
  97866. * @param buttonIdx Which button index changed
  97867. * @param state New state of the button
  97868. * @param changes Which properties on the state changed since last frame
  97869. */
  97870. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97871. }
  97872. }
  97873. declare module BABYLON {
  97874. /**
  97875. * Vive Controller
  97876. */
  97877. export class ViveController extends WebVRController {
  97878. /**
  97879. * Base Url for the controller model.
  97880. */
  97881. static MODEL_BASE_URL: string;
  97882. /**
  97883. * File name for the controller model.
  97884. */
  97885. static MODEL_FILENAME: string;
  97886. /**
  97887. * Creates a new ViveController from a gamepad
  97888. * @param vrGamepad the gamepad that the controller should be created from
  97889. */
  97890. constructor(vrGamepad: any);
  97891. /**
  97892. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  97893. * @param scene scene in which to add meshes
  97894. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  97895. */
  97896. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97897. /**
  97898. * Fired when the left button on this controller is modified
  97899. */
  97900. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97901. /**
  97902. * Fired when the right button on this controller is modified
  97903. */
  97904. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97905. /**
  97906. * Fired when the menu button on this controller is modified
  97907. */
  97908. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97909. /**
  97910. * Called once for each button that changed state since the last frame
  97911. * Vive mapping:
  97912. * 0: touchpad
  97913. * 1: trigger
  97914. * 2: left AND right buttons
  97915. * 3: menu button
  97916. * @param buttonIdx Which button index changed
  97917. * @param state New state of the button
  97918. * @param changes Which properties on the state changed since last frame
  97919. */
  97920. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97921. }
  97922. }
  97923. declare module BABYLON {
  97924. /**
  97925. * Defines the WindowsMotionController object that the state of the windows motion controller
  97926. */
  97927. export class WindowsMotionController extends WebVRController {
  97928. /**
  97929. * The base url used to load the left and right controller models
  97930. */
  97931. static MODEL_BASE_URL: string;
  97932. /**
  97933. * The name of the left controller model file
  97934. */
  97935. static MODEL_LEFT_FILENAME: string;
  97936. /**
  97937. * The name of the right controller model file
  97938. */
  97939. static MODEL_RIGHT_FILENAME: string;
  97940. /**
  97941. * The controller name prefix for this controller type
  97942. */
  97943. static readonly GAMEPAD_ID_PREFIX: string;
  97944. /**
  97945. * The controller id pattern for this controller type
  97946. */
  97947. private static readonly GAMEPAD_ID_PATTERN;
  97948. private _loadedMeshInfo;
  97949. private readonly _mapping;
  97950. /**
  97951. * Fired when the trackpad on this controller is clicked
  97952. */
  97953. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  97954. /**
  97955. * Fired when the trackpad on this controller is modified
  97956. */
  97957. onTrackpadValuesChangedObservable: Observable<StickValues>;
  97958. /**
  97959. * The current x and y values of this controller's trackpad
  97960. */
  97961. trackpad: StickValues;
  97962. /**
  97963. * Creates a new WindowsMotionController from a gamepad
  97964. * @param vrGamepad the gamepad that the controller should be created from
  97965. */
  97966. constructor(vrGamepad: any);
  97967. /**
  97968. * Fired when the trigger on this controller is modified
  97969. */
  97970. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97971. /**
  97972. * Fired when the menu button on this controller is modified
  97973. */
  97974. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97975. /**
  97976. * Fired when the grip button on this controller is modified
  97977. */
  97978. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97979. /**
  97980. * Fired when the thumbstick button on this controller is modified
  97981. */
  97982. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97983. /**
  97984. * Fired when the touchpad button on this controller is modified
  97985. */
  97986. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97987. /**
  97988. * Fired when the touchpad values on this controller are modified
  97989. */
  97990. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  97991. private _updateTrackpad;
  97992. /**
  97993. * Called once per frame by the engine.
  97994. */
  97995. update(): void;
  97996. /**
  97997. * Called once for each button that changed state since the last frame
  97998. * @param buttonIdx Which button index changed
  97999. * @param state New state of the button
  98000. * @param changes Which properties on the state changed since last frame
  98001. */
  98002. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98003. /**
  98004. * Moves the buttons on the controller mesh based on their current state
  98005. * @param buttonName the name of the button to move
  98006. * @param buttonValue the value of the button which determines the buttons new position
  98007. */
  98008. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  98009. /**
  98010. * Moves the axis on the controller mesh based on its current state
  98011. * @param axis the index of the axis
  98012. * @param axisValue the value of the axis which determines the meshes new position
  98013. * @hidden
  98014. */
  98015. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  98016. /**
  98017. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98018. * @param scene scene in which to add meshes
  98019. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98020. */
  98021. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  98022. /**
  98023. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  98024. * can be transformed by button presses and axes values, based on this._mapping.
  98025. *
  98026. * @param scene scene in which the meshes exist
  98027. * @param meshes list of meshes that make up the controller model to process
  98028. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  98029. */
  98030. private processModel;
  98031. private createMeshInfo;
  98032. /**
  98033. * Gets the ray of the controller in the direction the controller is pointing
  98034. * @param length the length the resulting ray should be
  98035. * @returns a ray in the direction the controller is pointing
  98036. */
  98037. getForwardRay(length?: number): Ray;
  98038. /**
  98039. * Disposes of the controller
  98040. */
  98041. dispose(): void;
  98042. }
  98043. }
  98044. declare module BABYLON {
  98045. /**
  98046. * Single axis scale gizmo
  98047. */
  98048. export class AxisScaleGizmo extends Gizmo {
  98049. private _coloredMaterial;
  98050. /**
  98051. * Drag behavior responsible for the gizmos dragging interactions
  98052. */
  98053. dragBehavior: PointerDragBehavior;
  98054. private _pointerObserver;
  98055. /**
  98056. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  98057. */
  98058. snapDistance: number;
  98059. /**
  98060. * Event that fires each time the gizmo snaps to a new location.
  98061. * * snapDistance is the the change in distance
  98062. */
  98063. onSnapObservable: Observable<{
  98064. snapDistance: number;
  98065. }>;
  98066. /**
  98067. * If the scaling operation should be done on all axis (default: false)
  98068. */
  98069. uniformScaling: boolean;
  98070. /**
  98071. * Creates an AxisScaleGizmo
  98072. * @param gizmoLayer The utility layer the gizmo will be added to
  98073. * @param dragAxis The axis which the gizmo will be able to scale on
  98074. * @param color The color of the gizmo
  98075. */
  98076. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  98077. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  98078. /**
  98079. * Disposes of the gizmo
  98080. */
  98081. dispose(): void;
  98082. /**
  98083. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  98084. * @param mesh The mesh to replace the default mesh of the gizmo
  98085. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  98086. */
  98087. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  98088. }
  98089. }
  98090. declare module BABYLON {
  98091. /**
  98092. * Bounding box gizmo
  98093. */
  98094. export class BoundingBoxGizmo extends Gizmo {
  98095. private _lineBoundingBox;
  98096. private _rotateSpheresParent;
  98097. private _scaleBoxesParent;
  98098. private _boundingDimensions;
  98099. private _renderObserver;
  98100. private _pointerObserver;
  98101. private _scaleDragSpeed;
  98102. private _tmpQuaternion;
  98103. private _tmpVector;
  98104. private _tmpRotationMatrix;
  98105. /**
  98106. * 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)
  98107. */
  98108. ignoreChildren: boolean;
  98109. /**
  98110. * 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)
  98111. */
  98112. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  98113. /**
  98114. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  98115. */
  98116. rotationSphereSize: number;
  98117. /**
  98118. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  98119. */
  98120. scaleBoxSize: number;
  98121. /**
  98122. * 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)
  98123. */
  98124. fixedDragMeshScreenSize: boolean;
  98125. /**
  98126. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  98127. */
  98128. fixedDragMeshScreenSizeDistanceFactor: number;
  98129. /**
  98130. * Fired when a rotation sphere or scale box is dragged
  98131. */
  98132. onDragStartObservable: Observable<{}>;
  98133. /**
  98134. * Fired when a scale box is dragged
  98135. */
  98136. onScaleBoxDragObservable: Observable<{}>;
  98137. /**
  98138. * Fired when a scale box drag is ended
  98139. */
  98140. onScaleBoxDragEndObservable: Observable<{}>;
  98141. /**
  98142. * Fired when a rotation sphere is dragged
  98143. */
  98144. onRotationSphereDragObservable: Observable<{}>;
  98145. /**
  98146. * Fired when a rotation sphere drag is ended
  98147. */
  98148. onRotationSphereDragEndObservable: Observable<{}>;
  98149. /**
  98150. * 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)
  98151. */
  98152. scalePivot: Nullable<Vector3>;
  98153. private _anchorMesh;
  98154. private _existingMeshScale;
  98155. private _dragMesh;
  98156. private pointerDragBehavior;
  98157. private coloredMaterial;
  98158. private hoverColoredMaterial;
  98159. /**
  98160. * Sets the color of the bounding box gizmo
  98161. * @param color the color to set
  98162. */
  98163. setColor(color: Color3): void;
  98164. /**
  98165. * Creates an BoundingBoxGizmo
  98166. * @param gizmoLayer The utility layer the gizmo will be added to
  98167. * @param color The color of the gizmo
  98168. */
  98169. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  98170. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  98171. private _selectNode;
  98172. /**
  98173. * Updates the bounding box information for the Gizmo
  98174. */
  98175. updateBoundingBox(): void;
  98176. private _updateRotationSpheres;
  98177. private _updateScaleBoxes;
  98178. /**
  98179. * Enables rotation on the specified axis and disables rotation on the others
  98180. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  98181. */
  98182. setEnabledRotationAxis(axis: string): void;
  98183. /**
  98184. * Enables/disables scaling
  98185. * @param enable if scaling should be enabled
  98186. */
  98187. setEnabledScaling(enable: boolean): void;
  98188. private _updateDummy;
  98189. /**
  98190. * Enables a pointer drag behavior on the bounding box of the gizmo
  98191. */
  98192. enableDragBehavior(): void;
  98193. /**
  98194. * Disposes of the gizmo
  98195. */
  98196. dispose(): void;
  98197. /**
  98198. * 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)
  98199. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  98200. * @returns the bounding box mesh with the passed in mesh as a child
  98201. */
  98202. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  98203. /**
  98204. * CustomMeshes are not supported by this gizmo
  98205. * @param mesh The mesh to replace the default mesh of the gizmo
  98206. */
  98207. setCustomMesh(mesh: Mesh): void;
  98208. }
  98209. }
  98210. declare module BABYLON {
  98211. /**
  98212. * Single plane rotation gizmo
  98213. */
  98214. export class PlaneRotationGizmo extends Gizmo {
  98215. /**
  98216. * Drag behavior responsible for the gizmos dragging interactions
  98217. */
  98218. dragBehavior: PointerDragBehavior;
  98219. private _pointerObserver;
  98220. /**
  98221. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  98222. */
  98223. snapDistance: number;
  98224. /**
  98225. * Event that fires each time the gizmo snaps to a new location.
  98226. * * snapDistance is the the change in distance
  98227. */
  98228. onSnapObservable: Observable<{
  98229. snapDistance: number;
  98230. }>;
  98231. /**
  98232. * Creates a PlaneRotationGizmo
  98233. * @param gizmoLayer The utility layer the gizmo will be added to
  98234. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  98235. * @param color The color of the gizmo
  98236. * @param tessellation Amount of tessellation to be used when creating rotation circles
  98237. */
  98238. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  98239. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  98240. /**
  98241. * Disposes of the gizmo
  98242. */
  98243. dispose(): void;
  98244. }
  98245. }
  98246. declare module BABYLON {
  98247. /**
  98248. * Gizmo that enables rotating a mesh along 3 axis
  98249. */
  98250. export class RotationGizmo extends Gizmo {
  98251. /**
  98252. * Internal gizmo used for interactions on the x axis
  98253. */
  98254. xGizmo: PlaneRotationGizmo;
  98255. /**
  98256. * Internal gizmo used for interactions on the y axis
  98257. */
  98258. yGizmo: PlaneRotationGizmo;
  98259. /**
  98260. * Internal gizmo used for interactions on the z axis
  98261. */
  98262. zGizmo: PlaneRotationGizmo;
  98263. /** Fires an event when any of it's sub gizmos are dragged */
  98264. onDragStartObservable: Observable<{}>;
  98265. /** Fires an event when any of it's sub gizmos are released from dragging */
  98266. onDragEndObservable: Observable<{}>;
  98267. attachedMesh: Nullable<AbstractMesh>;
  98268. /**
  98269. * Creates a RotationGizmo
  98270. * @param gizmoLayer The utility layer the gizmo will be added to
  98271. * @param tessellation Amount of tessellation to be used when creating rotation circles
  98272. */
  98273. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  98274. updateGizmoRotationToMatchAttachedMesh: boolean;
  98275. /**
  98276. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  98277. */
  98278. snapDistance: number;
  98279. /**
  98280. * Ratio for the scale of the gizmo (Default: 1)
  98281. */
  98282. scaleRatio: number;
  98283. /**
  98284. * Disposes of the gizmo
  98285. */
  98286. dispose(): void;
  98287. /**
  98288. * CustomMeshes are not supported by this gizmo
  98289. * @param mesh The mesh to replace the default mesh of the gizmo
  98290. */
  98291. setCustomMesh(mesh: Mesh): void;
  98292. }
  98293. }
  98294. declare module BABYLON {
  98295. /**
  98296. * Gizmo that enables dragging a mesh along 3 axis
  98297. */
  98298. export class PositionGizmo extends Gizmo {
  98299. /**
  98300. * Internal gizmo used for interactions on the x axis
  98301. */
  98302. xGizmo: AxisDragGizmo;
  98303. /**
  98304. * Internal gizmo used for interactions on the y axis
  98305. */
  98306. yGizmo: AxisDragGizmo;
  98307. /**
  98308. * Internal gizmo used for interactions on the z axis
  98309. */
  98310. zGizmo: AxisDragGizmo;
  98311. /** Fires an event when any of it's sub gizmos are dragged */
  98312. onDragStartObservable: Observable<{}>;
  98313. /** Fires an event when any of it's sub gizmos are released from dragging */
  98314. onDragEndObservable: Observable<{}>;
  98315. attachedMesh: Nullable<AbstractMesh>;
  98316. /**
  98317. * Creates a PositionGizmo
  98318. * @param gizmoLayer The utility layer the gizmo will be added to
  98319. */
  98320. constructor(gizmoLayer?: UtilityLayerRenderer);
  98321. updateGizmoRotationToMatchAttachedMesh: boolean;
  98322. /**
  98323. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  98324. */
  98325. snapDistance: number;
  98326. /**
  98327. * Ratio for the scale of the gizmo (Default: 1)
  98328. */
  98329. scaleRatio: number;
  98330. /**
  98331. * Disposes of the gizmo
  98332. */
  98333. dispose(): void;
  98334. /**
  98335. * CustomMeshes are not supported by this gizmo
  98336. * @param mesh The mesh to replace the default mesh of the gizmo
  98337. */
  98338. setCustomMesh(mesh: Mesh): void;
  98339. }
  98340. }
  98341. declare module BABYLON {
  98342. /**
  98343. * Class containing static functions to help procedurally build meshes
  98344. */
  98345. export class PolyhedronBuilder {
  98346. /**
  98347. * Creates a polyhedron mesh
  98348. * * 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
  98349. * * The parameter `size` (positive float, default 1) sets the polygon size
  98350. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  98351. * * 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`
  98352. * * 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
  98353. * * 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)`)
  98354. * * 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
  98355. * * 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
  98356. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98357. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98358. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98359. * @param name defines the name of the mesh
  98360. * @param options defines the options used to create the mesh
  98361. * @param scene defines the hosting scene
  98362. * @returns the polyhedron mesh
  98363. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  98364. */
  98365. static CreatePolyhedron(name: string, options: {
  98366. type?: number;
  98367. size?: number;
  98368. sizeX?: number;
  98369. sizeY?: number;
  98370. sizeZ?: number;
  98371. custom?: any;
  98372. faceUV?: Vector4[];
  98373. faceColors?: Color4[];
  98374. flat?: boolean;
  98375. updatable?: boolean;
  98376. sideOrientation?: number;
  98377. frontUVs?: Vector4;
  98378. backUVs?: Vector4;
  98379. }, scene: Scene): Mesh;
  98380. }
  98381. }
  98382. declare module BABYLON {
  98383. /**
  98384. * Gizmo that enables scaling a mesh along 3 axis
  98385. */
  98386. export class ScaleGizmo extends Gizmo {
  98387. /**
  98388. * Internal gizmo used for interactions on the x axis
  98389. */
  98390. xGizmo: AxisScaleGizmo;
  98391. /**
  98392. * Internal gizmo used for interactions on the y axis
  98393. */
  98394. yGizmo: AxisScaleGizmo;
  98395. /**
  98396. * Internal gizmo used for interactions on the z axis
  98397. */
  98398. zGizmo: AxisScaleGizmo;
  98399. /**
  98400. * Internal gizmo used to scale all axis equally
  98401. */
  98402. uniformScaleGizmo: AxisScaleGizmo;
  98403. /** Fires an event when any of it's sub gizmos are dragged */
  98404. onDragStartObservable: Observable<{}>;
  98405. /** Fires an event when any of it's sub gizmos are released from dragging */
  98406. onDragEndObservable: Observable<{}>;
  98407. attachedMesh: Nullable<AbstractMesh>;
  98408. /**
  98409. * Creates a ScaleGizmo
  98410. * @param gizmoLayer The utility layer the gizmo will be added to
  98411. */
  98412. constructor(gizmoLayer?: UtilityLayerRenderer);
  98413. updateGizmoRotationToMatchAttachedMesh: boolean;
  98414. /**
  98415. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  98416. */
  98417. snapDistance: number;
  98418. /**
  98419. * Ratio for the scale of the gizmo (Default: 1)
  98420. */
  98421. scaleRatio: number;
  98422. /**
  98423. * Disposes of the gizmo
  98424. */
  98425. dispose(): void;
  98426. }
  98427. }
  98428. declare module BABYLON {
  98429. /**
  98430. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  98431. */
  98432. export class GizmoManager implements IDisposable {
  98433. private scene;
  98434. /**
  98435. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  98436. */
  98437. gizmos: {
  98438. positionGizmo: Nullable<PositionGizmo>;
  98439. rotationGizmo: Nullable<RotationGizmo>;
  98440. scaleGizmo: Nullable<ScaleGizmo>;
  98441. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  98442. };
  98443. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  98444. clearGizmoOnEmptyPointerEvent: boolean;
  98445. /** Fires an event when the manager is attached to a mesh */
  98446. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  98447. private _gizmosEnabled;
  98448. private _pointerObserver;
  98449. private _attachedMesh;
  98450. private _boundingBoxColor;
  98451. private _defaultUtilityLayer;
  98452. private _defaultKeepDepthUtilityLayer;
  98453. /**
  98454. * When bounding box gizmo is enabled, this can be used to track drag/end events
  98455. */
  98456. boundingBoxDragBehavior: SixDofDragBehavior;
  98457. /**
  98458. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  98459. */
  98460. attachableMeshes: Nullable<Array<AbstractMesh>>;
  98461. /**
  98462. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  98463. */
  98464. usePointerToAttachGizmos: boolean;
  98465. /**
  98466. * Instatiates a gizmo manager
  98467. * @param scene the scene to overlay the gizmos on top of
  98468. */
  98469. constructor(scene: Scene);
  98470. /**
  98471. * Attaches a set of gizmos to the specified mesh
  98472. * @param mesh The mesh the gizmo's should be attached to
  98473. */
  98474. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  98475. /**
  98476. * If the position gizmo is enabled
  98477. */
  98478. positionGizmoEnabled: boolean;
  98479. /**
  98480. * If the rotation gizmo is enabled
  98481. */
  98482. rotationGizmoEnabled: boolean;
  98483. /**
  98484. * If the scale gizmo is enabled
  98485. */
  98486. scaleGizmoEnabled: boolean;
  98487. /**
  98488. * If the boundingBox gizmo is enabled
  98489. */
  98490. boundingBoxGizmoEnabled: boolean;
  98491. /**
  98492. * Disposes of the gizmo manager
  98493. */
  98494. dispose(): void;
  98495. }
  98496. }
  98497. declare module BABYLON {
  98498. /**
  98499. * Gizmo that enables viewing a light
  98500. */
  98501. export class LightGizmo extends Gizmo {
  98502. private _box;
  98503. /**
  98504. * Creates a LightGizmo
  98505. * @param gizmoLayer The utility layer the gizmo will be added to
  98506. */
  98507. constructor(gizmoLayer?: UtilityLayerRenderer);
  98508. private _light;
  98509. /**
  98510. * The light that the gizmo is attached to
  98511. */
  98512. light: Nullable<Light>;
  98513. /**
  98514. * @hidden
  98515. * Updates the gizmo to match the attached mesh's position/rotation
  98516. */
  98517. protected _update(): void;
  98518. }
  98519. }
  98520. declare module BABYLON {
  98521. /** @hidden */
  98522. export var backgroundFragmentDeclaration: {
  98523. name: string;
  98524. shader: string;
  98525. };
  98526. }
  98527. declare module BABYLON {
  98528. /** @hidden */
  98529. export var backgroundUboDeclaration: {
  98530. name: string;
  98531. shader: string;
  98532. };
  98533. }
  98534. declare module BABYLON {
  98535. /** @hidden */
  98536. export var backgroundPixelShader: {
  98537. name: string;
  98538. shader: string;
  98539. };
  98540. }
  98541. declare module BABYLON {
  98542. /** @hidden */
  98543. export var backgroundVertexDeclaration: {
  98544. name: string;
  98545. shader: string;
  98546. };
  98547. }
  98548. declare module BABYLON {
  98549. /** @hidden */
  98550. export var backgroundVertexShader: {
  98551. name: string;
  98552. shader: string;
  98553. };
  98554. }
  98555. declare module BABYLON {
  98556. /**
  98557. * Background material used to create an efficient environement around your scene.
  98558. */
  98559. export class BackgroundMaterial extends PushMaterial {
  98560. /**
  98561. * Standard reflectance value at parallel view angle.
  98562. */
  98563. static StandardReflectance0: number;
  98564. /**
  98565. * Standard reflectance value at grazing angle.
  98566. */
  98567. static StandardReflectance90: number;
  98568. protected _primaryColor: Color3;
  98569. /**
  98570. * Key light Color (multiply against the environement texture)
  98571. */
  98572. primaryColor: Color3;
  98573. protected __perceptualColor: Nullable<Color3>;
  98574. /**
  98575. * Experimental Internal Use Only.
  98576. *
  98577. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  98578. * This acts as a helper to set the primary color to a more "human friendly" value.
  98579. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  98580. * output color as close as possible from the chosen value.
  98581. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  98582. * part of lighting setup.)
  98583. */
  98584. _perceptualColor: Nullable<Color3>;
  98585. protected _primaryColorShadowLevel: float;
  98586. /**
  98587. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  98588. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  98589. */
  98590. primaryColorShadowLevel: float;
  98591. protected _primaryColorHighlightLevel: float;
  98592. /**
  98593. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  98594. * The primary color is used at the level chosen to define what the white area would look.
  98595. */
  98596. primaryColorHighlightLevel: float;
  98597. protected _reflectionTexture: Nullable<BaseTexture>;
  98598. /**
  98599. * Reflection Texture used in the material.
  98600. * Should be author in a specific way for the best result (refer to the documentation).
  98601. */
  98602. reflectionTexture: Nullable<BaseTexture>;
  98603. protected _reflectionBlur: float;
  98604. /**
  98605. * Reflection Texture level of blur.
  98606. *
  98607. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  98608. * texture twice.
  98609. */
  98610. reflectionBlur: float;
  98611. protected _diffuseTexture: Nullable<BaseTexture>;
  98612. /**
  98613. * Diffuse Texture used in the material.
  98614. * Should be author in a specific way for the best result (refer to the documentation).
  98615. */
  98616. diffuseTexture: Nullable<BaseTexture>;
  98617. protected _shadowLights: Nullable<IShadowLight[]>;
  98618. /**
  98619. * Specify the list of lights casting shadow on the material.
  98620. * All scene shadow lights will be included if null.
  98621. */
  98622. shadowLights: Nullable<IShadowLight[]>;
  98623. protected _shadowLevel: float;
  98624. /**
  98625. * Helps adjusting the shadow to a softer level if required.
  98626. * 0 means black shadows and 1 means no shadows.
  98627. */
  98628. shadowLevel: float;
  98629. protected _sceneCenter: Vector3;
  98630. /**
  98631. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  98632. * It is usually zero but might be interesting to modify according to your setup.
  98633. */
  98634. sceneCenter: Vector3;
  98635. protected _opacityFresnel: boolean;
  98636. /**
  98637. * This helps specifying that the material is falling off to the sky box at grazing angle.
  98638. * This helps ensuring a nice transition when the camera goes under the ground.
  98639. */
  98640. opacityFresnel: boolean;
  98641. protected _reflectionFresnel: boolean;
  98642. /**
  98643. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  98644. * This helps adding a mirror texture on the ground.
  98645. */
  98646. reflectionFresnel: boolean;
  98647. protected _reflectionFalloffDistance: number;
  98648. /**
  98649. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  98650. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  98651. */
  98652. reflectionFalloffDistance: number;
  98653. protected _reflectionAmount: number;
  98654. /**
  98655. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  98656. */
  98657. reflectionAmount: number;
  98658. protected _reflectionReflectance0: number;
  98659. /**
  98660. * This specifies the weight of the reflection at grazing angle.
  98661. */
  98662. reflectionReflectance0: number;
  98663. protected _reflectionReflectance90: number;
  98664. /**
  98665. * This specifies the weight of the reflection at a perpendicular point of view.
  98666. */
  98667. reflectionReflectance90: number;
  98668. /**
  98669. * Sets the reflection reflectance fresnel values according to the default standard
  98670. * empirically know to work well :-)
  98671. */
  98672. reflectionStandardFresnelWeight: number;
  98673. protected _useRGBColor: boolean;
  98674. /**
  98675. * Helps to directly use the maps channels instead of their level.
  98676. */
  98677. useRGBColor: boolean;
  98678. protected _enableNoise: boolean;
  98679. /**
  98680. * This helps reducing the banding effect that could occur on the background.
  98681. */
  98682. enableNoise: boolean;
  98683. /**
  98684. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  98685. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  98686. * Recommended to be keep at 1.0 except for special cases.
  98687. */
  98688. fovMultiplier: number;
  98689. private _fovMultiplier;
  98690. /**
  98691. * Enable the FOV adjustment feature controlled by fovMultiplier.
  98692. */
  98693. useEquirectangularFOV: boolean;
  98694. private _maxSimultaneousLights;
  98695. /**
  98696. * Number of Simultaneous lights allowed on the material.
  98697. */
  98698. maxSimultaneousLights: int;
  98699. /**
  98700. * Default configuration related to image processing available in the Background Material.
  98701. */
  98702. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98703. /**
  98704. * Keep track of the image processing observer to allow dispose and replace.
  98705. */
  98706. private _imageProcessingObserver;
  98707. /**
  98708. * Attaches a new image processing configuration to the PBR Material.
  98709. * @param configuration (if null the scene configuration will be use)
  98710. */
  98711. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  98712. /**
  98713. * Gets the image processing configuration used either in this material.
  98714. */
  98715. /**
  98716. * Sets the Default image processing configuration used either in the this material.
  98717. *
  98718. * If sets to null, the scene one is in use.
  98719. */
  98720. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  98721. /**
  98722. * Gets wether the color curves effect is enabled.
  98723. */
  98724. /**
  98725. * Sets wether the color curves effect is enabled.
  98726. */
  98727. cameraColorCurvesEnabled: boolean;
  98728. /**
  98729. * Gets wether the color grading effect is enabled.
  98730. */
  98731. /**
  98732. * Gets wether the color grading effect is enabled.
  98733. */
  98734. cameraColorGradingEnabled: boolean;
  98735. /**
  98736. * Gets wether tonemapping is enabled or not.
  98737. */
  98738. /**
  98739. * Sets wether tonemapping is enabled or not
  98740. */
  98741. cameraToneMappingEnabled: boolean;
  98742. /**
  98743. * The camera exposure used on this material.
  98744. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98745. * This corresponds to a photographic exposure.
  98746. */
  98747. /**
  98748. * The camera exposure used on this material.
  98749. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98750. * This corresponds to a photographic exposure.
  98751. */
  98752. cameraExposure: float;
  98753. /**
  98754. * Gets The camera contrast used on this material.
  98755. */
  98756. /**
  98757. * Sets The camera contrast used on this material.
  98758. */
  98759. cameraContrast: float;
  98760. /**
  98761. * Gets the Color Grading 2D Lookup Texture.
  98762. */
  98763. /**
  98764. * Sets the Color Grading 2D Lookup Texture.
  98765. */
  98766. cameraColorGradingTexture: Nullable<BaseTexture>;
  98767. /**
  98768. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98769. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98770. * 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;
  98771. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98772. */
  98773. /**
  98774. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98775. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98776. * 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;
  98777. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98778. */
  98779. cameraColorCurves: Nullable<ColorCurves>;
  98780. /**
  98781. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  98782. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  98783. */
  98784. switchToBGR: boolean;
  98785. private _renderTargets;
  98786. private _reflectionControls;
  98787. private _white;
  98788. private _primaryShadowColor;
  98789. private _primaryHighlightColor;
  98790. /**
  98791. * Instantiates a Background Material in the given scene
  98792. * @param name The friendly name of the material
  98793. * @param scene The scene to add the material to
  98794. */
  98795. constructor(name: string, scene: Scene);
  98796. /**
  98797. * Gets a boolean indicating that current material needs to register RTT
  98798. */
  98799. readonly hasRenderTargetTextures: boolean;
  98800. /**
  98801. * The entire material has been created in order to prevent overdraw.
  98802. * @returns false
  98803. */
  98804. needAlphaTesting(): boolean;
  98805. /**
  98806. * The entire material has been created in order to prevent overdraw.
  98807. * @returns true if blending is enable
  98808. */
  98809. needAlphaBlending(): boolean;
  98810. /**
  98811. * Checks wether the material is ready to be rendered for a given mesh.
  98812. * @param mesh The mesh to render
  98813. * @param subMesh The submesh to check against
  98814. * @param useInstances Specify wether or not the material is used with instances
  98815. * @returns true if all the dependencies are ready (Textures, Effects...)
  98816. */
  98817. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  98818. /**
  98819. * Compute the primary color according to the chosen perceptual color.
  98820. */
  98821. private _computePrimaryColorFromPerceptualColor;
  98822. /**
  98823. * Compute the highlights and shadow colors according to their chosen levels.
  98824. */
  98825. private _computePrimaryColors;
  98826. /**
  98827. * Build the uniform buffer used in the material.
  98828. */
  98829. buildUniformLayout(): void;
  98830. /**
  98831. * Unbind the material.
  98832. */
  98833. unbind(): void;
  98834. /**
  98835. * Bind only the world matrix to the material.
  98836. * @param world The world matrix to bind.
  98837. */
  98838. bindOnlyWorldMatrix(world: Matrix): void;
  98839. /**
  98840. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  98841. * @param world The world matrix to bind.
  98842. * @param subMesh The submesh to bind for.
  98843. */
  98844. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  98845. /**
  98846. * Dispose the material.
  98847. * @param forceDisposeEffect Force disposal of the associated effect.
  98848. * @param forceDisposeTextures Force disposal of the associated textures.
  98849. */
  98850. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  98851. /**
  98852. * Clones the material.
  98853. * @param name The cloned name.
  98854. * @returns The cloned material.
  98855. */
  98856. clone(name: string): BackgroundMaterial;
  98857. /**
  98858. * Serializes the current material to its JSON representation.
  98859. * @returns The JSON representation.
  98860. */
  98861. serialize(): any;
  98862. /**
  98863. * Gets the class name of the material
  98864. * @returns "BackgroundMaterial"
  98865. */
  98866. getClassName(): string;
  98867. /**
  98868. * Parse a JSON input to create back a background material.
  98869. * @param source The JSON data to parse
  98870. * @param scene The scene to create the parsed material in
  98871. * @param rootUrl The root url of the assets the material depends upon
  98872. * @returns the instantiated BackgroundMaterial.
  98873. */
  98874. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  98875. }
  98876. }
  98877. declare module BABYLON {
  98878. /**
  98879. * Represents the different options available during the creation of
  98880. * a Environment helper.
  98881. *
  98882. * This can control the default ground, skybox and image processing setup of your scene.
  98883. */
  98884. export interface IEnvironmentHelperOptions {
  98885. /**
  98886. * Specifies wether or not to create a ground.
  98887. * True by default.
  98888. */
  98889. createGround: boolean;
  98890. /**
  98891. * Specifies the ground size.
  98892. * 15 by default.
  98893. */
  98894. groundSize: number;
  98895. /**
  98896. * The texture used on the ground for the main color.
  98897. * Comes from the BabylonJS CDN by default.
  98898. *
  98899. * Remarks: Can be either a texture or a url.
  98900. */
  98901. groundTexture: string | BaseTexture;
  98902. /**
  98903. * The color mixed in the ground texture by default.
  98904. * BabylonJS clearColor by default.
  98905. */
  98906. groundColor: Color3;
  98907. /**
  98908. * Specifies the ground opacity.
  98909. * 1 by default.
  98910. */
  98911. groundOpacity: number;
  98912. /**
  98913. * Enables the ground to receive shadows.
  98914. * True by default.
  98915. */
  98916. enableGroundShadow: boolean;
  98917. /**
  98918. * Helps preventing the shadow to be fully black on the ground.
  98919. * 0.5 by default.
  98920. */
  98921. groundShadowLevel: number;
  98922. /**
  98923. * Creates a mirror texture attach to the ground.
  98924. * false by default.
  98925. */
  98926. enableGroundMirror: boolean;
  98927. /**
  98928. * Specifies the ground mirror size ratio.
  98929. * 0.3 by default as the default kernel is 64.
  98930. */
  98931. groundMirrorSizeRatio: number;
  98932. /**
  98933. * Specifies the ground mirror blur kernel size.
  98934. * 64 by default.
  98935. */
  98936. groundMirrorBlurKernel: number;
  98937. /**
  98938. * Specifies the ground mirror visibility amount.
  98939. * 1 by default
  98940. */
  98941. groundMirrorAmount: number;
  98942. /**
  98943. * Specifies the ground mirror reflectance weight.
  98944. * This uses the standard weight of the background material to setup the fresnel effect
  98945. * of the mirror.
  98946. * 1 by default.
  98947. */
  98948. groundMirrorFresnelWeight: number;
  98949. /**
  98950. * Specifies the ground mirror Falloff distance.
  98951. * This can helps reducing the size of the reflection.
  98952. * 0 by Default.
  98953. */
  98954. groundMirrorFallOffDistance: number;
  98955. /**
  98956. * Specifies the ground mirror texture type.
  98957. * Unsigned Int by Default.
  98958. */
  98959. groundMirrorTextureType: number;
  98960. /**
  98961. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  98962. * the shown objects.
  98963. */
  98964. groundYBias: number;
  98965. /**
  98966. * Specifies wether or not to create a skybox.
  98967. * True by default.
  98968. */
  98969. createSkybox: boolean;
  98970. /**
  98971. * Specifies the skybox size.
  98972. * 20 by default.
  98973. */
  98974. skyboxSize: number;
  98975. /**
  98976. * The texture used on the skybox for the main color.
  98977. * Comes from the BabylonJS CDN by default.
  98978. *
  98979. * Remarks: Can be either a texture or a url.
  98980. */
  98981. skyboxTexture: string | BaseTexture;
  98982. /**
  98983. * The color mixed in the skybox texture by default.
  98984. * BabylonJS clearColor by default.
  98985. */
  98986. skyboxColor: Color3;
  98987. /**
  98988. * The background rotation around the Y axis of the scene.
  98989. * This helps aligning the key lights of your scene with the background.
  98990. * 0 by default.
  98991. */
  98992. backgroundYRotation: number;
  98993. /**
  98994. * Compute automatically the size of the elements to best fit with the scene.
  98995. */
  98996. sizeAuto: boolean;
  98997. /**
  98998. * Default position of the rootMesh if autoSize is not true.
  98999. */
  99000. rootPosition: Vector3;
  99001. /**
  99002. * Sets up the image processing in the scene.
  99003. * true by default.
  99004. */
  99005. setupImageProcessing: boolean;
  99006. /**
  99007. * The texture used as your environment texture in the scene.
  99008. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  99009. *
  99010. * Remarks: Can be either a texture or a url.
  99011. */
  99012. environmentTexture: string | BaseTexture;
  99013. /**
  99014. * The value of the exposure to apply to the scene.
  99015. * 0.6 by default if setupImageProcessing is true.
  99016. */
  99017. cameraExposure: number;
  99018. /**
  99019. * The value of the contrast to apply to the scene.
  99020. * 1.6 by default if setupImageProcessing is true.
  99021. */
  99022. cameraContrast: number;
  99023. /**
  99024. * Specifies wether or not tonemapping should be enabled in the scene.
  99025. * true by default if setupImageProcessing is true.
  99026. */
  99027. toneMappingEnabled: boolean;
  99028. }
  99029. /**
  99030. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  99031. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  99032. * It also helps with the default setup of your imageProcessing configuration.
  99033. */
  99034. export class EnvironmentHelper {
  99035. /**
  99036. * Default ground texture URL.
  99037. */
  99038. private static _groundTextureCDNUrl;
  99039. /**
  99040. * Default skybox texture URL.
  99041. */
  99042. private static _skyboxTextureCDNUrl;
  99043. /**
  99044. * Default environment texture URL.
  99045. */
  99046. private static _environmentTextureCDNUrl;
  99047. /**
  99048. * Creates the default options for the helper.
  99049. */
  99050. private static _getDefaultOptions;
  99051. private _rootMesh;
  99052. /**
  99053. * Gets the root mesh created by the helper.
  99054. */
  99055. readonly rootMesh: Mesh;
  99056. private _skybox;
  99057. /**
  99058. * Gets the skybox created by the helper.
  99059. */
  99060. readonly skybox: Nullable<Mesh>;
  99061. private _skyboxTexture;
  99062. /**
  99063. * Gets the skybox texture created by the helper.
  99064. */
  99065. readonly skyboxTexture: Nullable<BaseTexture>;
  99066. private _skyboxMaterial;
  99067. /**
  99068. * Gets the skybox material created by the helper.
  99069. */
  99070. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  99071. private _ground;
  99072. /**
  99073. * Gets the ground mesh created by the helper.
  99074. */
  99075. readonly ground: Nullable<Mesh>;
  99076. private _groundTexture;
  99077. /**
  99078. * Gets the ground texture created by the helper.
  99079. */
  99080. readonly groundTexture: Nullable<BaseTexture>;
  99081. private _groundMirror;
  99082. /**
  99083. * Gets the ground mirror created by the helper.
  99084. */
  99085. readonly groundMirror: Nullable<MirrorTexture>;
  99086. /**
  99087. * Gets the ground mirror render list to helps pushing the meshes
  99088. * you wish in the ground reflection.
  99089. */
  99090. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  99091. private _groundMaterial;
  99092. /**
  99093. * Gets the ground material created by the helper.
  99094. */
  99095. readonly groundMaterial: Nullable<BackgroundMaterial>;
  99096. /**
  99097. * Stores the creation options.
  99098. */
  99099. private readonly _scene;
  99100. private _options;
  99101. /**
  99102. * This observable will be notified with any error during the creation of the environment,
  99103. * mainly texture creation errors.
  99104. */
  99105. onErrorObservable: Observable<{
  99106. message?: string;
  99107. exception?: any;
  99108. }>;
  99109. /**
  99110. * constructor
  99111. * @param options Defines the options we want to customize the helper
  99112. * @param scene The scene to add the material to
  99113. */
  99114. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  99115. /**
  99116. * Updates the background according to the new options
  99117. * @param options
  99118. */
  99119. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  99120. /**
  99121. * Sets the primary color of all the available elements.
  99122. * @param color the main color to affect to the ground and the background
  99123. */
  99124. setMainColor(color: Color3): void;
  99125. /**
  99126. * Setup the image processing according to the specified options.
  99127. */
  99128. private _setupImageProcessing;
  99129. /**
  99130. * Setup the environment texture according to the specified options.
  99131. */
  99132. private _setupEnvironmentTexture;
  99133. /**
  99134. * Setup the background according to the specified options.
  99135. */
  99136. private _setupBackground;
  99137. /**
  99138. * Get the scene sizes according to the setup.
  99139. */
  99140. private _getSceneSize;
  99141. /**
  99142. * Setup the ground according to the specified options.
  99143. */
  99144. private _setupGround;
  99145. /**
  99146. * Setup the ground material according to the specified options.
  99147. */
  99148. private _setupGroundMaterial;
  99149. /**
  99150. * Setup the ground diffuse texture according to the specified options.
  99151. */
  99152. private _setupGroundDiffuseTexture;
  99153. /**
  99154. * Setup the ground mirror texture according to the specified options.
  99155. */
  99156. private _setupGroundMirrorTexture;
  99157. /**
  99158. * Setup the ground to receive the mirror texture.
  99159. */
  99160. private _setupMirrorInGroundMaterial;
  99161. /**
  99162. * Setup the skybox according to the specified options.
  99163. */
  99164. private _setupSkybox;
  99165. /**
  99166. * Setup the skybox material according to the specified options.
  99167. */
  99168. private _setupSkyboxMaterial;
  99169. /**
  99170. * Setup the skybox reflection texture according to the specified options.
  99171. */
  99172. private _setupSkyboxReflectionTexture;
  99173. private _errorHandler;
  99174. /**
  99175. * Dispose all the elements created by the Helper.
  99176. */
  99177. dispose(): void;
  99178. }
  99179. }
  99180. declare module BABYLON {
  99181. /**
  99182. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  99183. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  99184. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  99185. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  99186. */
  99187. export class PhotoDome extends TransformNode {
  99188. private _useDirectMapping;
  99189. /**
  99190. * The texture being displayed on the sphere
  99191. */
  99192. protected _photoTexture: Texture;
  99193. /**
  99194. * Gets or sets the texture being displayed on the sphere
  99195. */
  99196. photoTexture: Texture;
  99197. /**
  99198. * Observable raised when an error occured while loading the 360 image
  99199. */
  99200. onLoadErrorObservable: Observable<string>;
  99201. /**
  99202. * The skybox material
  99203. */
  99204. protected _material: BackgroundMaterial;
  99205. /**
  99206. * The surface used for the skybox
  99207. */
  99208. protected _mesh: Mesh;
  99209. /**
  99210. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  99211. * Also see the options.resolution property.
  99212. */
  99213. fovMultiplier: number;
  99214. /**
  99215. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  99216. * @param name Element's name, child elements will append suffixes for their own names.
  99217. * @param urlsOfPhoto defines the url of the photo to display
  99218. * @param options defines an object containing optional or exposed sub element properties
  99219. * @param onError defines a callback called when an error occured while loading the texture
  99220. */
  99221. constructor(name: string, urlOfPhoto: string, options: {
  99222. resolution?: number;
  99223. size?: number;
  99224. useDirectMapping?: boolean;
  99225. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  99226. /**
  99227. * Releases resources associated with this node.
  99228. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99229. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99230. */
  99231. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99232. }
  99233. }
  99234. declare module BABYLON {
  99235. /**
  99236. * Class used to host texture specific utilities
  99237. */
  99238. export class TextureTools {
  99239. /**
  99240. * Uses the GPU to create a copy texture rescaled at a given size
  99241. * @param texture Texture to copy from
  99242. * @param width defines the desired width
  99243. * @param height defines the desired height
  99244. * @param useBilinearMode defines if bilinear mode has to be used
  99245. * @return the generated texture
  99246. */
  99247. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  99248. /**
  99249. * Gets an environment BRDF texture for a given scene
  99250. * @param scene defines the hosting scene
  99251. * @returns the environment BRDF texture
  99252. */
  99253. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  99254. private static _environmentBRDFBase64Texture;
  99255. }
  99256. }
  99257. declare module BABYLON {
  99258. /**
  99259. * @hidden
  99260. */
  99261. export interface IMaterialClearCoatDefines {
  99262. CLEARCOAT: boolean;
  99263. CLEARCOAT_DEFAULTIOR: boolean;
  99264. CLEARCOAT_TEXTURE: boolean;
  99265. CLEARCOAT_TEXTUREDIRECTUV: number;
  99266. CLEARCOAT_BUMP: boolean;
  99267. CLEARCOAT_BUMPDIRECTUV: number;
  99268. CLEARCOAT_TINT: boolean;
  99269. CLEARCOAT_TINT_TEXTURE: boolean;
  99270. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  99271. /** @hidden */
  99272. _areTexturesDirty: boolean;
  99273. }
  99274. /**
  99275. * Define the code related to the clear coat parameters of the pbr material.
  99276. */
  99277. export class PBRClearCoatConfiguration {
  99278. /**
  99279. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  99280. * The default fits with a polyurethane material.
  99281. */
  99282. private static readonly _DefaultIndiceOfRefraction;
  99283. private _isEnabled;
  99284. /**
  99285. * Defines if the clear coat is enabled in the material.
  99286. */
  99287. isEnabled: boolean;
  99288. /**
  99289. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  99290. */
  99291. intensity: number;
  99292. /**
  99293. * Defines the clear coat layer roughness.
  99294. */
  99295. roughness: number;
  99296. private _indiceOfRefraction;
  99297. /**
  99298. * Defines the indice of refraction of the clear coat.
  99299. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  99300. * The default fits with a polyurethane material.
  99301. * Changing the default value is more performance intensive.
  99302. */
  99303. indiceOfRefraction: number;
  99304. private _texture;
  99305. /**
  99306. * Stores the clear coat values in a texture.
  99307. */
  99308. texture: Nullable<BaseTexture>;
  99309. private _bumpTexture;
  99310. /**
  99311. * Define the clear coat specific bump texture.
  99312. */
  99313. bumpTexture: Nullable<BaseTexture>;
  99314. private _isTintEnabled;
  99315. /**
  99316. * Defines if the clear coat tint is enabled in the material.
  99317. */
  99318. isTintEnabled: boolean;
  99319. /**
  99320. * Defines if the clear coat tint is enabled in the material.
  99321. * This is only use if tint is enabled
  99322. */
  99323. tintColor: Color3;
  99324. /**
  99325. * Defines if the distance at which the tint color should be found in the
  99326. * clear coat media.
  99327. * This is only use if tint is enabled
  99328. */
  99329. tintColorAtDistance: number;
  99330. /**
  99331. * Defines the clear coat layer thickness.
  99332. * This is only use if tint is enabled
  99333. */
  99334. tintThickness: number;
  99335. private _tintTexture;
  99336. /**
  99337. * Stores the clear tint values in a texture.
  99338. * rgb is tint
  99339. * a is a thickness factor
  99340. */
  99341. tintTexture: Nullable<BaseTexture>;
  99342. /** @hidden */
  99343. private _internalMarkAllSubMeshesAsTexturesDirty;
  99344. /** @hidden */
  99345. _markAllSubMeshesAsTexturesDirty(): void;
  99346. /**
  99347. * Instantiate a new istance of clear coat configuration.
  99348. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  99349. */
  99350. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  99351. /**
  99352. * Specifies that the submesh is ready to be used.
  99353. * @param defines the list of "defines" to update.
  99354. * @param scene defines the scene the material belongs to.
  99355. * @param engine defines the engine the material belongs to.
  99356. * @param disableBumpMap defines wether the material disables bump or not.
  99357. * @returns - boolean indicating that the submesh is ready or not.
  99358. */
  99359. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  99360. /**
  99361. * Checks to see if a texture is used in the material.
  99362. * @param defines the list of "defines" to update.
  99363. * @param scene defines the scene to the material belongs to.
  99364. */
  99365. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  99366. /**
  99367. * Binds the material data.
  99368. * @param uniformBuffer defines the Uniform buffer to fill in.
  99369. * @param scene defines the scene the material belongs to.
  99370. * @param engine defines the engine the material belongs to.
  99371. * @param disableBumpMap defines wether the material disables bump or not.
  99372. * @param isFrozen defines wether the material is frozen or not.
  99373. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  99374. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  99375. */
  99376. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  99377. /**
  99378. * Checks to see if a texture is used in the material.
  99379. * @param texture - Base texture to use.
  99380. * @returns - Boolean specifying if a texture is used in the material.
  99381. */
  99382. hasTexture(texture: BaseTexture): boolean;
  99383. /**
  99384. * Returns an array of the actively used textures.
  99385. * @param activeTextures Array of BaseTextures
  99386. */
  99387. getActiveTextures(activeTextures: BaseTexture[]): void;
  99388. /**
  99389. * Returns the animatable textures.
  99390. * @param animatables Array of animatable textures.
  99391. */
  99392. getAnimatables(animatables: IAnimatable[]): void;
  99393. /**
  99394. * Disposes the resources of the material.
  99395. * @param forceDisposeTextures - Forces the disposal of all textures.
  99396. */
  99397. dispose(forceDisposeTextures?: boolean): void;
  99398. /**
  99399. * Get the current class name of the texture useful for serialization or dynamic coding.
  99400. * @returns "PBRClearCoatConfiguration"
  99401. */
  99402. getClassName(): string;
  99403. /**
  99404. * Makes a duplicate of the current configuration into another one.
  99405. * @param clearCoatConfiguration define the config where to copy the info
  99406. */
  99407. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  99408. /**
  99409. * Serializes this clear coat configuration.
  99410. * @returns - An object with the serialized config.
  99411. */
  99412. serialize(): any;
  99413. /**
  99414. * Parses a Clear Coat Configuration from a serialized object.
  99415. * @param source - Serialized object.
  99416. */
  99417. parse(source: any): void;
  99418. /**
  99419. * Add fallbacks to the effect fallbacks list.
  99420. * @param defines defines the Base texture to use.
  99421. * @param fallbacks defines the current fallback list.
  99422. * @param currentRank defines the current fallback rank.
  99423. * @returns the new fallback rank.
  99424. */
  99425. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  99426. /**
  99427. * Add the required uniforms to the current list.
  99428. * @param uniforms defines the current uniform list.
  99429. */
  99430. static AddUniforms(uniforms: string[]): void;
  99431. /**
  99432. * Add the required samplers to the current list.
  99433. * @param samplers defines the current sampler list.
  99434. */
  99435. static AddSamplers(samplers: string[]): void;
  99436. /**
  99437. * Add the required uniforms to the current buffer.
  99438. * @param uniformBuffer defines the current uniform buffer.
  99439. */
  99440. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  99441. }
  99442. }
  99443. declare module BABYLON {
  99444. /**
  99445. * @hidden
  99446. */
  99447. export interface IMaterialAnisotropicDefines {
  99448. ANISOTROPIC: boolean;
  99449. MAINUV1: boolean;
  99450. _areMiscDirty: boolean;
  99451. _needUVs: boolean;
  99452. }
  99453. /**
  99454. * Define the code related to the anisotropic parameters of the pbr material.
  99455. */
  99456. export class PBRAnisotropicConfiguration {
  99457. private _isEnabled;
  99458. /**
  99459. * Defines if the anisotropy is enabled in the material.
  99460. */
  99461. isEnabled: boolean;
  99462. /**
  99463. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  99464. */
  99465. intensity: number;
  99466. /**
  99467. * Defines if the effect is along the tangents or bitangents.
  99468. * By default, the effect is "strectching" the highlights along the tangents.
  99469. */
  99470. followTangents: boolean;
  99471. /** @hidden */
  99472. private _internalMarkAllSubMeshesAsMiscDirty;
  99473. /** @hidden */
  99474. _markAllSubMeshesAsMiscDirty(): void;
  99475. /**
  99476. * Instantiate a new istance of clear coat configuration.
  99477. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  99478. */
  99479. constructor(markAllSubMeshesAsMiscDirty: () => void);
  99480. /**
  99481. * Checks to see if a texture is used in the material.
  99482. * @param defines the list of "defines" to update.
  99483. * @param mesh the mesh we are preparing the defines for.
  99484. */
  99485. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh): void;
  99486. /**
  99487. * Binds the material data.
  99488. * @param uniformBuffer defines the Uniform buffer to fill in.
  99489. * @param isFrozen defines wether the material is frozen or not.
  99490. */
  99491. bindForSubMesh(uniformBuffer: UniformBuffer, isFrozen: boolean): void;
  99492. /**
  99493. * Get the current class name of the texture useful for serialization or dynamic coding.
  99494. * @returns "PBRAnisotropicConfiguration"
  99495. */
  99496. getClassName(): string;
  99497. /**
  99498. * Makes a duplicate of the current configuration into another one.
  99499. * @param anisotropicConfiguration define the config where to copy the info
  99500. */
  99501. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  99502. /**
  99503. * Serializes this clear coat configuration.
  99504. * @returns - An object with the serialized config.
  99505. */
  99506. serialize(): any;
  99507. /**
  99508. * Parses a Clear Coat Configuration from a serialized object.
  99509. * @param source - Serialized object.
  99510. */
  99511. parse(source: any): void;
  99512. /**
  99513. * Add fallbacks to the effect fallbacks list.
  99514. * @param defines defines the Base texture to use.
  99515. * @param fallbacks defines the current fallback list.
  99516. * @param currentRank defines the current fallback rank.
  99517. * @returns the new fallback rank.
  99518. */
  99519. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  99520. /**
  99521. * Add the required uniforms to the current list.
  99522. * @param uniforms defines the current uniform list.
  99523. */
  99524. static AddUniforms(uniforms: string[]): void;
  99525. /**
  99526. * Add the required uniforms to the current buffer.
  99527. * @param uniformBuffer defines the current uniform buffer.
  99528. */
  99529. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  99530. }
  99531. }
  99532. declare module BABYLON {
  99533. /** @hidden */
  99534. export var pbrFragmentDeclaration: {
  99535. name: string;
  99536. shader: string;
  99537. };
  99538. }
  99539. declare module BABYLON {
  99540. /** @hidden */
  99541. export var pbrUboDeclaration: {
  99542. name: string;
  99543. shader: string;
  99544. };
  99545. }
  99546. declare module BABYLON {
  99547. /** @hidden */
  99548. export var pbrFunctions: {
  99549. name: string;
  99550. shader: string;
  99551. };
  99552. }
  99553. declare module BABYLON {
  99554. /** @hidden */
  99555. export var harmonicsFunctions: {
  99556. name: string;
  99557. shader: string;
  99558. };
  99559. }
  99560. declare module BABYLON {
  99561. /** @hidden */
  99562. export var pbrPreLightingFunctions: {
  99563. name: string;
  99564. shader: string;
  99565. };
  99566. }
  99567. declare module BABYLON {
  99568. /** @hidden */
  99569. export var pbrFalloffLightingFunctions: {
  99570. name: string;
  99571. shader: string;
  99572. };
  99573. }
  99574. declare module BABYLON {
  99575. /** @hidden */
  99576. export var pbrLightingFunctions: {
  99577. name: string;
  99578. shader: string;
  99579. };
  99580. }
  99581. declare module BABYLON {
  99582. /** @hidden */
  99583. export var pbrPixelShader: {
  99584. name: string;
  99585. shader: string;
  99586. };
  99587. }
  99588. declare module BABYLON {
  99589. /** @hidden */
  99590. export var pbrVertexDeclaration: {
  99591. name: string;
  99592. shader: string;
  99593. };
  99594. }
  99595. declare module BABYLON {
  99596. /** @hidden */
  99597. export var pbrVertexShader: {
  99598. name: string;
  99599. shader: string;
  99600. };
  99601. }
  99602. declare module BABYLON {
  99603. /**
  99604. * The Physically based material base class of BJS.
  99605. *
  99606. * This offers the main features of a standard PBR material.
  99607. * For more information, please refer to the documentation :
  99608. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  99609. */
  99610. export abstract class PBRBaseMaterial extends PushMaterial {
  99611. /**
  99612. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  99613. */
  99614. static readonly PBRMATERIAL_OPAQUE: number;
  99615. /**
  99616. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  99617. */
  99618. static readonly PBRMATERIAL_ALPHATEST: number;
  99619. /**
  99620. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  99621. */
  99622. static readonly PBRMATERIAL_ALPHABLEND: number;
  99623. /**
  99624. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  99625. * They are also discarded below the alpha cutoff threshold to improve performances.
  99626. */
  99627. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  99628. /**
  99629. * Defines the default value of how much AO map is occluding the analytical lights
  99630. * (point spot...).
  99631. */
  99632. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  99633. /**
  99634. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  99635. */
  99636. static readonly LIGHTFALLOFF_PHYSICAL: number;
  99637. /**
  99638. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  99639. * to enhance interoperability with other engines.
  99640. */
  99641. static readonly LIGHTFALLOFF_GLTF: number;
  99642. /**
  99643. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  99644. * to enhance interoperability with other materials.
  99645. */
  99646. static readonly LIGHTFALLOFF_STANDARD: number;
  99647. /**
  99648. * Intensity of the direct lights e.g. the four lights available in your scene.
  99649. * This impacts both the direct diffuse and specular highlights.
  99650. */
  99651. protected _directIntensity: number;
  99652. /**
  99653. * Intensity of the emissive part of the material.
  99654. * This helps controlling the emissive effect without modifying the emissive color.
  99655. */
  99656. protected _emissiveIntensity: number;
  99657. /**
  99658. * Intensity of the environment e.g. how much the environment will light the object
  99659. * either through harmonics for rough material or through the refelction for shiny ones.
  99660. */
  99661. protected _environmentIntensity: number;
  99662. /**
  99663. * This is a special control allowing the reduction of the specular highlights coming from the
  99664. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  99665. */
  99666. protected _specularIntensity: number;
  99667. /**
  99668. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  99669. */
  99670. private _lightingInfos;
  99671. /**
  99672. * Debug Control allowing disabling the bump map on this material.
  99673. */
  99674. protected _disableBumpMap: boolean;
  99675. /**
  99676. * AKA Diffuse Texture in standard nomenclature.
  99677. */
  99678. protected _albedoTexture: BaseTexture;
  99679. /**
  99680. * AKA Occlusion Texture in other nomenclature.
  99681. */
  99682. protected _ambientTexture: BaseTexture;
  99683. /**
  99684. * AKA Occlusion Texture Intensity in other nomenclature.
  99685. */
  99686. protected _ambientTextureStrength: number;
  99687. /**
  99688. * Defines how much the AO map is occluding the analytical lights (point spot...).
  99689. * 1 means it completely occludes it
  99690. * 0 mean it has no impact
  99691. */
  99692. protected _ambientTextureImpactOnAnalyticalLights: number;
  99693. /**
  99694. * Stores the alpha values in a texture.
  99695. */
  99696. protected _opacityTexture: BaseTexture;
  99697. /**
  99698. * Stores the reflection values in a texture.
  99699. */
  99700. protected _reflectionTexture: BaseTexture;
  99701. /**
  99702. * Stores the refraction values in a texture.
  99703. */
  99704. protected _refractionTexture: BaseTexture;
  99705. /**
  99706. * Stores the emissive values in a texture.
  99707. */
  99708. protected _emissiveTexture: BaseTexture;
  99709. /**
  99710. * AKA Specular texture in other nomenclature.
  99711. */
  99712. protected _reflectivityTexture: BaseTexture;
  99713. /**
  99714. * Used to switch from specular/glossiness to metallic/roughness workflow.
  99715. */
  99716. protected _metallicTexture: BaseTexture;
  99717. /**
  99718. * Specifies the metallic scalar of the metallic/roughness workflow.
  99719. * Can also be used to scale the metalness values of the metallic texture.
  99720. */
  99721. protected _metallic: Nullable<number>;
  99722. /**
  99723. * Specifies the roughness scalar of the metallic/roughness workflow.
  99724. * Can also be used to scale the roughness values of the metallic texture.
  99725. */
  99726. protected _roughness: Nullable<number>;
  99727. /**
  99728. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  99729. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  99730. */
  99731. protected _microSurfaceTexture: BaseTexture;
  99732. /**
  99733. * Stores surface normal data used to displace a mesh in a texture.
  99734. */
  99735. protected _bumpTexture: BaseTexture;
  99736. /**
  99737. * Stores the pre-calculated light information of a mesh in a texture.
  99738. */
  99739. protected _lightmapTexture: BaseTexture;
  99740. /**
  99741. * The color of a material in ambient lighting.
  99742. */
  99743. protected _ambientColor: Color3;
  99744. /**
  99745. * AKA Diffuse Color in other nomenclature.
  99746. */
  99747. protected _albedoColor: Color3;
  99748. /**
  99749. * AKA Specular Color in other nomenclature.
  99750. */
  99751. protected _reflectivityColor: Color3;
  99752. /**
  99753. * The color applied when light is reflected from a material.
  99754. */
  99755. protected _reflectionColor: Color3;
  99756. /**
  99757. * The color applied when light is emitted from a material.
  99758. */
  99759. protected _emissiveColor: Color3;
  99760. /**
  99761. * AKA Glossiness in other nomenclature.
  99762. */
  99763. protected _microSurface: number;
  99764. /**
  99765. * source material index of refraction (IOR)' / 'destination material IOR.
  99766. */
  99767. protected _indexOfRefraction: number;
  99768. /**
  99769. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  99770. */
  99771. protected _invertRefractionY: boolean;
  99772. /**
  99773. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  99774. * Materials half opaque for instance using refraction could benefit from this control.
  99775. */
  99776. protected _linkRefractionWithTransparency: boolean;
  99777. /**
  99778. * Specifies that the material will use the light map as a show map.
  99779. */
  99780. protected _useLightmapAsShadowmap: boolean;
  99781. /**
  99782. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  99783. * makes the reflect vector face the model (under horizon).
  99784. */
  99785. protected _useHorizonOcclusion: boolean;
  99786. /**
  99787. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  99788. * too much the area relying on ambient texture to define their ambient occlusion.
  99789. */
  99790. protected _useRadianceOcclusion: boolean;
  99791. /**
  99792. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  99793. */
  99794. protected _useAlphaFromAlbedoTexture: boolean;
  99795. /**
  99796. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  99797. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  99798. */
  99799. protected _useSpecularOverAlpha: boolean;
  99800. /**
  99801. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  99802. */
  99803. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  99804. /**
  99805. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  99806. */
  99807. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  99808. /**
  99809. * Specifies if the metallic texture contains the roughness information in its green channel.
  99810. */
  99811. protected _useRoughnessFromMetallicTextureGreen: boolean;
  99812. /**
  99813. * Specifies if the metallic texture contains the metallness information in its blue channel.
  99814. */
  99815. protected _useMetallnessFromMetallicTextureBlue: boolean;
  99816. /**
  99817. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  99818. */
  99819. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  99820. /**
  99821. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  99822. */
  99823. protected _useAmbientInGrayScale: boolean;
  99824. /**
  99825. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  99826. * The material will try to infer what glossiness each pixel should be.
  99827. */
  99828. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  99829. /**
  99830. * Defines the falloff type used in this material.
  99831. * It by default is Physical.
  99832. */
  99833. protected _lightFalloff: number;
  99834. /**
  99835. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  99836. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  99837. */
  99838. protected _useRadianceOverAlpha: boolean;
  99839. /**
  99840. * Allows using an object space normal map (instead of tangent space).
  99841. */
  99842. protected _useObjectSpaceNormalMap: boolean;
  99843. /**
  99844. * Allows using the bump map in parallax mode.
  99845. */
  99846. protected _useParallax: boolean;
  99847. /**
  99848. * Allows using the bump map in parallax occlusion mode.
  99849. */
  99850. protected _useParallaxOcclusion: boolean;
  99851. /**
  99852. * Controls the scale bias of the parallax mode.
  99853. */
  99854. protected _parallaxScaleBias: number;
  99855. /**
  99856. * If sets to true, disables all the lights affecting the material.
  99857. */
  99858. protected _disableLighting: boolean;
  99859. /**
  99860. * Number of Simultaneous lights allowed on the material.
  99861. */
  99862. protected _maxSimultaneousLights: number;
  99863. /**
  99864. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  99865. */
  99866. protected _invertNormalMapX: boolean;
  99867. /**
  99868. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  99869. */
  99870. protected _invertNormalMapY: boolean;
  99871. /**
  99872. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  99873. */
  99874. protected _twoSidedLighting: boolean;
  99875. /**
  99876. * Defines the alpha limits in alpha test mode.
  99877. */
  99878. protected _alphaCutOff: number;
  99879. /**
  99880. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  99881. */
  99882. protected _forceAlphaTest: boolean;
  99883. /**
  99884. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  99885. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  99886. */
  99887. protected _useAlphaFresnel: boolean;
  99888. /**
  99889. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  99890. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  99891. */
  99892. protected _useLinearAlphaFresnel: boolean;
  99893. /**
  99894. * The transparency mode of the material.
  99895. */
  99896. protected _transparencyMode: Nullable<number>;
  99897. /**
  99898. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  99899. * from cos thetav and roughness:
  99900. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  99901. */
  99902. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  99903. /**
  99904. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  99905. */
  99906. protected _forceIrradianceInFragment: boolean;
  99907. /**
  99908. * Force normal to face away from face.
  99909. */
  99910. protected _forceNormalForward: boolean;
  99911. /**
  99912. * Enables specular anti aliasing in the PBR shader.
  99913. * It will both interacts on the Geometry for analytical and IBL lighting.
  99914. * It also prefilter the roughness map based on the bump values.
  99915. */
  99916. protected _enableSpecularAntiAliasing: boolean;
  99917. /**
  99918. * Default configuration related to image processing available in the PBR Material.
  99919. */
  99920. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99921. /**
  99922. * Keep track of the image processing observer to allow dispose and replace.
  99923. */
  99924. private _imageProcessingObserver;
  99925. /**
  99926. * Attaches a new image processing configuration to the PBR Material.
  99927. * @param configuration
  99928. */
  99929. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  99930. /**
  99931. * Stores the available render targets.
  99932. */
  99933. private _renderTargets;
  99934. /**
  99935. * Sets the global ambient color for the material used in lighting calculations.
  99936. */
  99937. private _globalAmbientColor;
  99938. /**
  99939. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  99940. */
  99941. private _useLogarithmicDepth;
  99942. /**
  99943. * If set to true, no lighting calculations will be applied.
  99944. */
  99945. private _unlit;
  99946. /**
  99947. * Defines the clear coat layer parameters for the material.
  99948. */
  99949. readonly clearCoat: PBRClearCoatConfiguration;
  99950. /**
  99951. * Defines the anisotropic parameters for the material.
  99952. */
  99953. readonly anisotropy: PBRAnisotropicConfiguration;
  99954. /**
  99955. * Instantiates a new PBRMaterial instance.
  99956. *
  99957. * @param name The material name
  99958. * @param scene The scene the material will be use in.
  99959. */
  99960. constructor(name: string, scene: Scene);
  99961. /**
  99962. * Gets a boolean indicating that current material needs to register RTT
  99963. */
  99964. readonly hasRenderTargetTextures: boolean;
  99965. /**
  99966. * Gets the name of the material class.
  99967. */
  99968. getClassName(): string;
  99969. /**
  99970. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  99971. */
  99972. /**
  99973. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  99974. */
  99975. useLogarithmicDepth: boolean;
  99976. /**
  99977. * Gets the current transparency mode.
  99978. */
  99979. /**
  99980. * Sets the transparency mode of the material.
  99981. *
  99982. * | Value | Type | Description |
  99983. * | ----- | ----------------------------------- | ----------- |
  99984. * | 0 | OPAQUE | |
  99985. * | 1 | ALPHATEST | |
  99986. * | 2 | ALPHABLEND | |
  99987. * | 3 | ALPHATESTANDBLEND | |
  99988. *
  99989. */
  99990. transparencyMode: Nullable<number>;
  99991. /**
  99992. * Returns true if alpha blending should be disabled.
  99993. */
  99994. private readonly _disableAlphaBlending;
  99995. /**
  99996. * Specifies whether or not this material should be rendered in alpha blend mode.
  99997. */
  99998. needAlphaBlending(): boolean;
  99999. /**
  100000. * Specifies if the mesh will require alpha blending.
  100001. * @param mesh - BJS mesh.
  100002. */
  100003. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  100004. /**
  100005. * Specifies whether or not this material should be rendered in alpha test mode.
  100006. */
  100007. needAlphaTesting(): boolean;
  100008. /**
  100009. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  100010. */
  100011. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  100012. /**
  100013. * Gets the texture used for the alpha test.
  100014. */
  100015. getAlphaTestTexture(): BaseTexture;
  100016. /**
  100017. * Specifies that the submesh is ready to be used.
  100018. * @param mesh - BJS mesh.
  100019. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  100020. * @param useInstances - Specifies that instances should be used.
  100021. * @returns - boolean indicating that the submesh is ready or not.
  100022. */
  100023. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  100024. /**
  100025. * Specifies if the material uses metallic roughness workflow.
  100026. * @returns boolean specifiying if the material uses metallic roughness workflow.
  100027. */
  100028. isMetallicWorkflow(): boolean;
  100029. private _prepareEffect;
  100030. private _prepareDefines;
  100031. /**
  100032. * Force shader compilation
  100033. */
  100034. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  100035. clipPlane: boolean;
  100036. }>): void;
  100037. /**
  100038. * Initializes the uniform buffer layout for the shader.
  100039. */
  100040. buildUniformLayout(): void;
  100041. /**
  100042. * Unbinds the textures.
  100043. */
  100044. unbind(): void;
  100045. /**
  100046. * Binds the submesh data.
  100047. * @param world - The world matrix.
  100048. * @param mesh - The BJS mesh.
  100049. * @param subMesh - A submesh of the BJS mesh.
  100050. */
  100051. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  100052. /**
  100053. * Returns the animatable textures.
  100054. * @returns - Array of animatable textures.
  100055. */
  100056. getAnimatables(): IAnimatable[];
  100057. /**
  100058. * Returns the texture used for reflections.
  100059. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  100060. */
  100061. private _getReflectionTexture;
  100062. /**
  100063. * Returns the texture used for refraction or null if none is used.
  100064. * @returns - Refection texture if present. If no refraction texture and refraction
  100065. * is linked with transparency, returns environment texture. Otherwise, returns null.
  100066. */
  100067. private _getRefractionTexture;
  100068. /**
  100069. * Returns an array of the actively used textures.
  100070. * @returns - Array of BaseTextures
  100071. */
  100072. getActiveTextures(): BaseTexture[];
  100073. /**
  100074. * Checks to see if a texture is used in the material.
  100075. * @param texture - Base texture to use.
  100076. * @returns - Boolean specifying if a texture is used in the material.
  100077. */
  100078. hasTexture(texture: BaseTexture): boolean;
  100079. /**
  100080. * Disposes the resources of the material.
  100081. * @param forceDisposeEffect - Forces the disposal of effects.
  100082. * @param forceDisposeTextures - Forces the disposal of all textures.
  100083. */
  100084. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  100085. }
  100086. }
  100087. declare module BABYLON {
  100088. /**
  100089. * The Physically based material of BJS.
  100090. *
  100091. * This offers the main features of a standard PBR material.
  100092. * For more information, please refer to the documentation :
  100093. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  100094. */
  100095. export class PBRMaterial extends PBRBaseMaterial {
  100096. /**
  100097. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  100098. */
  100099. static readonly PBRMATERIAL_OPAQUE: number;
  100100. /**
  100101. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  100102. */
  100103. static readonly PBRMATERIAL_ALPHATEST: number;
  100104. /**
  100105. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  100106. */
  100107. static readonly PBRMATERIAL_ALPHABLEND: number;
  100108. /**
  100109. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  100110. * They are also discarded below the alpha cutoff threshold to improve performances.
  100111. */
  100112. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  100113. /**
  100114. * Defines the default value of how much AO map is occluding the analytical lights
  100115. * (point spot...).
  100116. */
  100117. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  100118. /**
  100119. * Intensity of the direct lights e.g. the four lights available in your scene.
  100120. * This impacts both the direct diffuse and specular highlights.
  100121. */
  100122. directIntensity: number;
  100123. /**
  100124. * Intensity of the emissive part of the material.
  100125. * This helps controlling the emissive effect without modifying the emissive color.
  100126. */
  100127. emissiveIntensity: number;
  100128. /**
  100129. * Intensity of the environment e.g. how much the environment will light the object
  100130. * either through harmonics for rough material or through the refelction for shiny ones.
  100131. */
  100132. environmentIntensity: number;
  100133. /**
  100134. * This is a special control allowing the reduction of the specular highlights coming from the
  100135. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  100136. */
  100137. specularIntensity: number;
  100138. /**
  100139. * Debug Control allowing disabling the bump map on this material.
  100140. */
  100141. disableBumpMap: boolean;
  100142. /**
  100143. * AKA Diffuse Texture in standard nomenclature.
  100144. */
  100145. albedoTexture: BaseTexture;
  100146. /**
  100147. * AKA Occlusion Texture in other nomenclature.
  100148. */
  100149. ambientTexture: BaseTexture;
  100150. /**
  100151. * AKA Occlusion Texture Intensity in other nomenclature.
  100152. */
  100153. ambientTextureStrength: number;
  100154. /**
  100155. * Defines how much the AO map is occluding the analytical lights (point spot...).
  100156. * 1 means it completely occludes it
  100157. * 0 mean it has no impact
  100158. */
  100159. ambientTextureImpactOnAnalyticalLights: number;
  100160. /**
  100161. * Stores the alpha values in a texture.
  100162. */
  100163. opacityTexture: BaseTexture;
  100164. /**
  100165. * Stores the reflection values in a texture.
  100166. */
  100167. reflectionTexture: Nullable<BaseTexture>;
  100168. /**
  100169. * Stores the emissive values in a texture.
  100170. */
  100171. emissiveTexture: BaseTexture;
  100172. /**
  100173. * AKA Specular texture in other nomenclature.
  100174. */
  100175. reflectivityTexture: BaseTexture;
  100176. /**
  100177. * Used to switch from specular/glossiness to metallic/roughness workflow.
  100178. */
  100179. metallicTexture: BaseTexture;
  100180. /**
  100181. * Specifies the metallic scalar of the metallic/roughness workflow.
  100182. * Can also be used to scale the metalness values of the metallic texture.
  100183. */
  100184. metallic: Nullable<number>;
  100185. /**
  100186. * Specifies the roughness scalar of the metallic/roughness workflow.
  100187. * Can also be used to scale the roughness values of the metallic texture.
  100188. */
  100189. roughness: Nullable<number>;
  100190. /**
  100191. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  100192. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  100193. */
  100194. microSurfaceTexture: BaseTexture;
  100195. /**
  100196. * Stores surface normal data used to displace a mesh in a texture.
  100197. */
  100198. bumpTexture: BaseTexture;
  100199. /**
  100200. * Stores the pre-calculated light information of a mesh in a texture.
  100201. */
  100202. lightmapTexture: BaseTexture;
  100203. /**
  100204. * Stores the refracted light information in a texture.
  100205. */
  100206. refractionTexture: BaseTexture;
  100207. /**
  100208. * The color of a material in ambient lighting.
  100209. */
  100210. ambientColor: Color3;
  100211. /**
  100212. * AKA Diffuse Color in other nomenclature.
  100213. */
  100214. albedoColor: Color3;
  100215. /**
  100216. * AKA Specular Color in other nomenclature.
  100217. */
  100218. reflectivityColor: Color3;
  100219. /**
  100220. * The color reflected from the material.
  100221. */
  100222. reflectionColor: Color3;
  100223. /**
  100224. * The color emitted from the material.
  100225. */
  100226. emissiveColor: Color3;
  100227. /**
  100228. * AKA Glossiness in other nomenclature.
  100229. */
  100230. microSurface: number;
  100231. /**
  100232. * source material index of refraction (IOR)' / 'destination material IOR.
  100233. */
  100234. indexOfRefraction: number;
  100235. /**
  100236. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  100237. */
  100238. invertRefractionY: boolean;
  100239. /**
  100240. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  100241. * Materials half opaque for instance using refraction could benefit from this control.
  100242. */
  100243. linkRefractionWithTransparency: boolean;
  100244. /**
  100245. * If true, the light map contains occlusion information instead of lighting info.
  100246. */
  100247. useLightmapAsShadowmap: boolean;
  100248. /**
  100249. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  100250. */
  100251. useAlphaFromAlbedoTexture: boolean;
  100252. /**
  100253. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  100254. */
  100255. forceAlphaTest: boolean;
  100256. /**
  100257. * Defines the alpha limits in alpha test mode.
  100258. */
  100259. alphaCutOff: number;
  100260. /**
  100261. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  100262. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  100263. */
  100264. useSpecularOverAlpha: boolean;
  100265. /**
  100266. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  100267. */
  100268. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  100269. /**
  100270. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  100271. */
  100272. useRoughnessFromMetallicTextureAlpha: boolean;
  100273. /**
  100274. * Specifies if the metallic texture contains the roughness information in its green channel.
  100275. */
  100276. useRoughnessFromMetallicTextureGreen: boolean;
  100277. /**
  100278. * Specifies if the metallic texture contains the metallness information in its blue channel.
  100279. */
  100280. useMetallnessFromMetallicTextureBlue: boolean;
  100281. /**
  100282. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  100283. */
  100284. useAmbientOcclusionFromMetallicTextureRed: boolean;
  100285. /**
  100286. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  100287. */
  100288. useAmbientInGrayScale: boolean;
  100289. /**
  100290. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  100291. * The material will try to infer what glossiness each pixel should be.
  100292. */
  100293. useAutoMicroSurfaceFromReflectivityMap: boolean;
  100294. /**
  100295. * BJS is using an harcoded light falloff based on a manually sets up range.
  100296. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  100297. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  100298. */
  100299. /**
  100300. * BJS is using an harcoded light falloff based on a manually sets up range.
  100301. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  100302. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  100303. */
  100304. usePhysicalLightFalloff: boolean;
  100305. /**
  100306. * In order to support the falloff compatibility with gltf, a special mode has been added
  100307. * to reproduce the gltf light falloff.
  100308. */
  100309. /**
  100310. * In order to support the falloff compatibility with gltf, a special mode has been added
  100311. * to reproduce the gltf light falloff.
  100312. */
  100313. useGLTFLightFalloff: boolean;
  100314. /**
  100315. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  100316. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  100317. */
  100318. useRadianceOverAlpha: boolean;
  100319. /**
  100320. * Allows using an object space normal map (instead of tangent space).
  100321. */
  100322. useObjectSpaceNormalMap: boolean;
  100323. /**
  100324. * Allows using the bump map in parallax mode.
  100325. */
  100326. useParallax: boolean;
  100327. /**
  100328. * Allows using the bump map in parallax occlusion mode.
  100329. */
  100330. useParallaxOcclusion: boolean;
  100331. /**
  100332. * Controls the scale bias of the parallax mode.
  100333. */
  100334. parallaxScaleBias: number;
  100335. /**
  100336. * If sets to true, disables all the lights affecting the material.
  100337. */
  100338. disableLighting: boolean;
  100339. /**
  100340. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  100341. */
  100342. forceIrradianceInFragment: boolean;
  100343. /**
  100344. * Number of Simultaneous lights allowed on the material.
  100345. */
  100346. maxSimultaneousLights: number;
  100347. /**
  100348. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  100349. */
  100350. invertNormalMapX: boolean;
  100351. /**
  100352. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  100353. */
  100354. invertNormalMapY: boolean;
  100355. /**
  100356. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  100357. */
  100358. twoSidedLighting: boolean;
  100359. /**
  100360. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  100361. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  100362. */
  100363. useAlphaFresnel: boolean;
  100364. /**
  100365. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  100366. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  100367. */
  100368. useLinearAlphaFresnel: boolean;
  100369. /**
  100370. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  100371. * And/Or occlude the blended part.
  100372. */
  100373. environmentBRDFTexture: Nullable<BaseTexture>;
  100374. /**
  100375. * Force normal to face away from face.
  100376. */
  100377. forceNormalForward: boolean;
  100378. /**
  100379. * Enables specular anti aliasing in the PBR shader.
  100380. * It will both interacts on the Geometry for analytical and IBL lighting.
  100381. * It also prefilter the roughness map based on the bump values.
  100382. */
  100383. enableSpecularAntiAliasing: boolean;
  100384. /**
  100385. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  100386. * makes the reflect vector face the model (under horizon).
  100387. */
  100388. useHorizonOcclusion: boolean;
  100389. /**
  100390. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  100391. * too much the area relying on ambient texture to define their ambient occlusion.
  100392. */
  100393. useRadianceOcclusion: boolean;
  100394. /**
  100395. * If set to true, no lighting calculations will be applied.
  100396. */
  100397. unlit: boolean;
  100398. /**
  100399. * Gets the image processing configuration used either in this material.
  100400. */
  100401. /**
  100402. * Sets the Default image processing configuration used either in the this material.
  100403. *
  100404. * If sets to null, the scene one is in use.
  100405. */
  100406. imageProcessingConfiguration: ImageProcessingConfiguration;
  100407. /**
  100408. * Gets wether the color curves effect is enabled.
  100409. */
  100410. /**
  100411. * Sets wether the color curves effect is enabled.
  100412. */
  100413. cameraColorCurvesEnabled: boolean;
  100414. /**
  100415. * Gets wether the color grading effect is enabled.
  100416. */
  100417. /**
  100418. * Gets wether the color grading effect is enabled.
  100419. */
  100420. cameraColorGradingEnabled: boolean;
  100421. /**
  100422. * Gets wether tonemapping is enabled or not.
  100423. */
  100424. /**
  100425. * Sets wether tonemapping is enabled or not
  100426. */
  100427. cameraToneMappingEnabled: boolean;
  100428. /**
  100429. * The camera exposure used on this material.
  100430. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  100431. * This corresponds to a photographic exposure.
  100432. */
  100433. /**
  100434. * The camera exposure used on this material.
  100435. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  100436. * This corresponds to a photographic exposure.
  100437. */
  100438. cameraExposure: number;
  100439. /**
  100440. * Gets The camera contrast used on this material.
  100441. */
  100442. /**
  100443. * Sets The camera contrast used on this material.
  100444. */
  100445. cameraContrast: number;
  100446. /**
  100447. * Gets the Color Grading 2D Lookup Texture.
  100448. */
  100449. /**
  100450. * Sets the Color Grading 2D Lookup Texture.
  100451. */
  100452. cameraColorGradingTexture: Nullable<BaseTexture>;
  100453. /**
  100454. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  100455. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  100456. * 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;
  100457. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  100458. */
  100459. /**
  100460. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  100461. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  100462. * 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;
  100463. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  100464. */
  100465. cameraColorCurves: Nullable<ColorCurves>;
  100466. /**
  100467. * Instantiates a new PBRMaterial instance.
  100468. *
  100469. * @param name The material name
  100470. * @param scene The scene the material will be use in.
  100471. */
  100472. constructor(name: string, scene: Scene);
  100473. /**
  100474. * Returns the name of this material class.
  100475. */
  100476. getClassName(): string;
  100477. /**
  100478. * Makes a duplicate of the current material.
  100479. * @param name - name to use for the new material.
  100480. */
  100481. clone(name: string): PBRMaterial;
  100482. /**
  100483. * Serializes this PBR Material.
  100484. * @returns - An object with the serialized material.
  100485. */
  100486. serialize(): any;
  100487. /**
  100488. * Parses a PBR Material from a serialized object.
  100489. * @param source - Serialized object.
  100490. * @param scene - BJS scene instance.
  100491. * @param rootUrl - url for the scene object
  100492. * @returns - PBRMaterial
  100493. */
  100494. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  100495. }
  100496. }
  100497. declare module BABYLON {
  100498. /** @hidden */
  100499. export var _forceSceneHelpersToBundle: boolean;
  100500. interface Scene {
  100501. /**
  100502. * Creates a default light for the scene.
  100503. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  100504. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  100505. */
  100506. createDefaultLight(replace?: boolean): void;
  100507. /**
  100508. * Creates a default camera for the scene.
  100509. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  100510. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  100511. * @param replace has default false, when true replaces the active camera in the scene
  100512. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  100513. */
  100514. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  100515. /**
  100516. * Creates a default camera and a default light.
  100517. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  100518. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  100519. * @param replace has the default false, when true replaces the active camera/light in the scene
  100520. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  100521. */
  100522. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  100523. /**
  100524. * Creates a new sky box
  100525. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  100526. * @param environmentTexture defines the texture to use as environment texture
  100527. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  100528. * @param scale defines the overall scale of the skybox
  100529. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  100530. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  100531. * @returns a new mesh holding the sky box
  100532. */
  100533. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  100534. /**
  100535. * Creates a new environment
  100536. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  100537. * @param options defines the options you can use to configure the environment
  100538. * @returns the new EnvironmentHelper
  100539. */
  100540. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  100541. /**
  100542. * Creates a new VREXperienceHelper
  100543. * @see http://doc.babylonjs.com/how_to/webvr_helper
  100544. * @param webVROptions defines the options used to create the new VREXperienceHelper
  100545. * @returns a new VREXperienceHelper
  100546. */
  100547. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  100548. /**
  100549. * Creates a new XREXperienceHelper
  100550. * @see http://doc.babylonjs.com/how_to/webxr
  100551. * @returns a promise for a new XREXperienceHelper
  100552. */
  100553. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  100554. }
  100555. }
  100556. declare module BABYLON {
  100557. /**
  100558. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  100559. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  100560. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  100561. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  100562. */
  100563. export class VideoDome extends TransformNode {
  100564. private _useDirectMapping;
  100565. /**
  100566. * The video texture being displayed on the sphere
  100567. */
  100568. protected _videoTexture: VideoTexture;
  100569. /**
  100570. * Gets the video texture being displayed on the sphere
  100571. */
  100572. readonly videoTexture: VideoTexture;
  100573. /**
  100574. * The skybox material
  100575. */
  100576. protected _material: BackgroundMaterial;
  100577. /**
  100578. * The surface used for the skybox
  100579. */
  100580. protected _mesh: Mesh;
  100581. /**
  100582. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  100583. * Also see the options.resolution property.
  100584. */
  100585. fovMultiplier: number;
  100586. /**
  100587. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  100588. * @param name Element's name, child elements will append suffixes for their own names.
  100589. * @param urlsOrVideo defines the url(s) or the video element to use
  100590. * @param options An object containing optional or exposed sub element properties
  100591. */
  100592. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  100593. resolution?: number;
  100594. clickToPlay?: boolean;
  100595. autoPlay?: boolean;
  100596. loop?: boolean;
  100597. size?: number;
  100598. poster?: string;
  100599. useDirectMapping?: boolean;
  100600. }, scene: Scene);
  100601. /**
  100602. * Releases resources associated with this node.
  100603. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  100604. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  100605. */
  100606. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  100607. }
  100608. }
  100609. declare module BABYLON {
  100610. /**
  100611. * This class can be used to get instrumentation data from a Babylon engine
  100612. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  100613. */
  100614. export class EngineInstrumentation implements IDisposable {
  100615. /**
  100616. * Define the instrumented engine.
  100617. */
  100618. engine: Engine;
  100619. private _captureGPUFrameTime;
  100620. private _gpuFrameTimeToken;
  100621. private _gpuFrameTime;
  100622. private _captureShaderCompilationTime;
  100623. private _shaderCompilationTime;
  100624. private _onBeginFrameObserver;
  100625. private _onEndFrameObserver;
  100626. private _onBeforeShaderCompilationObserver;
  100627. private _onAfterShaderCompilationObserver;
  100628. /**
  100629. * Gets the perf counter used for GPU frame time
  100630. */
  100631. readonly gpuFrameTimeCounter: PerfCounter;
  100632. /**
  100633. * Gets the GPU frame time capture status
  100634. */
  100635. /**
  100636. * Enable or disable the GPU frame time capture
  100637. */
  100638. captureGPUFrameTime: boolean;
  100639. /**
  100640. * Gets the perf counter used for shader compilation time
  100641. */
  100642. readonly shaderCompilationTimeCounter: PerfCounter;
  100643. /**
  100644. * Gets the shader compilation time capture status
  100645. */
  100646. /**
  100647. * Enable or disable the shader compilation time capture
  100648. */
  100649. captureShaderCompilationTime: boolean;
  100650. /**
  100651. * Instantiates a new engine instrumentation.
  100652. * This class can be used to get instrumentation data from a Babylon engine
  100653. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  100654. * @param engine Defines the engine to instrument
  100655. */
  100656. constructor(
  100657. /**
  100658. * Define the instrumented engine.
  100659. */
  100660. engine: Engine);
  100661. /**
  100662. * Dispose and release associated resources.
  100663. */
  100664. dispose(): void;
  100665. }
  100666. }
  100667. declare module BABYLON {
  100668. /**
  100669. * This class can be used to get instrumentation data from a Babylon engine
  100670. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  100671. */
  100672. export class SceneInstrumentation implements IDisposable {
  100673. /**
  100674. * Defines the scene to instrument
  100675. */
  100676. scene: Scene;
  100677. private _captureActiveMeshesEvaluationTime;
  100678. private _activeMeshesEvaluationTime;
  100679. private _captureRenderTargetsRenderTime;
  100680. private _renderTargetsRenderTime;
  100681. private _captureFrameTime;
  100682. private _frameTime;
  100683. private _captureRenderTime;
  100684. private _renderTime;
  100685. private _captureInterFrameTime;
  100686. private _interFrameTime;
  100687. private _captureParticlesRenderTime;
  100688. private _particlesRenderTime;
  100689. private _captureSpritesRenderTime;
  100690. private _spritesRenderTime;
  100691. private _capturePhysicsTime;
  100692. private _physicsTime;
  100693. private _captureAnimationsTime;
  100694. private _animationsTime;
  100695. private _captureCameraRenderTime;
  100696. private _cameraRenderTime;
  100697. private _onBeforeActiveMeshesEvaluationObserver;
  100698. private _onAfterActiveMeshesEvaluationObserver;
  100699. private _onBeforeRenderTargetsRenderObserver;
  100700. private _onAfterRenderTargetsRenderObserver;
  100701. private _onAfterRenderObserver;
  100702. private _onBeforeDrawPhaseObserver;
  100703. private _onAfterDrawPhaseObserver;
  100704. private _onBeforeAnimationsObserver;
  100705. private _onBeforeParticlesRenderingObserver;
  100706. private _onAfterParticlesRenderingObserver;
  100707. private _onBeforeSpritesRenderingObserver;
  100708. private _onAfterSpritesRenderingObserver;
  100709. private _onBeforePhysicsObserver;
  100710. private _onAfterPhysicsObserver;
  100711. private _onAfterAnimationsObserver;
  100712. private _onBeforeCameraRenderObserver;
  100713. private _onAfterCameraRenderObserver;
  100714. /**
  100715. * Gets the perf counter used for active meshes evaluation time
  100716. */
  100717. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  100718. /**
  100719. * Gets the active meshes evaluation time capture status
  100720. */
  100721. /**
  100722. * Enable or disable the active meshes evaluation time capture
  100723. */
  100724. captureActiveMeshesEvaluationTime: boolean;
  100725. /**
  100726. * Gets the perf counter used for render targets render time
  100727. */
  100728. readonly renderTargetsRenderTimeCounter: PerfCounter;
  100729. /**
  100730. * Gets the render targets render time capture status
  100731. */
  100732. /**
  100733. * Enable or disable the render targets render time capture
  100734. */
  100735. captureRenderTargetsRenderTime: boolean;
  100736. /**
  100737. * Gets the perf counter used for particles render time
  100738. */
  100739. readonly particlesRenderTimeCounter: PerfCounter;
  100740. /**
  100741. * Gets the particles render time capture status
  100742. */
  100743. /**
  100744. * Enable or disable the particles render time capture
  100745. */
  100746. captureParticlesRenderTime: boolean;
  100747. /**
  100748. * Gets the perf counter used for sprites render time
  100749. */
  100750. readonly spritesRenderTimeCounter: PerfCounter;
  100751. /**
  100752. * Gets the sprites render time capture status
  100753. */
  100754. /**
  100755. * Enable or disable the sprites render time capture
  100756. */
  100757. captureSpritesRenderTime: boolean;
  100758. /**
  100759. * Gets the perf counter used for physics time
  100760. */
  100761. readonly physicsTimeCounter: PerfCounter;
  100762. /**
  100763. * Gets the physics time capture status
  100764. */
  100765. /**
  100766. * Enable or disable the physics time capture
  100767. */
  100768. capturePhysicsTime: boolean;
  100769. /**
  100770. * Gets the perf counter used for animations time
  100771. */
  100772. readonly animationsTimeCounter: PerfCounter;
  100773. /**
  100774. * Gets the animations time capture status
  100775. */
  100776. /**
  100777. * Enable or disable the animations time capture
  100778. */
  100779. captureAnimationsTime: boolean;
  100780. /**
  100781. * Gets the perf counter used for frame time capture
  100782. */
  100783. readonly frameTimeCounter: PerfCounter;
  100784. /**
  100785. * Gets the frame time capture status
  100786. */
  100787. /**
  100788. * Enable or disable the frame time capture
  100789. */
  100790. captureFrameTime: boolean;
  100791. /**
  100792. * Gets the perf counter used for inter-frames time capture
  100793. */
  100794. readonly interFrameTimeCounter: PerfCounter;
  100795. /**
  100796. * Gets the inter-frames time capture status
  100797. */
  100798. /**
  100799. * Enable or disable the inter-frames time capture
  100800. */
  100801. captureInterFrameTime: boolean;
  100802. /**
  100803. * Gets the perf counter used for render time capture
  100804. */
  100805. readonly renderTimeCounter: PerfCounter;
  100806. /**
  100807. * Gets the render time capture status
  100808. */
  100809. /**
  100810. * Enable or disable the render time capture
  100811. */
  100812. captureRenderTime: boolean;
  100813. /**
  100814. * Gets the perf counter used for camera render time capture
  100815. */
  100816. readonly cameraRenderTimeCounter: PerfCounter;
  100817. /**
  100818. * Gets the camera render time capture status
  100819. */
  100820. /**
  100821. * Enable or disable the camera render time capture
  100822. */
  100823. captureCameraRenderTime: boolean;
  100824. /**
  100825. * Gets the perf counter used for draw calls
  100826. */
  100827. readonly drawCallsCounter: PerfCounter;
  100828. /**
  100829. * Gets the perf counter used for texture collisions
  100830. */
  100831. readonly textureCollisionsCounter: PerfCounter;
  100832. /**
  100833. * Instantiates a new scene instrumentation.
  100834. * This class can be used to get instrumentation data from a Babylon engine
  100835. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  100836. * @param scene Defines the scene to instrument
  100837. */
  100838. constructor(
  100839. /**
  100840. * Defines the scene to instrument
  100841. */
  100842. scene: Scene);
  100843. /**
  100844. * Dispose and release associated resources.
  100845. */
  100846. dispose(): void;
  100847. }
  100848. }
  100849. declare module BABYLON {
  100850. /** @hidden */
  100851. export var glowMapGenerationPixelShader: {
  100852. name: string;
  100853. shader: string;
  100854. };
  100855. }
  100856. declare module BABYLON {
  100857. /** @hidden */
  100858. export var glowMapGenerationVertexShader: {
  100859. name: string;
  100860. shader: string;
  100861. };
  100862. }
  100863. declare module BABYLON {
  100864. /**
  100865. * Effect layer options. This helps customizing the behaviour
  100866. * of the effect layer.
  100867. */
  100868. export interface IEffectLayerOptions {
  100869. /**
  100870. * Multiplication factor apply to the canvas size to compute the render target size
  100871. * used to generated the objects (the smaller the faster).
  100872. */
  100873. mainTextureRatio: number;
  100874. /**
  100875. * Enforces a fixed size texture to ensure effect stability across devices.
  100876. */
  100877. mainTextureFixedSize?: number;
  100878. /**
  100879. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  100880. */
  100881. alphaBlendingMode: number;
  100882. /**
  100883. * The camera attached to the layer.
  100884. */
  100885. camera: Nullable<Camera>;
  100886. /**
  100887. * The rendering group to draw the layer in.
  100888. */
  100889. renderingGroupId: number;
  100890. }
  100891. /**
  100892. * The effect layer Helps adding post process effect blended with the main pass.
  100893. *
  100894. * This can be for instance use to generate glow or higlight effects on the scene.
  100895. *
  100896. * The effect layer class can not be used directly and is intented to inherited from to be
  100897. * customized per effects.
  100898. */
  100899. export abstract class EffectLayer {
  100900. private _vertexBuffers;
  100901. private _indexBuffer;
  100902. private _cachedDefines;
  100903. private _effectLayerMapGenerationEffect;
  100904. private _effectLayerOptions;
  100905. private _mergeEffect;
  100906. protected _scene: Scene;
  100907. protected _engine: Engine;
  100908. protected _maxSize: number;
  100909. protected _mainTextureDesiredSize: ISize;
  100910. protected _mainTexture: RenderTargetTexture;
  100911. protected _shouldRender: boolean;
  100912. protected _postProcesses: PostProcess[];
  100913. protected _textures: BaseTexture[];
  100914. protected _emissiveTextureAndColor: {
  100915. texture: Nullable<BaseTexture>;
  100916. color: Color4;
  100917. };
  100918. /**
  100919. * The name of the layer
  100920. */
  100921. name: string;
  100922. /**
  100923. * The clear color of the texture used to generate the glow map.
  100924. */
  100925. neutralColor: Color4;
  100926. /**
  100927. * Specifies wether the highlight layer is enabled or not.
  100928. */
  100929. isEnabled: boolean;
  100930. /**
  100931. * Gets the camera attached to the layer.
  100932. */
  100933. readonly camera: Nullable<Camera>;
  100934. /**
  100935. * Gets the rendering group id the layer should render in.
  100936. */
  100937. readonly renderingGroupId: number;
  100938. /**
  100939. * An event triggered when the effect layer has been disposed.
  100940. */
  100941. onDisposeObservable: Observable<EffectLayer>;
  100942. /**
  100943. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  100944. */
  100945. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  100946. /**
  100947. * An event triggered when the generated texture is being merged in the scene.
  100948. */
  100949. onBeforeComposeObservable: Observable<EffectLayer>;
  100950. /**
  100951. * An event triggered when the generated texture has been merged in the scene.
  100952. */
  100953. onAfterComposeObservable: Observable<EffectLayer>;
  100954. /**
  100955. * An event triggered when the efffect layer changes its size.
  100956. */
  100957. onSizeChangedObservable: Observable<EffectLayer>;
  100958. /** @hidden */
  100959. static _SceneComponentInitialization: (scene: Scene) => void;
  100960. /**
  100961. * Instantiates a new effect Layer and references it in the scene.
  100962. * @param name The name of the layer
  100963. * @param scene The scene to use the layer in
  100964. */
  100965. constructor(
  100966. /** The Friendly of the effect in the scene */
  100967. name: string, scene: Scene);
  100968. /**
  100969. * Get the effect name of the layer.
  100970. * @return The effect name
  100971. */
  100972. abstract getEffectName(): string;
  100973. /**
  100974. * Checks for the readiness of the element composing the layer.
  100975. * @param subMesh the mesh to check for
  100976. * @param useInstances specify wether or not to use instances to render the mesh
  100977. * @return true if ready otherwise, false
  100978. */
  100979. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  100980. /**
  100981. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  100982. * @returns true if the effect requires stencil during the main canvas render pass.
  100983. */
  100984. abstract needStencil(): boolean;
  100985. /**
  100986. * Create the merge effect. This is the shader use to blit the information back
  100987. * to the main canvas at the end of the scene rendering.
  100988. * @returns The effect containing the shader used to merge the effect on the main canvas
  100989. */
  100990. protected abstract _createMergeEffect(): Effect;
  100991. /**
  100992. * Creates the render target textures and post processes used in the effect layer.
  100993. */
  100994. protected abstract _createTextureAndPostProcesses(): void;
  100995. /**
  100996. * Implementation specific of rendering the generating effect on the main canvas.
  100997. * @param effect The effect used to render through
  100998. */
  100999. protected abstract _internalRender(effect: Effect): void;
  101000. /**
  101001. * Sets the required values for both the emissive texture and and the main color.
  101002. */
  101003. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  101004. /**
  101005. * Free any resources and references associated to a mesh.
  101006. * Internal use
  101007. * @param mesh The mesh to free.
  101008. */
  101009. abstract _disposeMesh(mesh: Mesh): void;
  101010. /**
  101011. * Serializes this layer (Glow or Highlight for example)
  101012. * @returns a serialized layer object
  101013. */
  101014. abstract serialize?(): any;
  101015. /**
  101016. * Initializes the effect layer with the required options.
  101017. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  101018. */
  101019. protected _init(options: Partial<IEffectLayerOptions>): void;
  101020. /**
  101021. * Generates the index buffer of the full screen quad blending to the main canvas.
  101022. */
  101023. private _generateIndexBuffer;
  101024. /**
  101025. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  101026. */
  101027. private _genrateVertexBuffer;
  101028. /**
  101029. * Sets the main texture desired size which is the closest power of two
  101030. * of the engine canvas size.
  101031. */
  101032. private _setMainTextureSize;
  101033. /**
  101034. * Creates the main texture for the effect layer.
  101035. */
  101036. protected _createMainTexture(): void;
  101037. /**
  101038. * Adds specific effects defines.
  101039. * @param defines The defines to add specifics to.
  101040. */
  101041. protected _addCustomEffectDefines(defines: string[]): void;
  101042. /**
  101043. * Checks for the readiness of the element composing the layer.
  101044. * @param subMesh the mesh to check for
  101045. * @param useInstances specify wether or not to use instances to render the mesh
  101046. * @param emissiveTexture the associated emissive texture used to generate the glow
  101047. * @return true if ready otherwise, false
  101048. */
  101049. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  101050. /**
  101051. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  101052. */
  101053. render(): void;
  101054. /**
  101055. * Determine if a given mesh will be used in the current effect.
  101056. * @param mesh mesh to test
  101057. * @returns true if the mesh will be used
  101058. */
  101059. hasMesh(mesh: AbstractMesh): boolean;
  101060. /**
  101061. * Returns true if the layer contains information to display, otherwise false.
  101062. * @returns true if the glow layer should be rendered
  101063. */
  101064. shouldRender(): boolean;
  101065. /**
  101066. * Returns true if the mesh should render, otherwise false.
  101067. * @param mesh The mesh to render
  101068. * @returns true if it should render otherwise false
  101069. */
  101070. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  101071. /**
  101072. * Returns true if the mesh can be rendered, otherwise false.
  101073. * @param mesh The mesh to render
  101074. * @param material The material used on the mesh
  101075. * @returns true if it can be rendered otherwise false
  101076. */
  101077. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  101078. /**
  101079. * Returns true if the mesh should render, otherwise false.
  101080. * @param mesh The mesh to render
  101081. * @returns true if it should render otherwise false
  101082. */
  101083. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  101084. /**
  101085. * Renders the submesh passed in parameter to the generation map.
  101086. */
  101087. protected _renderSubMesh(subMesh: SubMesh): void;
  101088. /**
  101089. * Rebuild the required buffers.
  101090. * @hidden Internal use only.
  101091. */
  101092. _rebuild(): void;
  101093. /**
  101094. * Dispose only the render target textures and post process.
  101095. */
  101096. private _disposeTextureAndPostProcesses;
  101097. /**
  101098. * Dispose the highlight layer and free resources.
  101099. */
  101100. dispose(): void;
  101101. /**
  101102. * Gets the class name of the effect layer
  101103. * @returns the string with the class name of the effect layer
  101104. */
  101105. getClassName(): string;
  101106. /**
  101107. * Creates an effect layer from parsed effect layer data
  101108. * @param parsedEffectLayer defines effect layer data
  101109. * @param scene defines the current scene
  101110. * @param rootUrl defines the root URL containing the effect layer information
  101111. * @returns a parsed effect Layer
  101112. */
  101113. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  101114. }
  101115. }
  101116. declare module BABYLON {
  101117. interface AbstractScene {
  101118. /**
  101119. * The list of effect layers (highlights/glow) added to the scene
  101120. * @see http://doc.babylonjs.com/how_to/highlight_layer
  101121. * @see http://doc.babylonjs.com/how_to/glow_layer
  101122. */
  101123. effectLayers: Array<EffectLayer>;
  101124. /**
  101125. * Removes the given effect layer from this scene.
  101126. * @param toRemove defines the effect layer to remove
  101127. * @returns the index of the removed effect layer
  101128. */
  101129. removeEffectLayer(toRemove: EffectLayer): number;
  101130. /**
  101131. * Adds the given effect layer to this scene
  101132. * @param newEffectLayer defines the effect layer to add
  101133. */
  101134. addEffectLayer(newEffectLayer: EffectLayer): void;
  101135. }
  101136. /**
  101137. * Defines the layer scene component responsible to manage any effect layers
  101138. * in a given scene.
  101139. */
  101140. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  101141. /**
  101142. * The component name helpfull to identify the component in the list of scene components.
  101143. */
  101144. readonly name: string;
  101145. /**
  101146. * The scene the component belongs to.
  101147. */
  101148. scene: Scene;
  101149. private _engine;
  101150. private _renderEffects;
  101151. private _needStencil;
  101152. private _previousStencilState;
  101153. /**
  101154. * Creates a new instance of the component for the given scene
  101155. * @param scene Defines the scene to register the component in
  101156. */
  101157. constructor(scene: Scene);
  101158. /**
  101159. * Registers the component in a given scene
  101160. */
  101161. register(): void;
  101162. /**
  101163. * Rebuilds the elements related to this component in case of
  101164. * context lost for instance.
  101165. */
  101166. rebuild(): void;
  101167. /**
  101168. * Serializes the component data to the specified json object
  101169. * @param serializationObject The object to serialize to
  101170. */
  101171. serialize(serializationObject: any): void;
  101172. /**
  101173. * Adds all the element from the container to the scene
  101174. * @param container the container holding the elements
  101175. */
  101176. addFromContainer(container: AbstractScene): void;
  101177. /**
  101178. * Removes all the elements in the container from the scene
  101179. * @param container contains the elements to remove
  101180. */
  101181. removeFromContainer(container: AbstractScene): void;
  101182. /**
  101183. * Disposes the component and the associated ressources.
  101184. */
  101185. dispose(): void;
  101186. private _isReadyForMesh;
  101187. private _renderMainTexture;
  101188. private _setStencil;
  101189. private _setStencilBack;
  101190. private _draw;
  101191. private _drawCamera;
  101192. private _drawRenderingGroup;
  101193. }
  101194. }
  101195. declare module BABYLON {
  101196. /** @hidden */
  101197. export var glowMapMergePixelShader: {
  101198. name: string;
  101199. shader: string;
  101200. };
  101201. }
  101202. declare module BABYLON {
  101203. /** @hidden */
  101204. export var glowMapMergeVertexShader: {
  101205. name: string;
  101206. shader: string;
  101207. };
  101208. }
  101209. declare module BABYLON {
  101210. interface AbstractScene {
  101211. /**
  101212. * Return a the first highlight layer of the scene with a given name.
  101213. * @param name The name of the highlight layer to look for.
  101214. * @return The highlight layer if found otherwise null.
  101215. */
  101216. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  101217. }
  101218. /**
  101219. * Glow layer options. This helps customizing the behaviour
  101220. * of the glow layer.
  101221. */
  101222. export interface IGlowLayerOptions {
  101223. /**
  101224. * Multiplication factor apply to the canvas size to compute the render target size
  101225. * used to generated the glowing objects (the smaller the faster).
  101226. */
  101227. mainTextureRatio: number;
  101228. /**
  101229. * Enforces a fixed size texture to ensure resize independant blur.
  101230. */
  101231. mainTextureFixedSize?: number;
  101232. /**
  101233. * How big is the kernel of the blur texture.
  101234. */
  101235. blurKernelSize: number;
  101236. /**
  101237. * The camera attached to the layer.
  101238. */
  101239. camera: Nullable<Camera>;
  101240. /**
  101241. * Enable MSAA by chosing the number of samples.
  101242. */
  101243. mainTextureSamples?: number;
  101244. /**
  101245. * The rendering group to draw the layer in.
  101246. */
  101247. renderingGroupId: number;
  101248. }
  101249. /**
  101250. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  101251. *
  101252. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  101253. * glowy meshes to your scene.
  101254. *
  101255. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  101256. */
  101257. export class GlowLayer extends EffectLayer {
  101258. /**
  101259. * Effect Name of the layer.
  101260. */
  101261. static readonly EffectName: string;
  101262. /**
  101263. * The default blur kernel size used for the glow.
  101264. */
  101265. static DefaultBlurKernelSize: number;
  101266. /**
  101267. * The default texture size ratio used for the glow.
  101268. */
  101269. static DefaultTextureRatio: number;
  101270. /**
  101271. * Sets the kernel size of the blur.
  101272. */
  101273. /**
  101274. * Gets the kernel size of the blur.
  101275. */
  101276. blurKernelSize: number;
  101277. /**
  101278. * Sets the glow intensity.
  101279. */
  101280. /**
  101281. * Gets the glow intensity.
  101282. */
  101283. intensity: number;
  101284. private _options;
  101285. private _intensity;
  101286. private _horizontalBlurPostprocess1;
  101287. private _verticalBlurPostprocess1;
  101288. private _horizontalBlurPostprocess2;
  101289. private _verticalBlurPostprocess2;
  101290. private _blurTexture1;
  101291. private _blurTexture2;
  101292. private _postProcesses1;
  101293. private _postProcesses2;
  101294. private _includedOnlyMeshes;
  101295. private _excludedMeshes;
  101296. /**
  101297. * Callback used to let the user override the color selection on a per mesh basis
  101298. */
  101299. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  101300. /**
  101301. * Callback used to let the user override the texture selection on a per mesh basis
  101302. */
  101303. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  101304. /**
  101305. * Instantiates a new glow Layer and references it to the scene.
  101306. * @param name The name of the layer
  101307. * @param scene The scene to use the layer in
  101308. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  101309. */
  101310. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  101311. /**
  101312. * Get the effect name of the layer.
  101313. * @return The effect name
  101314. */
  101315. getEffectName(): string;
  101316. /**
  101317. * Create the merge effect. This is the shader use to blit the information back
  101318. * to the main canvas at the end of the scene rendering.
  101319. */
  101320. protected _createMergeEffect(): Effect;
  101321. /**
  101322. * Creates the render target textures and post processes used in the glow layer.
  101323. */
  101324. protected _createTextureAndPostProcesses(): void;
  101325. /**
  101326. * Checks for the readiness of the element composing the layer.
  101327. * @param subMesh the mesh to check for
  101328. * @param useInstances specify wether or not to use instances to render the mesh
  101329. * @param emissiveTexture the associated emissive texture used to generate the glow
  101330. * @return true if ready otherwise, false
  101331. */
  101332. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  101333. /**
  101334. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  101335. */
  101336. needStencil(): boolean;
  101337. /**
  101338. * Returns true if the mesh can be rendered, otherwise false.
  101339. * @param mesh The mesh to render
  101340. * @param material The material used on the mesh
  101341. * @returns true if it can be rendered otherwise false
  101342. */
  101343. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  101344. /**
  101345. * Implementation specific of rendering the generating effect on the main canvas.
  101346. * @param effect The effect used to render through
  101347. */
  101348. protected _internalRender(effect: Effect): void;
  101349. /**
  101350. * Sets the required values for both the emissive texture and and the main color.
  101351. */
  101352. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  101353. /**
  101354. * Returns true if the mesh should render, otherwise false.
  101355. * @param mesh The mesh to render
  101356. * @returns true if it should render otherwise false
  101357. */
  101358. protected _shouldRenderMesh(mesh: Mesh): boolean;
  101359. /**
  101360. * Adds specific effects defines.
  101361. * @param defines The defines to add specifics to.
  101362. */
  101363. protected _addCustomEffectDefines(defines: string[]): void;
  101364. /**
  101365. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  101366. * @param mesh The mesh to exclude from the glow layer
  101367. */
  101368. addExcludedMesh(mesh: Mesh): void;
  101369. /**
  101370. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  101371. * @param mesh The mesh to remove
  101372. */
  101373. removeExcludedMesh(mesh: Mesh): void;
  101374. /**
  101375. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  101376. * @param mesh The mesh to include in the glow layer
  101377. */
  101378. addIncludedOnlyMesh(mesh: Mesh): void;
  101379. /**
  101380. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  101381. * @param mesh The mesh to remove
  101382. */
  101383. removeIncludedOnlyMesh(mesh: Mesh): void;
  101384. /**
  101385. * Determine if a given mesh will be used in the glow layer
  101386. * @param mesh The mesh to test
  101387. * @returns true if the mesh will be highlighted by the current glow layer
  101388. */
  101389. hasMesh(mesh: AbstractMesh): boolean;
  101390. /**
  101391. * Free any resources and references associated to a mesh.
  101392. * Internal use
  101393. * @param mesh The mesh to free.
  101394. * @hidden
  101395. */
  101396. _disposeMesh(mesh: Mesh): void;
  101397. /**
  101398. * Gets the class name of the effect layer
  101399. * @returns the string with the class name of the effect layer
  101400. */
  101401. getClassName(): string;
  101402. /**
  101403. * Serializes this glow layer
  101404. * @returns a serialized glow layer object
  101405. */
  101406. serialize(): any;
  101407. /**
  101408. * Creates a Glow Layer from parsed glow layer data
  101409. * @param parsedGlowLayer defines glow layer data
  101410. * @param scene defines the current scene
  101411. * @param rootUrl defines the root URL containing the glow layer information
  101412. * @returns a parsed Glow Layer
  101413. */
  101414. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  101415. }
  101416. }
  101417. declare module BABYLON {
  101418. /** @hidden */
  101419. export var glowBlurPostProcessPixelShader: {
  101420. name: string;
  101421. shader: string;
  101422. };
  101423. }
  101424. declare module BABYLON {
  101425. interface AbstractScene {
  101426. /**
  101427. * Return a the first highlight layer of the scene with a given name.
  101428. * @param name The name of the highlight layer to look for.
  101429. * @return The highlight layer if found otherwise null.
  101430. */
  101431. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  101432. }
  101433. /**
  101434. * Highlight layer options. This helps customizing the behaviour
  101435. * of the highlight layer.
  101436. */
  101437. export interface IHighlightLayerOptions {
  101438. /**
  101439. * Multiplication factor apply to the canvas size to compute the render target size
  101440. * used to generated the glowing objects (the smaller the faster).
  101441. */
  101442. mainTextureRatio: number;
  101443. /**
  101444. * Enforces a fixed size texture to ensure resize independant blur.
  101445. */
  101446. mainTextureFixedSize?: number;
  101447. /**
  101448. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  101449. * of the picture to blur (the smaller the faster).
  101450. */
  101451. blurTextureSizeRatio: number;
  101452. /**
  101453. * How big in texel of the blur texture is the vertical blur.
  101454. */
  101455. blurVerticalSize: number;
  101456. /**
  101457. * How big in texel of the blur texture is the horizontal blur.
  101458. */
  101459. blurHorizontalSize: number;
  101460. /**
  101461. * Alpha blending mode used to apply the blur. Default is combine.
  101462. */
  101463. alphaBlendingMode: number;
  101464. /**
  101465. * The camera attached to the layer.
  101466. */
  101467. camera: Nullable<Camera>;
  101468. /**
  101469. * Should we display highlight as a solid stroke?
  101470. */
  101471. isStroke?: boolean;
  101472. /**
  101473. * The rendering group to draw the layer in.
  101474. */
  101475. renderingGroupId: number;
  101476. }
  101477. /**
  101478. * The highlight layer Helps adding a glow effect around a mesh.
  101479. *
  101480. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  101481. * glowy meshes to your scene.
  101482. *
  101483. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  101484. */
  101485. export class HighlightLayer extends EffectLayer {
  101486. name: string;
  101487. /**
  101488. * Effect Name of the highlight layer.
  101489. */
  101490. static readonly EffectName: string;
  101491. /**
  101492. * The neutral color used during the preparation of the glow effect.
  101493. * This is black by default as the blend operation is a blend operation.
  101494. */
  101495. static NeutralColor: Color4;
  101496. /**
  101497. * Stencil value used for glowing meshes.
  101498. */
  101499. static GlowingMeshStencilReference: number;
  101500. /**
  101501. * Stencil value used for the other meshes in the scene.
  101502. */
  101503. static NormalMeshStencilReference: number;
  101504. /**
  101505. * Specifies whether or not the inner glow is ACTIVE in the layer.
  101506. */
  101507. innerGlow: boolean;
  101508. /**
  101509. * Specifies whether or not the outer glow is ACTIVE in the layer.
  101510. */
  101511. outerGlow: boolean;
  101512. /**
  101513. * Specifies the horizontal size of the blur.
  101514. */
  101515. /**
  101516. * Gets the horizontal size of the blur.
  101517. */
  101518. blurHorizontalSize: number;
  101519. /**
  101520. * Specifies the vertical size of the blur.
  101521. */
  101522. /**
  101523. * Gets the vertical size of the blur.
  101524. */
  101525. blurVerticalSize: number;
  101526. /**
  101527. * An event triggered when the highlight layer is being blurred.
  101528. */
  101529. onBeforeBlurObservable: Observable<HighlightLayer>;
  101530. /**
  101531. * An event triggered when the highlight layer has been blurred.
  101532. */
  101533. onAfterBlurObservable: Observable<HighlightLayer>;
  101534. private _instanceGlowingMeshStencilReference;
  101535. private _options;
  101536. private _downSamplePostprocess;
  101537. private _horizontalBlurPostprocess;
  101538. private _verticalBlurPostprocess;
  101539. private _blurTexture;
  101540. private _meshes;
  101541. private _excludedMeshes;
  101542. /**
  101543. * Instantiates a new highlight Layer and references it to the scene..
  101544. * @param name The name of the layer
  101545. * @param scene The scene to use the layer in
  101546. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  101547. */
  101548. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  101549. /**
  101550. * Get the effect name of the layer.
  101551. * @return The effect name
  101552. */
  101553. getEffectName(): string;
  101554. /**
  101555. * Create the merge effect. This is the shader use to blit the information back
  101556. * to the main canvas at the end of the scene rendering.
  101557. */
  101558. protected _createMergeEffect(): Effect;
  101559. /**
  101560. * Creates the render target textures and post processes used in the highlight layer.
  101561. */
  101562. protected _createTextureAndPostProcesses(): void;
  101563. /**
  101564. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  101565. */
  101566. needStencil(): boolean;
  101567. /**
  101568. * Checks for the readiness of the element composing the layer.
  101569. * @param subMesh the mesh to check for
  101570. * @param useInstances specify wether or not to use instances to render the mesh
  101571. * @param emissiveTexture the associated emissive texture used to generate the glow
  101572. * @return true if ready otherwise, false
  101573. */
  101574. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  101575. /**
  101576. * Implementation specific of rendering the generating effect on the main canvas.
  101577. * @param effect The effect used to render through
  101578. */
  101579. protected _internalRender(effect: Effect): void;
  101580. /**
  101581. * Returns true if the layer contains information to display, otherwise false.
  101582. */
  101583. shouldRender(): boolean;
  101584. /**
  101585. * Returns true if the mesh should render, otherwise false.
  101586. * @param mesh The mesh to render
  101587. * @returns true if it should render otherwise false
  101588. */
  101589. protected _shouldRenderMesh(mesh: Mesh): boolean;
  101590. /**
  101591. * Sets the required values for both the emissive texture and and the main color.
  101592. */
  101593. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  101594. /**
  101595. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  101596. * @param mesh The mesh to exclude from the highlight layer
  101597. */
  101598. addExcludedMesh(mesh: Mesh): void;
  101599. /**
  101600. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  101601. * @param mesh The mesh to highlight
  101602. */
  101603. removeExcludedMesh(mesh: Mesh): void;
  101604. /**
  101605. * Determine if a given mesh will be highlighted by the current HighlightLayer
  101606. * @param mesh mesh to test
  101607. * @returns true if the mesh will be highlighted by the current HighlightLayer
  101608. */
  101609. hasMesh(mesh: AbstractMesh): boolean;
  101610. /**
  101611. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  101612. * @param mesh The mesh to highlight
  101613. * @param color The color of the highlight
  101614. * @param glowEmissiveOnly Extract the glow from the emissive texture
  101615. */
  101616. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  101617. /**
  101618. * Remove a mesh from the highlight layer in order to make it stop glowing.
  101619. * @param mesh The mesh to highlight
  101620. */
  101621. removeMesh(mesh: Mesh): void;
  101622. /**
  101623. * Force the stencil to the normal expected value for none glowing parts
  101624. */
  101625. private _defaultStencilReference;
  101626. /**
  101627. * Free any resources and references associated to a mesh.
  101628. * Internal use
  101629. * @param mesh The mesh to free.
  101630. * @hidden
  101631. */
  101632. _disposeMesh(mesh: Mesh): void;
  101633. /**
  101634. * Dispose the highlight layer and free resources.
  101635. */
  101636. dispose(): void;
  101637. /**
  101638. * Gets the class name of the effect layer
  101639. * @returns the string with the class name of the effect layer
  101640. */
  101641. getClassName(): string;
  101642. /**
  101643. * Serializes this Highlight layer
  101644. * @returns a serialized Highlight layer object
  101645. */
  101646. serialize(): any;
  101647. /**
  101648. * Creates a Highlight layer from parsed Highlight layer data
  101649. * @param parsedHightlightLayer defines the Highlight layer data
  101650. * @param scene defines the current scene
  101651. * @param rootUrl defines the root URL containing the Highlight layer information
  101652. * @returns a parsed Highlight layer
  101653. */
  101654. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  101655. }
  101656. }
  101657. declare module BABYLON {
  101658. /** @hidden */
  101659. export var lensFlarePixelShader: {
  101660. name: string;
  101661. shader: string;
  101662. };
  101663. }
  101664. declare module BABYLON {
  101665. /** @hidden */
  101666. export var lensFlareVertexShader: {
  101667. name: string;
  101668. shader: string;
  101669. };
  101670. }
  101671. declare module BABYLON {
  101672. /**
  101673. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  101674. * It is usually composed of several `lensFlare`.
  101675. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  101676. */
  101677. export class LensFlareSystem {
  101678. /**
  101679. * Define the name of the lens flare system
  101680. */
  101681. name: string;
  101682. /**
  101683. * List of lens flares used in this system.
  101684. */
  101685. lensFlares: LensFlare[];
  101686. /**
  101687. * Define a limit from the border the lens flare can be visible.
  101688. */
  101689. borderLimit: number;
  101690. /**
  101691. * Define a viewport border we do not want to see the lens flare in.
  101692. */
  101693. viewportBorder: number;
  101694. /**
  101695. * Define a predicate which could limit the list of meshes able to occlude the effect.
  101696. */
  101697. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  101698. /**
  101699. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  101700. */
  101701. layerMask: number;
  101702. /**
  101703. * Define the id of the lens flare system in the scene.
  101704. * (equal to name by default)
  101705. */
  101706. id: string;
  101707. private _scene;
  101708. private _emitter;
  101709. private _vertexBuffers;
  101710. private _indexBuffer;
  101711. private _effect;
  101712. private _positionX;
  101713. private _positionY;
  101714. private _isEnabled;
  101715. /** @hidden */
  101716. static _SceneComponentInitialization: (scene: Scene) => void;
  101717. /**
  101718. * Instantiates a lens flare system.
  101719. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  101720. * It is usually composed of several `lensFlare`.
  101721. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  101722. * @param name Define the name of the lens flare system in the scene
  101723. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  101724. * @param scene Define the scene the lens flare system belongs to
  101725. */
  101726. constructor(
  101727. /**
  101728. * Define the name of the lens flare system
  101729. */
  101730. name: string, emitter: any, scene: Scene);
  101731. /**
  101732. * Define if the lens flare system is enabled.
  101733. */
  101734. isEnabled: boolean;
  101735. /**
  101736. * Get the scene the effects belongs to.
  101737. * @returns the scene holding the lens flare system
  101738. */
  101739. getScene(): Scene;
  101740. /**
  101741. * Get the emitter of the lens flare system.
  101742. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  101743. * @returns the emitter of the lens flare system
  101744. */
  101745. getEmitter(): any;
  101746. /**
  101747. * Set the emitter of the lens flare system.
  101748. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  101749. * @param newEmitter Define the new emitter of the system
  101750. */
  101751. setEmitter(newEmitter: any): void;
  101752. /**
  101753. * Get the lens flare system emitter position.
  101754. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  101755. * @returns the position
  101756. */
  101757. getEmitterPosition(): Vector3;
  101758. /**
  101759. * @hidden
  101760. */
  101761. computeEffectivePosition(globalViewport: Viewport): boolean;
  101762. /** @hidden */
  101763. _isVisible(): boolean;
  101764. /**
  101765. * @hidden
  101766. */
  101767. render(): boolean;
  101768. /**
  101769. * Dispose and release the lens flare with its associated resources.
  101770. */
  101771. dispose(): void;
  101772. /**
  101773. * Parse a lens flare system from a JSON repressentation
  101774. * @param parsedLensFlareSystem Define the JSON to parse
  101775. * @param scene Define the scene the parsed system should be instantiated in
  101776. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  101777. * @returns the parsed system
  101778. */
  101779. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  101780. /**
  101781. * Serialize the current Lens Flare System into a JSON representation.
  101782. * @returns the serialized JSON
  101783. */
  101784. serialize(): any;
  101785. }
  101786. }
  101787. declare module BABYLON {
  101788. /**
  101789. * This represents one of the lens effect in a `lensFlareSystem`.
  101790. * It controls one of the indiviual texture used in the effect.
  101791. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  101792. */
  101793. export class LensFlare {
  101794. /**
  101795. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  101796. */
  101797. size: number;
  101798. /**
  101799. * 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.
  101800. */
  101801. position: number;
  101802. /**
  101803. * Define the lens color.
  101804. */
  101805. color: Color3;
  101806. /**
  101807. * Define the lens texture.
  101808. */
  101809. texture: Nullable<Texture>;
  101810. /**
  101811. * Define the alpha mode to render this particular lens.
  101812. */
  101813. alphaMode: number;
  101814. private _system;
  101815. /**
  101816. * Creates a new Lens Flare.
  101817. * This represents one of the lens effect in a `lensFlareSystem`.
  101818. * It controls one of the indiviual texture used in the effect.
  101819. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  101820. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  101821. * @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.
  101822. * @param color Define the lens color
  101823. * @param imgUrl Define the lens texture url
  101824. * @param system Define the `lensFlareSystem` this flare is part of
  101825. * @returns The newly created Lens Flare
  101826. */
  101827. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  101828. /**
  101829. * Instantiates a new Lens Flare.
  101830. * This represents one of the lens effect in a `lensFlareSystem`.
  101831. * It controls one of the indiviual texture used in the effect.
  101832. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  101833. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  101834. * @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.
  101835. * @param color Define the lens color
  101836. * @param imgUrl Define the lens texture url
  101837. * @param system Define the `lensFlareSystem` this flare is part of
  101838. */
  101839. constructor(
  101840. /**
  101841. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  101842. */
  101843. size: number,
  101844. /**
  101845. * 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.
  101846. */
  101847. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  101848. /**
  101849. * Dispose and release the lens flare with its associated resources.
  101850. */
  101851. dispose(): void;
  101852. }
  101853. }
  101854. declare module BABYLON {
  101855. interface AbstractScene {
  101856. /**
  101857. * The list of lens flare system added to the scene
  101858. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  101859. */
  101860. lensFlareSystems: Array<LensFlareSystem>;
  101861. /**
  101862. * Removes the given lens flare system from this scene.
  101863. * @param toRemove The lens flare system to remove
  101864. * @returns The index of the removed lens flare system
  101865. */
  101866. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  101867. /**
  101868. * Adds the given lens flare system to this scene
  101869. * @param newLensFlareSystem The lens flare system to add
  101870. */
  101871. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  101872. /**
  101873. * Gets a lens flare system using its name
  101874. * @param name defines the name to look for
  101875. * @returns the lens flare system or null if not found
  101876. */
  101877. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  101878. /**
  101879. * Gets a lens flare system using its id
  101880. * @param id defines the id to look for
  101881. * @returns the lens flare system or null if not found
  101882. */
  101883. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  101884. }
  101885. /**
  101886. * Defines the lens flare scene component responsible to manage any lens flares
  101887. * in a given scene.
  101888. */
  101889. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  101890. /**
  101891. * The component name helpfull to identify the component in the list of scene components.
  101892. */
  101893. readonly name: string;
  101894. /**
  101895. * The scene the component belongs to.
  101896. */
  101897. scene: Scene;
  101898. /**
  101899. * Creates a new instance of the component for the given scene
  101900. * @param scene Defines the scene to register the component in
  101901. */
  101902. constructor(scene: Scene);
  101903. /**
  101904. * Registers the component in a given scene
  101905. */
  101906. register(): void;
  101907. /**
  101908. * Rebuilds the elements related to this component in case of
  101909. * context lost for instance.
  101910. */
  101911. rebuild(): void;
  101912. /**
  101913. * Adds all the element from the container to the scene
  101914. * @param container the container holding the elements
  101915. */
  101916. addFromContainer(container: AbstractScene): void;
  101917. /**
  101918. * Removes all the elements in the container from the scene
  101919. * @param container contains the elements to remove
  101920. */
  101921. removeFromContainer(container: AbstractScene): void;
  101922. /**
  101923. * Serializes the component data to the specified json object
  101924. * @param serializationObject The object to serialize to
  101925. */
  101926. serialize(serializationObject: any): void;
  101927. /**
  101928. * Disposes the component and the associated ressources.
  101929. */
  101930. dispose(): void;
  101931. private _draw;
  101932. }
  101933. }
  101934. declare module BABYLON {
  101935. /**
  101936. * Defines the shadow generator component responsible to manage any shadow generators
  101937. * in a given scene.
  101938. */
  101939. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  101940. /**
  101941. * The component name helpfull to identify the component in the list of scene components.
  101942. */
  101943. readonly name: string;
  101944. /**
  101945. * The scene the component belongs to.
  101946. */
  101947. scene: Scene;
  101948. /**
  101949. * Creates a new instance of the component for the given scene
  101950. * @param scene Defines the scene to register the component in
  101951. */
  101952. constructor(scene: Scene);
  101953. /**
  101954. * Registers the component in a given scene
  101955. */
  101956. register(): void;
  101957. /**
  101958. * Rebuilds the elements related to this component in case of
  101959. * context lost for instance.
  101960. */
  101961. rebuild(): void;
  101962. /**
  101963. * Serializes the component data to the specified json object
  101964. * @param serializationObject The object to serialize to
  101965. */
  101966. serialize(serializationObject: any): void;
  101967. /**
  101968. * Adds all the element from the container to the scene
  101969. * @param container the container holding the elements
  101970. */
  101971. addFromContainer(container: AbstractScene): void;
  101972. /**
  101973. * Removes all the elements in the container from the scene
  101974. * @param container contains the elements to remove
  101975. */
  101976. removeFromContainer(container: AbstractScene): void;
  101977. /**
  101978. * Rebuilds the elements related to this component in case of
  101979. * context lost for instance.
  101980. */
  101981. dispose(): void;
  101982. private _gatherRenderTargets;
  101983. }
  101984. }
  101985. declare module BABYLON {
  101986. /**
  101987. * A directional light is defined by a direction (what a surprise!).
  101988. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  101989. * 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.
  101990. * Documentation: https://doc.babylonjs.com/babylon101/lights
  101991. */
  101992. export class DirectionalLight extends ShadowLight {
  101993. private _shadowFrustumSize;
  101994. /**
  101995. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  101996. */
  101997. /**
  101998. * Specifies a fix frustum size for the shadow generation.
  101999. */
  102000. shadowFrustumSize: number;
  102001. private _shadowOrthoScale;
  102002. /**
  102003. * Gets the shadow projection scale against the optimal computed one.
  102004. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  102005. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  102006. */
  102007. /**
  102008. * Sets the shadow projection scale against the optimal computed one.
  102009. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  102010. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  102011. */
  102012. shadowOrthoScale: number;
  102013. /**
  102014. * Automatically compute the projection matrix to best fit (including all the casters)
  102015. * on each frame.
  102016. */
  102017. autoUpdateExtends: boolean;
  102018. private _orthoLeft;
  102019. private _orthoRight;
  102020. private _orthoTop;
  102021. private _orthoBottom;
  102022. /**
  102023. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  102024. * The directional light is emitted from everywhere in the given direction.
  102025. * It can cast shadows.
  102026. * Documentation : https://doc.babylonjs.com/babylon101/lights
  102027. * @param name The friendly name of the light
  102028. * @param direction The direction of the light
  102029. * @param scene The scene the light belongs to
  102030. */
  102031. constructor(name: string, direction: Vector3, scene: Scene);
  102032. /**
  102033. * Returns the string "DirectionalLight".
  102034. * @return The class name
  102035. */
  102036. getClassName(): string;
  102037. /**
  102038. * Returns the integer 1.
  102039. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  102040. */
  102041. getTypeID(): number;
  102042. /**
  102043. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  102044. * Returns the DirectionalLight Shadow projection matrix.
  102045. */
  102046. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102047. /**
  102048. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  102049. * Returns the DirectionalLight Shadow projection matrix.
  102050. */
  102051. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  102052. /**
  102053. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  102054. * Returns the DirectionalLight Shadow projection matrix.
  102055. */
  102056. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102057. protected _buildUniformLayout(): void;
  102058. /**
  102059. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  102060. * @param effect The effect to update
  102061. * @param lightIndex The index of the light in the effect to update
  102062. * @returns The directional light
  102063. */
  102064. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  102065. /**
  102066. * Gets the minZ used for shadow according to both the scene and the light.
  102067. *
  102068. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  102069. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  102070. * @param activeCamera The camera we are returning the min for
  102071. * @returns the depth min z
  102072. */
  102073. getDepthMinZ(activeCamera: Camera): number;
  102074. /**
  102075. * Gets the maxZ used for shadow according to both the scene and the light.
  102076. *
  102077. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  102078. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  102079. * @param activeCamera The camera we are returning the max for
  102080. * @returns the depth max z
  102081. */
  102082. getDepthMaxZ(activeCamera: Camera): number;
  102083. /**
  102084. * Prepares the list of defines specific to the light type.
  102085. * @param defines the list of defines
  102086. * @param lightIndex defines the index of the light for the effect
  102087. */
  102088. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  102089. }
  102090. }
  102091. declare module BABYLON {
  102092. /**
  102093. * A point light is a light defined by an unique point in world space.
  102094. * The light is emitted in every direction from this point.
  102095. * A good example of a point light is a standard light bulb.
  102096. * Documentation: https://doc.babylonjs.com/babylon101/lights
  102097. */
  102098. export class PointLight extends ShadowLight {
  102099. private _shadowAngle;
  102100. /**
  102101. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  102102. * This specifies what angle the shadow will use to be created.
  102103. *
  102104. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  102105. */
  102106. /**
  102107. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  102108. * This specifies what angle the shadow will use to be created.
  102109. *
  102110. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  102111. */
  102112. shadowAngle: number;
  102113. /**
  102114. * Gets the direction if it has been set.
  102115. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  102116. */
  102117. /**
  102118. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  102119. */
  102120. direction: Vector3;
  102121. /**
  102122. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  102123. * A PointLight emits the light in every direction.
  102124. * It can cast shadows.
  102125. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  102126. * ```javascript
  102127. * var pointLight = new PointLight("pl", camera.position, scene);
  102128. * ```
  102129. * Documentation : https://doc.babylonjs.com/babylon101/lights
  102130. * @param name The light friendly name
  102131. * @param position The position of the point light in the scene
  102132. * @param scene The scene the lights belongs to
  102133. */
  102134. constructor(name: string, position: Vector3, scene: Scene);
  102135. /**
  102136. * Returns the string "PointLight"
  102137. * @returns the class name
  102138. */
  102139. getClassName(): string;
  102140. /**
  102141. * Returns the integer 0.
  102142. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  102143. */
  102144. getTypeID(): number;
  102145. /**
  102146. * Specifies wether or not the shadowmap should be a cube texture.
  102147. * @returns true if the shadowmap needs to be a cube texture.
  102148. */
  102149. needCube(): boolean;
  102150. /**
  102151. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  102152. * @param faceIndex The index of the face we are computed the direction to generate shadow
  102153. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  102154. */
  102155. getShadowDirection(faceIndex?: number): Vector3;
  102156. /**
  102157. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  102158. * - fov = PI / 2
  102159. * - aspect ratio : 1.0
  102160. * - z-near and far equal to the active camera minZ and maxZ.
  102161. * Returns the PointLight.
  102162. */
  102163. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102164. protected _buildUniformLayout(): void;
  102165. /**
  102166. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  102167. * @param effect The effect to update
  102168. * @param lightIndex The index of the light in the effect to update
  102169. * @returns The point light
  102170. */
  102171. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  102172. /**
  102173. * Prepares the list of defines specific to the light type.
  102174. * @param defines the list of defines
  102175. * @param lightIndex defines the index of the light for the effect
  102176. */
  102177. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  102178. }
  102179. }
  102180. declare module BABYLON {
  102181. /**
  102182. * A spot light is defined by a position, a direction, an angle, and an exponent.
  102183. * These values define a cone of light starting from the position, emitting toward the direction.
  102184. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  102185. * and the exponent defines the speed of the decay of the light with distance (reach).
  102186. * Documentation: https://doc.babylonjs.com/babylon101/lights
  102187. */
  102188. export class SpotLight extends ShadowLight {
  102189. private _angle;
  102190. private _innerAngle;
  102191. private _cosHalfAngle;
  102192. private _lightAngleScale;
  102193. private _lightAngleOffset;
  102194. /**
  102195. * Gets the cone angle of the spot light in Radians.
  102196. */
  102197. /**
  102198. * Sets the cone angle of the spot light in Radians.
  102199. */
  102200. angle: number;
  102201. /**
  102202. * Only used in gltf falloff mode, this defines the angle where
  102203. * the directional falloff will start before cutting at angle which could be seen
  102204. * as outer angle.
  102205. */
  102206. /**
  102207. * Only used in gltf falloff mode, this defines the angle where
  102208. * the directional falloff will start before cutting at angle which could be seen
  102209. * as outer angle.
  102210. */
  102211. innerAngle: number;
  102212. private _shadowAngleScale;
  102213. /**
  102214. * Allows scaling the angle of the light for shadow generation only.
  102215. */
  102216. /**
  102217. * Allows scaling the angle of the light for shadow generation only.
  102218. */
  102219. shadowAngleScale: number;
  102220. /**
  102221. * The light decay speed with the distance from the emission spot.
  102222. */
  102223. exponent: number;
  102224. private _projectionTextureMatrix;
  102225. /**
  102226. * Allows reading the projecton texture
  102227. */
  102228. readonly projectionTextureMatrix: Matrix;
  102229. protected _projectionTextureLightNear: number;
  102230. /**
  102231. * Gets the near clip of the Spotlight for texture projection.
  102232. */
  102233. /**
  102234. * Sets the near clip of the Spotlight for texture projection.
  102235. */
  102236. projectionTextureLightNear: number;
  102237. protected _projectionTextureLightFar: number;
  102238. /**
  102239. * Gets the far clip of the Spotlight for texture projection.
  102240. */
  102241. /**
  102242. * Sets the far clip of the Spotlight for texture projection.
  102243. */
  102244. projectionTextureLightFar: number;
  102245. protected _projectionTextureUpDirection: Vector3;
  102246. /**
  102247. * Gets the Up vector of the Spotlight for texture projection.
  102248. */
  102249. /**
  102250. * Sets the Up vector of the Spotlight for texture projection.
  102251. */
  102252. projectionTextureUpDirection: Vector3;
  102253. private _projectionTexture;
  102254. /**
  102255. * Gets the projection texture of the light.
  102256. */
  102257. /**
  102258. * Sets the projection texture of the light.
  102259. */
  102260. projectionTexture: Nullable<BaseTexture>;
  102261. private _projectionTextureViewLightDirty;
  102262. private _projectionTextureProjectionLightDirty;
  102263. private _projectionTextureDirty;
  102264. private _projectionTextureViewTargetVector;
  102265. private _projectionTextureViewLightMatrix;
  102266. private _projectionTextureProjectionLightMatrix;
  102267. private _projectionTextureScalingMatrix;
  102268. /**
  102269. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  102270. * It can cast shadows.
  102271. * Documentation : https://doc.babylonjs.com/babylon101/lights
  102272. * @param name The light friendly name
  102273. * @param position The position of the spot light in the scene
  102274. * @param direction The direction of the light in the scene
  102275. * @param angle The cone angle of the light in Radians
  102276. * @param exponent The light decay speed with the distance from the emission spot
  102277. * @param scene The scene the lights belongs to
  102278. */
  102279. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  102280. /**
  102281. * Returns the string "SpotLight".
  102282. * @returns the class name
  102283. */
  102284. getClassName(): string;
  102285. /**
  102286. * Returns the integer 2.
  102287. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  102288. */
  102289. getTypeID(): number;
  102290. /**
  102291. * Overrides the direction setter to recompute the projection texture view light Matrix.
  102292. */
  102293. protected _setDirection(value: Vector3): void;
  102294. /**
  102295. * Overrides the position setter to recompute the projection texture view light Matrix.
  102296. */
  102297. protected _setPosition(value: Vector3): void;
  102298. /**
  102299. * 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.
  102300. * Returns the SpotLight.
  102301. */
  102302. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102303. protected _computeProjectionTextureViewLightMatrix(): void;
  102304. protected _computeProjectionTextureProjectionLightMatrix(): void;
  102305. /**
  102306. * Main function for light texture projection matrix computing.
  102307. */
  102308. protected _computeProjectionTextureMatrix(): void;
  102309. protected _buildUniformLayout(): void;
  102310. private _computeAngleValues;
  102311. /**
  102312. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  102313. * @param effect The effect to update
  102314. * @param lightIndex The index of the light in the effect to update
  102315. * @returns The spot light
  102316. */
  102317. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  102318. /**
  102319. * Disposes the light and the associated resources.
  102320. */
  102321. dispose(): void;
  102322. /**
  102323. * Prepares the list of defines specific to the light type.
  102324. * @param defines the list of defines
  102325. * @param lightIndex defines the index of the light for the effect
  102326. */
  102327. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  102328. }
  102329. }
  102330. declare module BABYLON {
  102331. /**
  102332. * Header information of HDR texture files.
  102333. */
  102334. export interface HDRInfo {
  102335. /**
  102336. * The height of the texture in pixels.
  102337. */
  102338. height: number;
  102339. /**
  102340. * The width of the texture in pixels.
  102341. */
  102342. width: number;
  102343. /**
  102344. * The index of the beginning of the data in the binary file.
  102345. */
  102346. dataPosition: number;
  102347. }
  102348. /**
  102349. * This groups tools to convert HDR texture to native colors array.
  102350. */
  102351. export class HDRTools {
  102352. private static Ldexp;
  102353. private static Rgbe2float;
  102354. private static readStringLine;
  102355. /**
  102356. * Reads header information from an RGBE texture stored in a native array.
  102357. * More information on this format are available here:
  102358. * https://en.wikipedia.org/wiki/RGBE_image_format
  102359. *
  102360. * @param uint8array The binary file stored in native array.
  102361. * @return The header information.
  102362. */
  102363. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  102364. /**
  102365. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  102366. * This RGBE texture needs to store the information as a panorama.
  102367. *
  102368. * More information on this format are available here:
  102369. * https://en.wikipedia.org/wiki/RGBE_image_format
  102370. *
  102371. * @param buffer The binary file stored in an array buffer.
  102372. * @param size The expected size of the extracted cubemap.
  102373. * @return The Cube Map information.
  102374. */
  102375. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  102376. /**
  102377. * Returns the pixels data extracted from an RGBE texture.
  102378. * This pixels will be stored left to right up to down in the R G B order in one array.
  102379. *
  102380. * More information on this format are available here:
  102381. * https://en.wikipedia.org/wiki/RGBE_image_format
  102382. *
  102383. * @param uint8array The binary file stored in an array buffer.
  102384. * @param hdrInfo The header information of the file.
  102385. * @return The pixels data in RGB right to left up to down order.
  102386. */
  102387. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  102388. private static RGBE_ReadPixels_RLE;
  102389. }
  102390. }
  102391. declare module BABYLON {
  102392. /**
  102393. * This represents a texture coming from an HDR input.
  102394. *
  102395. * The only supported format is currently panorama picture stored in RGBE format.
  102396. * Example of such files can be found on HDRLib: http://hdrlib.com/
  102397. */
  102398. export class HDRCubeTexture extends BaseTexture {
  102399. private static _facesMapping;
  102400. private _generateHarmonics;
  102401. private _noMipmap;
  102402. private _textureMatrix;
  102403. private _size;
  102404. private _onLoad;
  102405. private _onError;
  102406. /**
  102407. * The texture URL.
  102408. */
  102409. url: string;
  102410. /**
  102411. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  102412. */
  102413. coordinatesMode: number;
  102414. protected _isBlocking: boolean;
  102415. /**
  102416. * Sets wether or not the texture is blocking during loading.
  102417. */
  102418. /**
  102419. * Gets wether or not the texture is blocking during loading.
  102420. */
  102421. isBlocking: boolean;
  102422. protected _rotationY: number;
  102423. /**
  102424. * Sets texture matrix rotation angle around Y axis in radians.
  102425. */
  102426. /**
  102427. * Gets texture matrix rotation angle around Y axis radians.
  102428. */
  102429. rotationY: number;
  102430. /**
  102431. * Gets or sets the center of the bounding box associated with the cube texture
  102432. * It must define where the camera used to render the texture was set
  102433. */
  102434. boundingBoxPosition: Vector3;
  102435. private _boundingBoxSize;
  102436. /**
  102437. * Gets or sets the size of the bounding box associated with the cube texture
  102438. * When defined, the cubemap will switch to local mode
  102439. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  102440. * @example https://www.babylonjs-playground.com/#RNASML
  102441. */
  102442. boundingBoxSize: Vector3;
  102443. /**
  102444. * Instantiates an HDRTexture from the following parameters.
  102445. *
  102446. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  102447. * @param scene The scene the texture will be used in
  102448. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  102449. * @param noMipmap Forces to not generate the mipmap if true
  102450. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  102451. * @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)
  102452. * @param reserved Reserved flag for internal use.
  102453. */
  102454. 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>);
  102455. /**
  102456. * Get the current class name of the texture useful for serialization or dynamic coding.
  102457. * @returns "HDRCubeTexture"
  102458. */
  102459. getClassName(): string;
  102460. /**
  102461. * Occurs when the file is raw .hdr file.
  102462. */
  102463. private loadTexture;
  102464. clone(): HDRCubeTexture;
  102465. delayLoad(): void;
  102466. /**
  102467. * Get the texture reflection matrix used to rotate/transform the reflection.
  102468. * @returns the reflection matrix
  102469. */
  102470. getReflectionTextureMatrix(): Matrix;
  102471. /**
  102472. * Set the texture reflection matrix used to rotate/transform the reflection.
  102473. * @param value Define the reflection matrix to set
  102474. */
  102475. setReflectionTextureMatrix(value: Matrix): void;
  102476. /**
  102477. * Parses a JSON representation of an HDR Texture in order to create the texture
  102478. * @param parsedTexture Define the JSON representation
  102479. * @param scene Define the scene the texture should be created in
  102480. * @param rootUrl Define the root url in case we need to load relative dependencies
  102481. * @returns the newly created texture after parsing
  102482. */
  102483. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  102484. serialize(): any;
  102485. }
  102486. }
  102487. declare module BABYLON {
  102488. /**
  102489. * Class used to control physics engine
  102490. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  102491. */
  102492. export class PhysicsEngine implements IPhysicsEngine {
  102493. private _physicsPlugin;
  102494. /**
  102495. * Global value used to control the smallest number supported by the simulation
  102496. */
  102497. static Epsilon: number;
  102498. private _impostors;
  102499. private _joints;
  102500. /**
  102501. * Gets the gravity vector used by the simulation
  102502. */
  102503. gravity: Vector3;
  102504. /**
  102505. * Factory used to create the default physics plugin.
  102506. * @returns The default physics plugin
  102507. */
  102508. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  102509. /**
  102510. * Creates a new Physics Engine
  102511. * @param gravity defines the gravity vector used by the simulation
  102512. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  102513. */
  102514. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  102515. /**
  102516. * Sets the gravity vector used by the simulation
  102517. * @param gravity defines the gravity vector to use
  102518. */
  102519. setGravity(gravity: Vector3): void;
  102520. /**
  102521. * Set the time step of the physics engine.
  102522. * Default is 1/60.
  102523. * To slow it down, enter 1/600 for example.
  102524. * To speed it up, 1/30
  102525. * @param newTimeStep defines the new timestep to apply to this world.
  102526. */
  102527. setTimeStep(newTimeStep?: number): void;
  102528. /**
  102529. * Get the time step of the physics engine.
  102530. * @returns the current time step
  102531. */
  102532. getTimeStep(): number;
  102533. /**
  102534. * Release all resources
  102535. */
  102536. dispose(): void;
  102537. /**
  102538. * Gets the name of the current physics plugin
  102539. * @returns the name of the plugin
  102540. */
  102541. getPhysicsPluginName(): string;
  102542. /**
  102543. * Adding a new impostor for the impostor tracking.
  102544. * This will be done by the impostor itself.
  102545. * @param impostor the impostor to add
  102546. */
  102547. addImpostor(impostor: PhysicsImpostor): void;
  102548. /**
  102549. * Remove an impostor from the engine.
  102550. * This impostor and its mesh will not longer be updated by the physics engine.
  102551. * @param impostor the impostor to remove
  102552. */
  102553. removeImpostor(impostor: PhysicsImpostor): void;
  102554. /**
  102555. * Add a joint to the physics engine
  102556. * @param mainImpostor defines the main impostor to which the joint is added.
  102557. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  102558. * @param joint defines the joint that will connect both impostors.
  102559. */
  102560. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  102561. /**
  102562. * Removes a joint from the simulation
  102563. * @param mainImpostor defines the impostor used with the joint
  102564. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  102565. * @param joint defines the joint to remove
  102566. */
  102567. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  102568. /**
  102569. * Called by the scene. No need to call it.
  102570. * @param delta defines the timespam between frames
  102571. */
  102572. _step(delta: number): void;
  102573. /**
  102574. * Gets the current plugin used to run the simulation
  102575. * @returns current plugin
  102576. */
  102577. getPhysicsPlugin(): IPhysicsEnginePlugin;
  102578. /**
  102579. * Gets the list of physic impostors
  102580. * @returns an array of PhysicsImpostor
  102581. */
  102582. getImpostors(): Array<PhysicsImpostor>;
  102583. /**
  102584. * Gets the impostor for a physics enabled object
  102585. * @param object defines the object impersonated by the impostor
  102586. * @returns the PhysicsImpostor or null if not found
  102587. */
  102588. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  102589. /**
  102590. * Gets the impostor for a physics body object
  102591. * @param body defines physics body used by the impostor
  102592. * @returns the PhysicsImpostor or null if not found
  102593. */
  102594. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  102595. }
  102596. }
  102597. declare module BABYLON {
  102598. /** @hidden */
  102599. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  102600. private _useDeltaForWorldStep;
  102601. world: any;
  102602. name: string;
  102603. private _physicsMaterials;
  102604. private _fixedTimeStep;
  102605. BJSCANNON: any;
  102606. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  102607. setGravity(gravity: Vector3): void;
  102608. setTimeStep(timeStep: number): void;
  102609. getTimeStep(): number;
  102610. executeStep(delta: number): void;
  102611. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  102612. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  102613. generatePhysicsBody(impostor: PhysicsImpostor): void;
  102614. private _processChildMeshes;
  102615. removePhysicsBody(impostor: PhysicsImpostor): void;
  102616. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  102617. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  102618. private _addMaterial;
  102619. private _checkWithEpsilon;
  102620. private _createShape;
  102621. private _createHeightmap;
  102622. private _minus90X;
  102623. private _plus90X;
  102624. private _tmpPosition;
  102625. private _tmpDeltaPosition;
  102626. private _tmpUnityRotation;
  102627. private _updatePhysicsBodyTransformation;
  102628. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  102629. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  102630. isSupported(): boolean;
  102631. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  102632. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  102633. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  102634. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  102635. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  102636. getBodyMass(impostor: PhysicsImpostor): number;
  102637. getBodyFriction(impostor: PhysicsImpostor): number;
  102638. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  102639. getBodyRestitution(impostor: PhysicsImpostor): number;
  102640. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  102641. sleepBody(impostor: PhysicsImpostor): void;
  102642. wakeUpBody(impostor: PhysicsImpostor): void;
  102643. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  102644. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  102645. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  102646. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  102647. getRadius(impostor: PhysicsImpostor): number;
  102648. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  102649. dispose(): void;
  102650. private _extendNamespace;
  102651. }
  102652. }
  102653. declare module BABYLON {
  102654. /** @hidden */
  102655. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  102656. world: any;
  102657. name: string;
  102658. BJSOIMO: any;
  102659. constructor(iterations?: number, oimoInjection?: any);
  102660. setGravity(gravity: Vector3): void;
  102661. setTimeStep(timeStep: number): void;
  102662. getTimeStep(): number;
  102663. private _tmpImpostorsArray;
  102664. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  102665. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  102666. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  102667. generatePhysicsBody(impostor: PhysicsImpostor): void;
  102668. private _tmpPositionVector;
  102669. removePhysicsBody(impostor: PhysicsImpostor): void;
  102670. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  102671. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  102672. isSupported(): boolean;
  102673. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  102674. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  102675. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  102676. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  102677. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  102678. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  102679. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  102680. getBodyMass(impostor: PhysicsImpostor): number;
  102681. getBodyFriction(impostor: PhysicsImpostor): number;
  102682. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  102683. getBodyRestitution(impostor: PhysicsImpostor): number;
  102684. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  102685. sleepBody(impostor: PhysicsImpostor): void;
  102686. wakeUpBody(impostor: PhysicsImpostor): void;
  102687. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  102688. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  102689. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  102690. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  102691. getRadius(impostor: PhysicsImpostor): number;
  102692. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  102693. dispose(): void;
  102694. }
  102695. }
  102696. declare module BABYLON {
  102697. interface AbstractScene {
  102698. /**
  102699. * The list of reflection probes added to the scene
  102700. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  102701. */
  102702. reflectionProbes: Array<ReflectionProbe>;
  102703. /**
  102704. * Removes the given reflection probe from this scene.
  102705. * @param toRemove The reflection probe to remove
  102706. * @returns The index of the removed reflection probe
  102707. */
  102708. removeReflectionProbe(toRemove: ReflectionProbe): number;
  102709. /**
  102710. * Adds the given reflection probe to this scene.
  102711. * @param newReflectionProbe The reflection probe to add
  102712. */
  102713. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  102714. }
  102715. /**
  102716. * Class used to generate realtime reflection / refraction cube textures
  102717. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  102718. */
  102719. export class ReflectionProbe {
  102720. /** defines the name of the probe */
  102721. name: string;
  102722. private _scene;
  102723. private _renderTargetTexture;
  102724. private _projectionMatrix;
  102725. private _viewMatrix;
  102726. private _target;
  102727. private _add;
  102728. private _attachedMesh;
  102729. private _invertYAxis;
  102730. /** Gets or sets probe position (center of the cube map) */
  102731. position: Vector3;
  102732. /**
  102733. * Creates a new reflection probe
  102734. * @param name defines the name of the probe
  102735. * @param size defines the texture resolution (for each face)
  102736. * @param scene defines the hosting scene
  102737. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  102738. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  102739. */
  102740. constructor(
  102741. /** defines the name of the probe */
  102742. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  102743. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  102744. samples: number;
  102745. /** Gets or sets the refresh rate to use (on every frame by default) */
  102746. refreshRate: number;
  102747. /**
  102748. * Gets the hosting scene
  102749. * @returns a Scene
  102750. */
  102751. getScene(): Scene;
  102752. /** Gets the internal CubeTexture used to render to */
  102753. readonly cubeTexture: RenderTargetTexture;
  102754. /** Gets the list of meshes to render */
  102755. readonly renderList: Nullable<AbstractMesh[]>;
  102756. /**
  102757. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  102758. * @param mesh defines the mesh to attach to
  102759. */
  102760. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  102761. /**
  102762. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  102763. * @param renderingGroupId The rendering group id corresponding to its index
  102764. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  102765. */
  102766. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  102767. /**
  102768. * Clean all associated resources
  102769. */
  102770. dispose(): void;
  102771. /**
  102772. * Converts the reflection probe information to a readable string for debug purpose.
  102773. * @param fullDetails Supports for multiple levels of logging within scene loading
  102774. * @returns the human readable reflection probe info
  102775. */
  102776. toString(fullDetails?: boolean): string;
  102777. /**
  102778. * Get the class name of the relfection probe.
  102779. * @returns "ReflectionProbe"
  102780. */
  102781. getClassName(): string;
  102782. /**
  102783. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  102784. * @returns The JSON representation of the texture
  102785. */
  102786. serialize(): any;
  102787. /**
  102788. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  102789. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  102790. * @param scene Define the scene the parsed reflection probe should be instantiated in
  102791. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  102792. * @returns The parsed reflection probe if successful
  102793. */
  102794. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  102795. }
  102796. }
  102797. declare module BABYLON {
  102798. /** @hidden */
  102799. export var _BabylonLoaderRegistered: boolean;
  102800. }
  102801. declare module BABYLON {
  102802. /**
  102803. * The Physically based simple base material of BJS.
  102804. *
  102805. * This enables better naming and convention enforcements on top of the pbrMaterial.
  102806. * It is used as the base class for both the specGloss and metalRough conventions.
  102807. */
  102808. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  102809. /**
  102810. * Number of Simultaneous lights allowed on the material.
  102811. */
  102812. maxSimultaneousLights: number;
  102813. /**
  102814. * If sets to true, disables all the lights affecting the material.
  102815. */
  102816. disableLighting: boolean;
  102817. /**
  102818. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  102819. */
  102820. environmentTexture: BaseTexture;
  102821. /**
  102822. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  102823. */
  102824. invertNormalMapX: boolean;
  102825. /**
  102826. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  102827. */
  102828. invertNormalMapY: boolean;
  102829. /**
  102830. * Normal map used in the model.
  102831. */
  102832. normalTexture: BaseTexture;
  102833. /**
  102834. * Emissivie color used to self-illuminate the model.
  102835. */
  102836. emissiveColor: Color3;
  102837. /**
  102838. * Emissivie texture used to self-illuminate the model.
  102839. */
  102840. emissiveTexture: BaseTexture;
  102841. /**
  102842. * Occlusion Channel Strenght.
  102843. */
  102844. occlusionStrength: number;
  102845. /**
  102846. * Occlusion Texture of the material (adding extra occlusion effects).
  102847. */
  102848. occlusionTexture: BaseTexture;
  102849. /**
  102850. * Defines the alpha limits in alpha test mode.
  102851. */
  102852. alphaCutOff: number;
  102853. /**
  102854. * Gets the current double sided mode.
  102855. */
  102856. /**
  102857. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  102858. */
  102859. doubleSided: boolean;
  102860. /**
  102861. * Stores the pre-calculated light information of a mesh in a texture.
  102862. */
  102863. lightmapTexture: BaseTexture;
  102864. /**
  102865. * If true, the light map contains occlusion information instead of lighting info.
  102866. */
  102867. useLightmapAsShadowmap: boolean;
  102868. /**
  102869. * Instantiates a new PBRMaterial instance.
  102870. *
  102871. * @param name The material name
  102872. * @param scene The scene the material will be use in.
  102873. */
  102874. constructor(name: string, scene: Scene);
  102875. getClassName(): string;
  102876. }
  102877. }
  102878. declare module BABYLON {
  102879. /**
  102880. * The PBR material of BJS following the metal roughness convention.
  102881. *
  102882. * This fits to the PBR convention in the GLTF definition:
  102883. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  102884. */
  102885. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  102886. /**
  102887. * The base color has two different interpretations depending on the value of metalness.
  102888. * When the material is a metal, the base color is the specific measured reflectance value
  102889. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  102890. * of the material.
  102891. */
  102892. baseColor: Color3;
  102893. /**
  102894. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  102895. * well as opacity information in the alpha channel.
  102896. */
  102897. baseTexture: BaseTexture;
  102898. /**
  102899. * Specifies the metallic scalar value of the material.
  102900. * Can also be used to scale the metalness values of the metallic texture.
  102901. */
  102902. metallic: number;
  102903. /**
  102904. * Specifies the roughness scalar value of the material.
  102905. * Can also be used to scale the roughness values of the metallic texture.
  102906. */
  102907. roughness: number;
  102908. /**
  102909. * Texture containing both the metallic value in the B channel and the
  102910. * roughness value in the G channel to keep better precision.
  102911. */
  102912. metallicRoughnessTexture: BaseTexture;
  102913. /**
  102914. * Instantiates a new PBRMetalRoughnessMaterial instance.
  102915. *
  102916. * @param name The material name
  102917. * @param scene The scene the material will be use in.
  102918. */
  102919. constructor(name: string, scene: Scene);
  102920. /**
  102921. * Return the currrent class name of the material.
  102922. */
  102923. getClassName(): string;
  102924. /**
  102925. * Makes a duplicate of the current material.
  102926. * @param name - name to use for the new material.
  102927. */
  102928. clone(name: string): PBRMetallicRoughnessMaterial;
  102929. /**
  102930. * Serialize the material to a parsable JSON object.
  102931. */
  102932. serialize(): any;
  102933. /**
  102934. * Parses a JSON object correponding to the serialize function.
  102935. */
  102936. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  102937. }
  102938. }
  102939. declare module BABYLON {
  102940. /**
  102941. * The PBR material of BJS following the specular glossiness convention.
  102942. *
  102943. * This fits to the PBR convention in the GLTF definition:
  102944. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  102945. */
  102946. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  102947. /**
  102948. * Specifies the diffuse color of the material.
  102949. */
  102950. diffuseColor: Color3;
  102951. /**
  102952. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  102953. * channel.
  102954. */
  102955. diffuseTexture: BaseTexture;
  102956. /**
  102957. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  102958. */
  102959. specularColor: Color3;
  102960. /**
  102961. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  102962. */
  102963. glossiness: number;
  102964. /**
  102965. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  102966. */
  102967. specularGlossinessTexture: BaseTexture;
  102968. /**
  102969. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  102970. *
  102971. * @param name The material name
  102972. * @param scene The scene the material will be use in.
  102973. */
  102974. constructor(name: string, scene: Scene);
  102975. /**
  102976. * Return the currrent class name of the material.
  102977. */
  102978. getClassName(): string;
  102979. /**
  102980. * Makes a duplicate of the current material.
  102981. * @param name - name to use for the new material.
  102982. */
  102983. clone(name: string): PBRSpecularGlossinessMaterial;
  102984. /**
  102985. * Serialize the material to a parsable JSON object.
  102986. */
  102987. serialize(): any;
  102988. /**
  102989. * Parses a JSON object correponding to the serialize function.
  102990. */
  102991. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  102992. }
  102993. }
  102994. declare module BABYLON {
  102995. /**
  102996. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  102997. * It can help converting any input color in a desired output one. This can then be used to create effects
  102998. * from sepia, black and white to sixties or futuristic rendering...
  102999. *
  103000. * The only supported format is currently 3dl.
  103001. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  103002. */
  103003. export class ColorGradingTexture extends BaseTexture {
  103004. /**
  103005. * The current texture matrix. (will always be identity in color grading texture)
  103006. */
  103007. private _textureMatrix;
  103008. /**
  103009. * The texture URL.
  103010. */
  103011. url: string;
  103012. /**
  103013. * Empty line regex stored for GC.
  103014. */
  103015. private static _noneEmptyLineRegex;
  103016. private _engine;
  103017. /**
  103018. * Instantiates a ColorGradingTexture from the following parameters.
  103019. *
  103020. * @param url The location of the color gradind data (currently only supporting 3dl)
  103021. * @param scene The scene the texture will be used in
  103022. */
  103023. constructor(url: string, scene: Scene);
  103024. /**
  103025. * Returns the texture matrix used in most of the material.
  103026. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  103027. */
  103028. getTextureMatrix(): Matrix;
  103029. /**
  103030. * Occurs when the file being loaded is a .3dl LUT file.
  103031. */
  103032. private load3dlTexture;
  103033. /**
  103034. * Starts the loading process of the texture.
  103035. */
  103036. private loadTexture;
  103037. /**
  103038. * Clones the color gradind texture.
  103039. */
  103040. clone(): ColorGradingTexture;
  103041. /**
  103042. * Called during delayed load for textures.
  103043. */
  103044. delayLoad(): void;
  103045. /**
  103046. * Parses a color grading texture serialized by Babylon.
  103047. * @param parsedTexture The texture information being parsedTexture
  103048. * @param scene The scene to load the texture in
  103049. * @param rootUrl The root url of the data assets to load
  103050. * @return A color gradind texture
  103051. */
  103052. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  103053. /**
  103054. * Serializes the LUT texture to json format.
  103055. */
  103056. serialize(): any;
  103057. }
  103058. }
  103059. declare module BABYLON {
  103060. /**
  103061. * Direct draw surface info
  103062. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  103063. */
  103064. export interface DDSInfo {
  103065. /**
  103066. * Width of the texture
  103067. */
  103068. width: number;
  103069. /**
  103070. * Width of the texture
  103071. */
  103072. height: number;
  103073. /**
  103074. * Number of Mipmaps for the texture
  103075. * @see https://en.wikipedia.org/wiki/Mipmap
  103076. */
  103077. mipmapCount: number;
  103078. /**
  103079. * If the textures format is a known fourCC format
  103080. * @see https://www.fourcc.org/
  103081. */
  103082. isFourCC: boolean;
  103083. /**
  103084. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  103085. */
  103086. isRGB: boolean;
  103087. /**
  103088. * If the texture is a lumincance format
  103089. */
  103090. isLuminance: boolean;
  103091. /**
  103092. * If this is a cube texture
  103093. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  103094. */
  103095. isCube: boolean;
  103096. /**
  103097. * If the texture is a compressed format eg. FOURCC_DXT1
  103098. */
  103099. isCompressed: boolean;
  103100. /**
  103101. * The dxgiFormat of the texture
  103102. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  103103. */
  103104. dxgiFormat: number;
  103105. /**
  103106. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  103107. */
  103108. textureType: number;
  103109. /**
  103110. * Sphericle polynomial created for the dds texture
  103111. */
  103112. sphericalPolynomial?: SphericalPolynomial;
  103113. }
  103114. /**
  103115. * Class used to provide DDS decompression tools
  103116. */
  103117. export class DDSTools {
  103118. /**
  103119. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  103120. */
  103121. static StoreLODInAlphaChannel: boolean;
  103122. /**
  103123. * Gets DDS information from an array buffer
  103124. * @param arrayBuffer defines the array buffer to read data from
  103125. * @returns the DDS information
  103126. */
  103127. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  103128. private static _FloatView;
  103129. private static _Int32View;
  103130. private static _ToHalfFloat;
  103131. private static _FromHalfFloat;
  103132. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  103133. private static _GetHalfFloatRGBAArrayBuffer;
  103134. private static _GetFloatRGBAArrayBuffer;
  103135. private static _GetFloatAsUIntRGBAArrayBuffer;
  103136. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  103137. private static _GetRGBAArrayBuffer;
  103138. private static _ExtractLongWordOrder;
  103139. private static _GetRGBArrayBuffer;
  103140. private static _GetLuminanceArrayBuffer;
  103141. /**
  103142. * Uploads DDS Levels to a Babylon Texture
  103143. * @hidden
  103144. */
  103145. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  103146. }
  103147. interface Engine {
  103148. /**
  103149. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  103150. * @param rootUrl defines the url where the file to load is located
  103151. * @param scene defines the current scene
  103152. * @param lodScale defines scale to apply to the mip map selection
  103153. * @param lodOffset defines offset to apply to the mip map selection
  103154. * @param onLoad defines an optional callback raised when the texture is loaded
  103155. * @param onError defines an optional callback raised if there is an issue to load the texture
  103156. * @param format defines the format of the data
  103157. * @param forcedExtension defines the extension to use to pick the right loader
  103158. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  103159. * @returns the cube texture as an InternalTexture
  103160. */
  103161. 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;
  103162. }
  103163. }
  103164. declare module BABYLON {
  103165. /**
  103166. * Implementation of the DDS Texture Loader.
  103167. * @hidden
  103168. */
  103169. export class _DDSTextureLoader implements IInternalTextureLoader {
  103170. /**
  103171. * Defines wether the loader supports cascade loading the different faces.
  103172. */
  103173. readonly supportCascades: boolean;
  103174. /**
  103175. * This returns if the loader support the current file information.
  103176. * @param extension defines the file extension of the file being loaded
  103177. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103178. * @param fallback defines the fallback internal texture if any
  103179. * @param isBase64 defines whether the texture is encoded as a base64
  103180. * @param isBuffer defines whether the texture data are stored as a buffer
  103181. * @returns true if the loader can load the specified file
  103182. */
  103183. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  103184. /**
  103185. * Transform the url before loading if required.
  103186. * @param rootUrl the url of the texture
  103187. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103188. * @returns the transformed texture
  103189. */
  103190. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  103191. /**
  103192. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  103193. * @param rootUrl the url of the texture
  103194. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103195. * @returns the fallback texture
  103196. */
  103197. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  103198. /**
  103199. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  103200. * @param data contains the texture data
  103201. * @param texture defines the BabylonJS internal texture
  103202. * @param createPolynomials will be true if polynomials have been requested
  103203. * @param onLoad defines the callback to trigger once the texture is ready
  103204. * @param onError defines the callback to trigger in case of error
  103205. */
  103206. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  103207. /**
  103208. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  103209. * @param data contains the texture data
  103210. * @param texture defines the BabylonJS internal texture
  103211. * @param callback defines the method to call once ready to upload
  103212. */
  103213. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  103214. }
  103215. }
  103216. declare module BABYLON {
  103217. /** @hidden */
  103218. export var rgbdEncodePixelShader: {
  103219. name: string;
  103220. shader: string;
  103221. };
  103222. }
  103223. declare module BABYLON {
  103224. /** @hidden */
  103225. export var rgbdDecodePixelShader: {
  103226. name: string;
  103227. shader: string;
  103228. };
  103229. }
  103230. declare module BABYLON {
  103231. /**
  103232. * Raw texture data and descriptor sufficient for WebGL texture upload
  103233. */
  103234. export interface EnvironmentTextureInfo {
  103235. /**
  103236. * Version of the environment map
  103237. */
  103238. version: number;
  103239. /**
  103240. * Width of image
  103241. */
  103242. width: number;
  103243. /**
  103244. * Irradiance information stored in the file.
  103245. */
  103246. irradiance: any;
  103247. /**
  103248. * Specular information stored in the file.
  103249. */
  103250. specular: any;
  103251. }
  103252. /**
  103253. * Sets of helpers addressing the serialization and deserialization of environment texture
  103254. * stored in a BabylonJS env file.
  103255. * Those files are usually stored as .env files.
  103256. */
  103257. export class EnvironmentTextureTools {
  103258. /**
  103259. * Magic number identifying the env file.
  103260. */
  103261. private static _MagicBytes;
  103262. /**
  103263. * Gets the environment info from an env file.
  103264. * @param data The array buffer containing the .env bytes.
  103265. * @returns the environment file info (the json header) if successfully parsed.
  103266. */
  103267. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  103268. /**
  103269. * Creates an environment texture from a loaded cube texture.
  103270. * @param texture defines the cube texture to convert in env file
  103271. * @return a promise containing the environment data if succesfull.
  103272. */
  103273. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  103274. /**
  103275. * Creates a JSON representation of the spherical data.
  103276. * @param texture defines the texture containing the polynomials
  103277. * @return the JSON representation of the spherical info
  103278. */
  103279. private static _CreateEnvTextureIrradiance;
  103280. /**
  103281. * Uploads the texture info contained in the env file to the GPU.
  103282. * @param texture defines the internal texture to upload to
  103283. * @param arrayBuffer defines the buffer cotaining the data to load
  103284. * @param info defines the texture info retrieved through the GetEnvInfo method
  103285. * @returns a promise
  103286. */
  103287. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  103288. /**
  103289. * Uploads the levels of image data to the GPU.
  103290. * @param texture defines the internal texture to upload to
  103291. * @param imageData defines the array buffer views of image data [mipmap][face]
  103292. * @returns a promise
  103293. */
  103294. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  103295. /**
  103296. * Uploads spherical polynomials information to the texture.
  103297. * @param texture defines the texture we are trying to upload the information to
  103298. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  103299. */
  103300. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  103301. /** @hidden */
  103302. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  103303. }
  103304. }
  103305. declare module BABYLON {
  103306. /**
  103307. * Implementation of the ENV Texture Loader.
  103308. * @hidden
  103309. */
  103310. export class _ENVTextureLoader implements IInternalTextureLoader {
  103311. /**
  103312. * Defines wether the loader supports cascade loading the different faces.
  103313. */
  103314. readonly supportCascades: boolean;
  103315. /**
  103316. * This returns if the loader support the current file information.
  103317. * @param extension defines the file extension of the file being loaded
  103318. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103319. * @param fallback defines the fallback internal texture if any
  103320. * @param isBase64 defines whether the texture is encoded as a base64
  103321. * @param isBuffer defines whether the texture data are stored as a buffer
  103322. * @returns true if the loader can load the specified file
  103323. */
  103324. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  103325. /**
  103326. * Transform the url before loading if required.
  103327. * @param rootUrl the url of the texture
  103328. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103329. * @returns the transformed texture
  103330. */
  103331. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  103332. /**
  103333. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  103334. * @param rootUrl the url of the texture
  103335. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103336. * @returns the fallback texture
  103337. */
  103338. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  103339. /**
  103340. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  103341. * @param data contains the texture data
  103342. * @param texture defines the BabylonJS internal texture
  103343. * @param createPolynomials will be true if polynomials have been requested
  103344. * @param onLoad defines the callback to trigger once the texture is ready
  103345. * @param onError defines the callback to trigger in case of error
  103346. */
  103347. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  103348. /**
  103349. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  103350. * @param data contains the texture data
  103351. * @param texture defines the BabylonJS internal texture
  103352. * @param callback defines the method to call once ready to upload
  103353. */
  103354. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  103355. }
  103356. }
  103357. declare module BABYLON {
  103358. /**
  103359. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  103360. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  103361. */
  103362. export class KhronosTextureContainer {
  103363. /** contents of the KTX container file */
  103364. arrayBuffer: any;
  103365. private static HEADER_LEN;
  103366. private static COMPRESSED_2D;
  103367. private static COMPRESSED_3D;
  103368. private static TEX_2D;
  103369. private static TEX_3D;
  103370. /**
  103371. * Gets the openGL type
  103372. */
  103373. glType: number;
  103374. /**
  103375. * Gets the openGL type size
  103376. */
  103377. glTypeSize: number;
  103378. /**
  103379. * Gets the openGL format
  103380. */
  103381. glFormat: number;
  103382. /**
  103383. * Gets the openGL internal format
  103384. */
  103385. glInternalFormat: number;
  103386. /**
  103387. * Gets the base internal format
  103388. */
  103389. glBaseInternalFormat: number;
  103390. /**
  103391. * Gets image width in pixel
  103392. */
  103393. pixelWidth: number;
  103394. /**
  103395. * Gets image height in pixel
  103396. */
  103397. pixelHeight: number;
  103398. /**
  103399. * Gets image depth in pixels
  103400. */
  103401. pixelDepth: number;
  103402. /**
  103403. * Gets the number of array elements
  103404. */
  103405. numberOfArrayElements: number;
  103406. /**
  103407. * Gets the number of faces
  103408. */
  103409. numberOfFaces: number;
  103410. /**
  103411. * Gets the number of mipmap levels
  103412. */
  103413. numberOfMipmapLevels: number;
  103414. /**
  103415. * Gets the bytes of key value data
  103416. */
  103417. bytesOfKeyValueData: number;
  103418. /**
  103419. * Gets the load type
  103420. */
  103421. loadType: number;
  103422. /**
  103423. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  103424. */
  103425. isInvalid: boolean;
  103426. /**
  103427. * Creates a new KhronosTextureContainer
  103428. * @param arrayBuffer contents of the KTX container file
  103429. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  103430. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  103431. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  103432. */
  103433. constructor(
  103434. /** contents of the KTX container file */
  103435. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  103436. /**
  103437. * Uploads KTX content to a Babylon Texture.
  103438. * It is assumed that the texture has already been created & is currently bound
  103439. * @hidden
  103440. */
  103441. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  103442. private _upload2DCompressedLevels;
  103443. }
  103444. }
  103445. declare module BABYLON {
  103446. /**
  103447. * Implementation of the KTX Texture Loader.
  103448. * @hidden
  103449. */
  103450. export class _KTXTextureLoader implements IInternalTextureLoader {
  103451. /**
  103452. * Defines wether the loader supports cascade loading the different faces.
  103453. */
  103454. readonly supportCascades: boolean;
  103455. /**
  103456. * This returns if the loader support the current file information.
  103457. * @param extension defines the file extension of the file being loaded
  103458. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103459. * @param fallback defines the fallback internal texture if any
  103460. * @param isBase64 defines whether the texture is encoded as a base64
  103461. * @param isBuffer defines whether the texture data are stored as a buffer
  103462. * @returns true if the loader can load the specified file
  103463. */
  103464. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  103465. /**
  103466. * Transform the url before loading if required.
  103467. * @param rootUrl the url of the texture
  103468. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103469. * @returns the transformed texture
  103470. */
  103471. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  103472. /**
  103473. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  103474. * @param rootUrl the url of the texture
  103475. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103476. * @returns the fallback texture
  103477. */
  103478. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  103479. /**
  103480. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  103481. * @param data contains the texture data
  103482. * @param texture defines the BabylonJS internal texture
  103483. * @param createPolynomials will be true if polynomials have been requested
  103484. * @param onLoad defines the callback to trigger once the texture is ready
  103485. * @param onError defines the callback to trigger in case of error
  103486. */
  103487. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  103488. /**
  103489. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  103490. * @param data contains the texture data
  103491. * @param texture defines the BabylonJS internal texture
  103492. * @param callback defines the method to call once ready to upload
  103493. */
  103494. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  103495. }
  103496. }
  103497. declare module BABYLON {
  103498. /**
  103499. * Based on jsTGALoader - Javascript loader for TGA file
  103500. * By Vincent Thibault
  103501. * @see http://blog.robrowser.com/javascript-tga-loader.html
  103502. */
  103503. export class TGATools {
  103504. private static _TYPE_INDEXED;
  103505. private static _TYPE_RGB;
  103506. private static _TYPE_GREY;
  103507. private static _TYPE_RLE_INDEXED;
  103508. private static _TYPE_RLE_RGB;
  103509. private static _TYPE_RLE_GREY;
  103510. private static _ORIGIN_MASK;
  103511. private static _ORIGIN_SHIFT;
  103512. private static _ORIGIN_BL;
  103513. private static _ORIGIN_BR;
  103514. private static _ORIGIN_UL;
  103515. private static _ORIGIN_UR;
  103516. /**
  103517. * Gets the header of a TGA file
  103518. * @param data defines the TGA data
  103519. * @returns the header
  103520. */
  103521. static GetTGAHeader(data: Uint8Array): any;
  103522. /**
  103523. * Uploads TGA content to a Babylon Texture
  103524. * @hidden
  103525. */
  103526. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  103527. /** @hidden */
  103528. 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;
  103529. /** @hidden */
  103530. 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;
  103531. /** @hidden */
  103532. 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;
  103533. /** @hidden */
  103534. 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;
  103535. /** @hidden */
  103536. 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;
  103537. /** @hidden */
  103538. 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;
  103539. }
  103540. }
  103541. declare module BABYLON {
  103542. /**
  103543. * Implementation of the TGA Texture Loader.
  103544. * @hidden
  103545. */
  103546. export class _TGATextureLoader implements IInternalTextureLoader {
  103547. /**
  103548. * Defines wether the loader supports cascade loading the different faces.
  103549. */
  103550. readonly supportCascades: boolean;
  103551. /**
  103552. * This returns if the loader support the current file information.
  103553. * @param extension defines the file extension of the file being loaded
  103554. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103555. * @param fallback defines the fallback internal texture if any
  103556. * @param isBase64 defines whether the texture is encoded as a base64
  103557. * @param isBuffer defines whether the texture data are stored as a buffer
  103558. * @returns true if the loader can load the specified file
  103559. */
  103560. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  103561. /**
  103562. * Transform the url before loading if required.
  103563. * @param rootUrl the url of the texture
  103564. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103565. * @returns the transformed texture
  103566. */
  103567. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  103568. /**
  103569. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  103570. * @param rootUrl the url of the texture
  103571. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103572. * @returns the fallback texture
  103573. */
  103574. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  103575. /**
  103576. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  103577. * @param data contains the texture data
  103578. * @param texture defines the BabylonJS internal texture
  103579. * @param createPolynomials will be true if polynomials have been requested
  103580. * @param onLoad defines the callback to trigger once the texture is ready
  103581. * @param onError defines the callback to trigger in case of error
  103582. */
  103583. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  103584. /**
  103585. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  103586. * @param data contains the texture data
  103587. * @param texture defines the BabylonJS internal texture
  103588. * @param callback defines the method to call once ready to upload
  103589. */
  103590. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  103591. }
  103592. }
  103593. declare module BABYLON {
  103594. /**
  103595. * 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.
  103596. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  103597. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  103598. */
  103599. export class CustomProceduralTexture extends ProceduralTexture {
  103600. private _animate;
  103601. private _time;
  103602. private _config;
  103603. private _texturePath;
  103604. /**
  103605. * Instantiates a new Custom Procedural Texture.
  103606. * 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.
  103607. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  103608. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  103609. * @param name Define the name of the texture
  103610. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  103611. * @param size Define the size of the texture to create
  103612. * @param scene Define the scene the texture belongs to
  103613. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  103614. * @param generateMipMaps Define if the texture should creates mip maps or not
  103615. */
  103616. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  103617. private _loadJson;
  103618. /**
  103619. * Is the texture ready to be used ? (rendered at least once)
  103620. * @returns true if ready, otherwise, false.
  103621. */
  103622. isReady(): boolean;
  103623. /**
  103624. * Render the texture to its associated render target.
  103625. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  103626. */
  103627. render(useCameraPostProcess?: boolean): void;
  103628. /**
  103629. * Update the list of dependant textures samplers in the shader.
  103630. */
  103631. updateTextures(): void;
  103632. /**
  103633. * Update the uniform values of the procedural texture in the shader.
  103634. */
  103635. updateShaderUniforms(): void;
  103636. /**
  103637. * Define if the texture animates or not.
  103638. */
  103639. animate: boolean;
  103640. }
  103641. }
  103642. declare module BABYLON {
  103643. /** @hidden */
  103644. export var noisePixelShader: {
  103645. name: string;
  103646. shader: string;
  103647. };
  103648. }
  103649. declare module BABYLON {
  103650. /**
  103651. * Class used to generate noise procedural textures
  103652. */
  103653. export class NoiseProceduralTexture extends ProceduralTexture {
  103654. private _time;
  103655. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  103656. brightness: number;
  103657. /** Defines the number of octaves to process */
  103658. octaves: number;
  103659. /** Defines the level of persistence (0.8 by default) */
  103660. persistence: number;
  103661. /** Gets or sets animation speed factor (default is 1) */
  103662. animationSpeedFactor: number;
  103663. /**
  103664. * Creates a new NoiseProceduralTexture
  103665. * @param name defines the name fo the texture
  103666. * @param size defines the size of the texture (default is 256)
  103667. * @param scene defines the hosting scene
  103668. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  103669. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  103670. */
  103671. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  103672. private _updateShaderUniforms;
  103673. protected _getDefines(): string;
  103674. /** Generate the current state of the procedural texture */
  103675. render(useCameraPostProcess?: boolean): void;
  103676. /**
  103677. * Serializes this noise procedural texture
  103678. * @returns a serialized noise procedural texture object
  103679. */
  103680. serialize(): any;
  103681. /**
  103682. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  103683. * @param parsedTexture defines parsed texture data
  103684. * @param scene defines the current scene
  103685. * @param rootUrl defines the root URL containing noise procedural texture information
  103686. * @returns a parsed NoiseProceduralTexture
  103687. */
  103688. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  103689. }
  103690. }
  103691. declare module BABYLON {
  103692. /**
  103693. * Raw cube texture where the raw buffers are passed in
  103694. */
  103695. export class RawCubeTexture extends CubeTexture {
  103696. /**
  103697. * Creates a cube texture where the raw buffers are passed in.
  103698. * @param scene defines the scene the texture is attached to
  103699. * @param data defines the array of data to use to create each face
  103700. * @param size defines the size of the textures
  103701. * @param format defines the format of the data
  103702. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  103703. * @param generateMipMaps defines if the engine should generate the mip levels
  103704. * @param invertY defines if data must be stored with Y axis inverted
  103705. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  103706. * @param compression defines the compression used (null by default)
  103707. */
  103708. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  103709. /**
  103710. * Updates the raw cube texture.
  103711. * @param data defines the data to store
  103712. * @param format defines the data format
  103713. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  103714. * @param invertY defines if data must be stored with Y axis inverted
  103715. * @param compression defines the compression used (null by default)
  103716. * @param level defines which level of the texture to update
  103717. */
  103718. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  103719. /**
  103720. * Updates a raw cube texture with RGBD encoded data.
  103721. * @param data defines the array of data [mipmap][face] to use to create each face
  103722. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  103723. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  103724. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  103725. * @returns a promsie that resolves when the operation is complete
  103726. */
  103727. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  103728. /**
  103729. * Clones the raw cube texture.
  103730. * @return a new cube texture
  103731. */
  103732. clone(): CubeTexture;
  103733. /** @hidden */
  103734. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  103735. }
  103736. }
  103737. declare module BABYLON {
  103738. /**
  103739. * Class used to store 3D textures containing user data
  103740. */
  103741. export class RawTexture3D extends Texture {
  103742. /** Gets or sets the texture format to use */
  103743. format: number;
  103744. private _engine;
  103745. /**
  103746. * Create a new RawTexture3D
  103747. * @param data defines the data of the texture
  103748. * @param width defines the width of the texture
  103749. * @param height defines the height of the texture
  103750. * @param depth defines the depth of the texture
  103751. * @param format defines the texture format to use
  103752. * @param scene defines the hosting scene
  103753. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  103754. * @param invertY defines if texture must be stored with Y axis inverted
  103755. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  103756. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  103757. */
  103758. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  103759. /** Gets or sets the texture format to use */
  103760. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  103761. /**
  103762. * Update the texture with new data
  103763. * @param data defines the data to store in the texture
  103764. */
  103765. update(data: ArrayBufferView): void;
  103766. }
  103767. }
  103768. declare module BABYLON {
  103769. /**
  103770. * Creates a refraction texture used by refraction channel of the standard material.
  103771. * It is like a mirror but to see through a material.
  103772. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  103773. */
  103774. export class RefractionTexture extends RenderTargetTexture {
  103775. /**
  103776. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  103777. * 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.
  103778. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  103779. */
  103780. refractionPlane: Plane;
  103781. /**
  103782. * Define how deep under the surface we should see.
  103783. */
  103784. depth: number;
  103785. /**
  103786. * Creates a refraction texture used by refraction channel of the standard material.
  103787. * It is like a mirror but to see through a material.
  103788. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  103789. * @param name Define the texture name
  103790. * @param size Define the size of the underlying texture
  103791. * @param scene Define the scene the refraction belongs to
  103792. * @param generateMipMaps Define if we need to generate mips level for the refraction
  103793. */
  103794. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  103795. /**
  103796. * Clone the refraction texture.
  103797. * @returns the cloned texture
  103798. */
  103799. clone(): RefractionTexture;
  103800. /**
  103801. * Serialize the texture to a JSON representation you could use in Parse later on
  103802. * @returns the serialized JSON representation
  103803. */
  103804. serialize(): any;
  103805. }
  103806. }
  103807. declare module BABYLON {
  103808. /**
  103809. * Configuration for Draco compression
  103810. */
  103811. export interface IDracoCompressionConfiguration {
  103812. /**
  103813. * Configuration for the decoder.
  103814. */
  103815. decoder?: {
  103816. /**
  103817. * The url to the WebAssembly module.
  103818. */
  103819. wasmUrl?: string;
  103820. /**
  103821. * The url to the WebAssembly binary.
  103822. */
  103823. wasmBinaryUrl?: string;
  103824. /**
  103825. * The url to the fallback JavaScript module.
  103826. */
  103827. fallbackUrl?: string;
  103828. };
  103829. }
  103830. /**
  103831. * Draco compression (https://google.github.io/draco/)
  103832. *
  103833. * This class wraps the Draco module.
  103834. *
  103835. * **Encoder**
  103836. *
  103837. * The encoder is not currently implemented.
  103838. *
  103839. * **Decoder**
  103840. *
  103841. * 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.
  103842. *
  103843. * To update the configuration, use the following code:
  103844. * ```javascript
  103845. * DracoCompression.Configuration = {
  103846. * decoder: {
  103847. * wasmUrl: "<url to the WebAssembly library>",
  103848. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  103849. * fallbackUrl: "<url to the fallback JavaScript library>",
  103850. * }
  103851. * };
  103852. * ```
  103853. *
  103854. * 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.
  103855. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  103856. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  103857. *
  103858. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  103859. * ```javascript
  103860. * var dracoCompression = new DracoCompression();
  103861. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  103862. * [VertexBuffer.PositionKind]: 0
  103863. * });
  103864. * ```
  103865. *
  103866. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  103867. */
  103868. export class DracoCompression implements IDisposable {
  103869. private static _DecoderModulePromise;
  103870. /**
  103871. * The configuration. Defaults to the following urls:
  103872. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  103873. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  103874. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  103875. */
  103876. static Configuration: IDracoCompressionConfiguration;
  103877. /**
  103878. * Returns true if the decoder is available.
  103879. */
  103880. static readonly DecoderAvailable: boolean;
  103881. /**
  103882. * Constructor
  103883. */
  103884. constructor();
  103885. /**
  103886. * Stop all async operations and release resources.
  103887. */
  103888. dispose(): void;
  103889. /**
  103890. * Decode Draco compressed mesh data to vertex data.
  103891. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  103892. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  103893. * @returns A promise that resolves with the decoded vertex data
  103894. */
  103895. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  103896. [kind: string]: number;
  103897. }): Promise<VertexData>;
  103898. private static _GetDecoderModule;
  103899. private static _LoadScriptAsync;
  103900. private static _LoadFileAsync;
  103901. }
  103902. }
  103903. declare module BABYLON {
  103904. /**
  103905. * Class for building Constructive Solid Geometry
  103906. */
  103907. export class CSG {
  103908. private polygons;
  103909. /**
  103910. * The world matrix
  103911. */
  103912. matrix: Matrix;
  103913. /**
  103914. * Stores the position
  103915. */
  103916. position: Vector3;
  103917. /**
  103918. * Stores the rotation
  103919. */
  103920. rotation: Vector3;
  103921. /**
  103922. * Stores the rotation quaternion
  103923. */
  103924. rotationQuaternion: Nullable<Quaternion>;
  103925. /**
  103926. * Stores the scaling vector
  103927. */
  103928. scaling: Vector3;
  103929. /**
  103930. * Convert the Mesh to CSG
  103931. * @param mesh The Mesh to convert to CSG
  103932. * @returns A new CSG from the Mesh
  103933. */
  103934. static FromMesh(mesh: Mesh): CSG;
  103935. /**
  103936. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  103937. * @param polygons Polygons used to construct a CSG solid
  103938. */
  103939. private static FromPolygons;
  103940. /**
  103941. * Clones, or makes a deep copy, of the CSG
  103942. * @returns A new CSG
  103943. */
  103944. clone(): CSG;
  103945. /**
  103946. * Unions this CSG with another CSG
  103947. * @param csg The CSG to union against this CSG
  103948. * @returns The unioned CSG
  103949. */
  103950. union(csg: CSG): CSG;
  103951. /**
  103952. * Unions this CSG with another CSG in place
  103953. * @param csg The CSG to union against this CSG
  103954. */
  103955. unionInPlace(csg: CSG): void;
  103956. /**
  103957. * Subtracts this CSG with another CSG
  103958. * @param csg The CSG to subtract against this CSG
  103959. * @returns A new CSG
  103960. */
  103961. subtract(csg: CSG): CSG;
  103962. /**
  103963. * Subtracts this CSG with another CSG in place
  103964. * @param csg The CSG to subtact against this CSG
  103965. */
  103966. subtractInPlace(csg: CSG): void;
  103967. /**
  103968. * Intersect this CSG with another CSG
  103969. * @param csg The CSG to intersect against this CSG
  103970. * @returns A new CSG
  103971. */
  103972. intersect(csg: CSG): CSG;
  103973. /**
  103974. * Intersects this CSG with another CSG in place
  103975. * @param csg The CSG to intersect against this CSG
  103976. */
  103977. intersectInPlace(csg: CSG): void;
  103978. /**
  103979. * Return a new CSG solid with solid and empty space switched. This solid is
  103980. * not modified.
  103981. * @returns A new CSG solid with solid and empty space switched
  103982. */
  103983. inverse(): CSG;
  103984. /**
  103985. * Inverses the CSG in place
  103986. */
  103987. inverseInPlace(): void;
  103988. /**
  103989. * This is used to keep meshes transformations so they can be restored
  103990. * when we build back a Babylon Mesh
  103991. * NB : All CSG operations are performed in world coordinates
  103992. * @param csg The CSG to copy the transform attributes from
  103993. * @returns This CSG
  103994. */
  103995. copyTransformAttributes(csg: CSG): CSG;
  103996. /**
  103997. * Build Raw mesh from CSG
  103998. * Coordinates here are in world space
  103999. * @param name The name of the mesh geometry
  104000. * @param scene The Scene
  104001. * @param keepSubMeshes Specifies if the submeshes should be kept
  104002. * @returns A new Mesh
  104003. */
  104004. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  104005. /**
  104006. * Build Mesh from CSG taking material and transforms into account
  104007. * @param name The name of the Mesh
  104008. * @param material The material of the Mesh
  104009. * @param scene The Scene
  104010. * @param keepSubMeshes Specifies if submeshes should be kept
  104011. * @returns The new Mesh
  104012. */
  104013. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  104014. }
  104015. }
  104016. declare module BABYLON {
  104017. /**
  104018. * Class used to create a trail following a mesh
  104019. */
  104020. export class TrailMesh extends Mesh {
  104021. private _generator;
  104022. private _autoStart;
  104023. private _running;
  104024. private _diameter;
  104025. private _length;
  104026. private _sectionPolygonPointsCount;
  104027. private _sectionVectors;
  104028. private _sectionNormalVectors;
  104029. private _beforeRenderObserver;
  104030. /**
  104031. * @constructor
  104032. * @param name The value used by scene.getMeshByName() to do a lookup.
  104033. * @param generator The mesh to generate a trail.
  104034. * @param scene The scene to add this mesh to.
  104035. * @param diameter Diameter of trailing mesh. Default is 1.
  104036. * @param length Length of trailing mesh. Default is 60.
  104037. * @param autoStart Automatically start trailing mesh. Default true.
  104038. */
  104039. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  104040. /**
  104041. * "TrailMesh"
  104042. * @returns "TrailMesh"
  104043. */
  104044. getClassName(): string;
  104045. private _createMesh;
  104046. /**
  104047. * Start trailing mesh.
  104048. */
  104049. start(): void;
  104050. /**
  104051. * Stop trailing mesh.
  104052. */
  104053. stop(): void;
  104054. /**
  104055. * Update trailing mesh geometry.
  104056. */
  104057. update(): void;
  104058. /**
  104059. * Returns a new TrailMesh object.
  104060. * @param name is a string, the name given to the new mesh
  104061. * @param newGenerator use new generator object for cloned trail mesh
  104062. * @returns a new mesh
  104063. */
  104064. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  104065. /**
  104066. * Serializes this trail mesh
  104067. * @param serializationObject object to write serialization to
  104068. */
  104069. serialize(serializationObject: any): void;
  104070. /**
  104071. * Parses a serialized trail mesh
  104072. * @param parsedMesh the serialized mesh
  104073. * @param scene the scene to create the trail mesh in
  104074. * @returns the created trail mesh
  104075. */
  104076. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  104077. }
  104078. }
  104079. declare module BABYLON {
  104080. /**
  104081. * Class containing static functions to help procedurally build meshes
  104082. */
  104083. export class RibbonBuilder {
  104084. /**
  104085. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  104086. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  104087. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  104088. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  104089. * * 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
  104090. * * 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
  104091. * * 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
  104092. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104093. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104094. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  104095. * * 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
  104096. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  104097. * * 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
  104098. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  104099. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104100. * @param name defines the name of the mesh
  104101. * @param options defines the options used to create the mesh
  104102. * @param scene defines the hosting scene
  104103. * @returns the ribbon mesh
  104104. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  104105. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  104106. */
  104107. static CreateRibbon(name: string, options: {
  104108. pathArray: Vector3[][];
  104109. closeArray?: boolean;
  104110. closePath?: boolean;
  104111. offset?: number;
  104112. updatable?: boolean;
  104113. sideOrientation?: number;
  104114. frontUVs?: Vector4;
  104115. backUVs?: Vector4;
  104116. instance?: Mesh;
  104117. invertUV?: boolean;
  104118. uvs?: Vector2[];
  104119. colors?: Color4[];
  104120. }, scene?: Nullable<Scene>): Mesh;
  104121. }
  104122. }
  104123. declare module BABYLON {
  104124. /**
  104125. * Class containing static functions to help procedurally build meshes
  104126. */
  104127. export class TorusKnotBuilder {
  104128. /**
  104129. * Creates a torus knot mesh
  104130. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  104131. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  104132. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  104133. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  104134. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104135. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104136. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104137. * @param name defines the name of the mesh
  104138. * @param options defines the options used to create the mesh
  104139. * @param scene defines the hosting scene
  104140. * @returns the torus knot mesh
  104141. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  104142. */
  104143. static CreateTorusKnot(name: string, options: {
  104144. radius?: number;
  104145. tube?: number;
  104146. radialSegments?: number;
  104147. tubularSegments?: number;
  104148. p?: number;
  104149. q?: number;
  104150. updatable?: boolean;
  104151. sideOrientation?: number;
  104152. frontUVs?: Vector4;
  104153. backUVs?: Vector4;
  104154. }, scene: any): Mesh;
  104155. }
  104156. }
  104157. declare module BABYLON {
  104158. /**
  104159. * Polygon
  104160. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  104161. */
  104162. export class Polygon {
  104163. /**
  104164. * Creates a rectangle
  104165. * @param xmin bottom X coord
  104166. * @param ymin bottom Y coord
  104167. * @param xmax top X coord
  104168. * @param ymax top Y coord
  104169. * @returns points that make the resulting rectation
  104170. */
  104171. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  104172. /**
  104173. * Creates a circle
  104174. * @param radius radius of circle
  104175. * @param cx scale in x
  104176. * @param cy scale in y
  104177. * @param numberOfSides number of sides that make up the circle
  104178. * @returns points that make the resulting circle
  104179. */
  104180. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  104181. /**
  104182. * Creates a polygon from input string
  104183. * @param input Input polygon data
  104184. * @returns the parsed points
  104185. */
  104186. static Parse(input: string): Vector2[];
  104187. /**
  104188. * Starts building a polygon from x and y coordinates
  104189. * @param x x coordinate
  104190. * @param y y coordinate
  104191. * @returns the started path2
  104192. */
  104193. static StartingAt(x: number, y: number): Path2;
  104194. }
  104195. /**
  104196. * Builds a polygon
  104197. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  104198. */
  104199. export class PolygonMeshBuilder {
  104200. private _points;
  104201. private _outlinepoints;
  104202. private _holes;
  104203. private _name;
  104204. private _scene;
  104205. private _epoints;
  104206. private _eholes;
  104207. private _addToepoint;
  104208. /**
  104209. * Babylon reference to the earcut plugin.
  104210. */
  104211. bjsEarcut: any;
  104212. /**
  104213. * Creates a PolygonMeshBuilder
  104214. * @param name name of the builder
  104215. * @param contours Path of the polygon
  104216. * @param scene scene to add to
  104217. * @param earcutInjection can be used to inject your own earcut reference
  104218. */
  104219. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  104220. /**
  104221. * Adds a whole within the polygon
  104222. * @param hole Array of points defining the hole
  104223. * @returns this
  104224. */
  104225. addHole(hole: Vector2[]): PolygonMeshBuilder;
  104226. /**
  104227. * Creates the polygon
  104228. * @param updatable If the mesh should be updatable
  104229. * @param depth The depth of the mesh created
  104230. * @returns the created mesh
  104231. */
  104232. build(updatable?: boolean, depth?: number): Mesh;
  104233. /**
  104234. * Adds a side to the polygon
  104235. * @param positions points that make the polygon
  104236. * @param normals normals of the polygon
  104237. * @param uvs uvs of the polygon
  104238. * @param indices indices of the polygon
  104239. * @param bounds bounds of the polygon
  104240. * @param points points of the polygon
  104241. * @param depth depth of the polygon
  104242. * @param flip flip of the polygon
  104243. */
  104244. private addSide;
  104245. }
  104246. }
  104247. declare module BABYLON {
  104248. /**
  104249. * Class containing static functions to help procedurally build meshes
  104250. */
  104251. export class PolygonBuilder {
  104252. /**
  104253. * Creates a polygon mesh
  104254. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  104255. * * 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
  104256. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104257. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104258. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  104259. * * Remember you can only change the shape positions, not their number when updating a polygon
  104260. * @param name defines the name of the mesh
  104261. * @param options defines the options used to create the mesh
  104262. * @param scene defines the hosting scene
  104263. * @param earcutInjection can be used to inject your own earcut reference
  104264. * @returns the polygon mesh
  104265. */
  104266. static CreatePolygon(name: string, options: {
  104267. shape: Vector3[];
  104268. holes?: Vector3[][];
  104269. depth?: number;
  104270. faceUV?: Vector4[];
  104271. faceColors?: Color4[];
  104272. updatable?: boolean;
  104273. sideOrientation?: number;
  104274. frontUVs?: Vector4;
  104275. backUVs?: Vector4;
  104276. }, scene: Scene, earcutInjection?: any): Mesh;
  104277. /**
  104278. * Creates an extruded polygon mesh, with depth in the Y direction.
  104279. * * 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)
  104280. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  104281. * @param name defines the name of the mesh
  104282. * @param options defines the options used to create the mesh
  104283. * @param scene defines the hosting scene
  104284. * @param earcutInjection can be used to inject your own earcut reference
  104285. * @returns the polygon mesh
  104286. */
  104287. static ExtrudePolygon(name: string, options: {
  104288. shape: Vector3[];
  104289. holes?: Vector3[][];
  104290. depth?: number;
  104291. faceUV?: Vector4[];
  104292. faceColors?: Color4[];
  104293. updatable?: boolean;
  104294. sideOrientation?: number;
  104295. frontUVs?: Vector4;
  104296. backUVs?: Vector4;
  104297. }, scene: Scene, earcutInjection?: any): Mesh;
  104298. }
  104299. }
  104300. declare module BABYLON {
  104301. /**
  104302. * Class containing static functions to help procedurally build meshes
  104303. */
  104304. export class ShapeBuilder {
  104305. /**
  104306. * 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.
  104307. * * 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.
  104308. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  104309. * * 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.
  104310. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  104311. * * 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
  104312. * * 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
  104313. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  104314. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104315. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104316. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  104317. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104318. * @param name defines the name of the mesh
  104319. * @param options defines the options used to create the mesh
  104320. * @param scene defines the hosting scene
  104321. * @returns the extruded shape mesh
  104322. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  104323. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  104324. */
  104325. static ExtrudeShape(name: string, options: {
  104326. shape: Vector3[];
  104327. path: Vector3[];
  104328. scale?: number;
  104329. rotation?: number;
  104330. cap?: number;
  104331. updatable?: boolean;
  104332. sideOrientation?: number;
  104333. frontUVs?: Vector4;
  104334. backUVs?: Vector4;
  104335. instance?: Mesh;
  104336. invertUV?: boolean;
  104337. }, scene?: Nullable<Scene>): Mesh;
  104338. /**
  104339. * Creates an custom extruded shape mesh.
  104340. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  104341. * * 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.
  104342. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  104343. * * 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
  104344. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  104345. * * 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
  104346. * * It must returns a float value that will be the scale value applied to the shape on each path point
  104347. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  104348. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  104349. * * 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
  104350. * * 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
  104351. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  104352. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104353. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104354. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  104355. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104356. * @param name defines the name of the mesh
  104357. * @param options defines the options used to create the mesh
  104358. * @param scene defines the hosting scene
  104359. * @returns the custom extruded shape mesh
  104360. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  104361. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  104362. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  104363. */
  104364. static ExtrudeShapeCustom(name: string, options: {
  104365. shape: Vector3[];
  104366. path: Vector3[];
  104367. scaleFunction?: any;
  104368. rotationFunction?: any;
  104369. ribbonCloseArray?: boolean;
  104370. ribbonClosePath?: boolean;
  104371. cap?: number;
  104372. updatable?: boolean;
  104373. sideOrientation?: number;
  104374. frontUVs?: Vector4;
  104375. backUVs?: Vector4;
  104376. instance?: Mesh;
  104377. invertUV?: boolean;
  104378. }, scene: Scene): Mesh;
  104379. private static _ExtrudeShapeGeneric;
  104380. }
  104381. }
  104382. declare module BABYLON {
  104383. /**
  104384. * Class containing static functions to help procedurally build meshes
  104385. */
  104386. export class LatheBuilder {
  104387. /**
  104388. * Creates lathe mesh.
  104389. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  104390. * * 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
  104391. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  104392. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  104393. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  104394. * * 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
  104395. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  104396. * * 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
  104397. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104398. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104399. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  104400. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104401. * @param name defines the name of the mesh
  104402. * @param options defines the options used to create the mesh
  104403. * @param scene defines the hosting scene
  104404. * @returns the lathe mesh
  104405. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  104406. */
  104407. static CreateLathe(name: string, options: {
  104408. shape: Vector3[];
  104409. radius?: number;
  104410. tessellation?: number;
  104411. clip?: number;
  104412. arc?: number;
  104413. closed?: boolean;
  104414. updatable?: boolean;
  104415. sideOrientation?: number;
  104416. frontUVs?: Vector4;
  104417. backUVs?: Vector4;
  104418. cap?: number;
  104419. invertUV?: boolean;
  104420. }, scene: Scene): Mesh;
  104421. }
  104422. }
  104423. declare module BABYLON {
  104424. /**
  104425. * Class containing static functions to help procedurally build meshes
  104426. */
  104427. export class TubeBuilder {
  104428. /**
  104429. * Creates a tube mesh.
  104430. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  104431. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  104432. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  104433. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  104434. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  104435. * * 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)
  104436. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  104437. * * 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
  104438. * * 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
  104439. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104440. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104441. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  104442. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104443. * @param name defines the name of the mesh
  104444. * @param options defines the options used to create the mesh
  104445. * @param scene defines the hosting scene
  104446. * @returns the tube mesh
  104447. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  104448. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  104449. */
  104450. static CreateTube(name: string, options: {
  104451. path: Vector3[];
  104452. radius?: number;
  104453. tessellation?: number;
  104454. radiusFunction?: {
  104455. (i: number, distance: number): number;
  104456. };
  104457. cap?: number;
  104458. arc?: number;
  104459. updatable?: boolean;
  104460. sideOrientation?: number;
  104461. frontUVs?: Vector4;
  104462. backUVs?: Vector4;
  104463. instance?: Mesh;
  104464. invertUV?: boolean;
  104465. }, scene: Scene): Mesh;
  104466. }
  104467. }
  104468. declare module BABYLON {
  104469. /**
  104470. * Class containing static functions to help procedurally build meshes
  104471. */
  104472. export class IcoSphereBuilder {
  104473. /**
  104474. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  104475. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  104476. * * 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`)
  104477. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  104478. * * 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
  104479. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104480. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104481. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104482. * @param name defines the name of the mesh
  104483. * @param options defines the options used to create the mesh
  104484. * @param scene defines the hosting scene
  104485. * @returns the icosahedron mesh
  104486. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  104487. */
  104488. static CreateIcoSphere(name: string, options: {
  104489. radius?: number;
  104490. radiusX?: number;
  104491. radiusY?: number;
  104492. radiusZ?: number;
  104493. flat?: boolean;
  104494. subdivisions?: number;
  104495. sideOrientation?: number;
  104496. frontUVs?: Vector4;
  104497. backUVs?: Vector4;
  104498. updatable?: boolean;
  104499. }, scene: Scene): Mesh;
  104500. }
  104501. }
  104502. declare module BABYLON {
  104503. /**
  104504. * Class containing static functions to help procedurally build meshes
  104505. */
  104506. export class DecalBuilder {
  104507. /**
  104508. * Creates a decal mesh.
  104509. * 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
  104510. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  104511. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  104512. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  104513. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  104514. * @param name defines the name of the mesh
  104515. * @param sourceMesh defines the mesh where the decal must be applied
  104516. * @param options defines the options used to create the mesh
  104517. * @param scene defines the hosting scene
  104518. * @returns the decal mesh
  104519. * @see https://doc.babylonjs.com/how_to/decals
  104520. */
  104521. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  104522. position?: Vector3;
  104523. normal?: Vector3;
  104524. size?: Vector3;
  104525. angle?: number;
  104526. }): Mesh;
  104527. }
  104528. }
  104529. declare module BABYLON {
  104530. /**
  104531. * Class containing static functions to help procedurally build meshes
  104532. */
  104533. export class MeshBuilder {
  104534. /**
  104535. * Creates a box mesh
  104536. * * The parameter `size` sets the size (float) of each box side (default 1)
  104537. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  104538. * * 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)
  104539. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  104540. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104541. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104542. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104543. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  104544. * @param name defines the name of the mesh
  104545. * @param options defines the options used to create the mesh
  104546. * @param scene defines the hosting scene
  104547. * @returns the box mesh
  104548. */
  104549. static CreateBox(name: string, options: {
  104550. size?: number;
  104551. width?: number;
  104552. height?: number;
  104553. depth?: number;
  104554. faceUV?: Vector4[];
  104555. faceColors?: Color4[];
  104556. sideOrientation?: number;
  104557. frontUVs?: Vector4;
  104558. backUVs?: Vector4;
  104559. updatable?: boolean;
  104560. }, scene?: Nullable<Scene>): Mesh;
  104561. /**
  104562. * Creates a sphere mesh
  104563. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  104564. * * 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`)
  104565. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  104566. * * 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
  104567. * * 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)
  104568. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104569. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104570. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104571. * @param name defines the name of the mesh
  104572. * @param options defines the options used to create the mesh
  104573. * @param scene defines the hosting scene
  104574. * @returns the sphere mesh
  104575. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  104576. */
  104577. static CreateSphere(name: string, options: {
  104578. segments?: number;
  104579. diameter?: number;
  104580. diameterX?: number;
  104581. diameterY?: number;
  104582. diameterZ?: number;
  104583. arc?: number;
  104584. slice?: number;
  104585. sideOrientation?: number;
  104586. frontUVs?: Vector4;
  104587. backUVs?: Vector4;
  104588. updatable?: boolean;
  104589. }, scene: any): Mesh;
  104590. /**
  104591. * Creates a plane polygonal mesh. By default, this is a disc
  104592. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  104593. * * 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
  104594. * * 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
  104595. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104596. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104597. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104598. * @param name defines the name of the mesh
  104599. * @param options defines the options used to create the mesh
  104600. * @param scene defines the hosting scene
  104601. * @returns the plane polygonal mesh
  104602. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  104603. */
  104604. static CreateDisc(name: string, options: {
  104605. radius?: number;
  104606. tessellation?: number;
  104607. arc?: number;
  104608. updatable?: boolean;
  104609. sideOrientation?: number;
  104610. frontUVs?: Vector4;
  104611. backUVs?: Vector4;
  104612. }, scene?: Nullable<Scene>): Mesh;
  104613. /**
  104614. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  104615. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  104616. * * 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`)
  104617. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  104618. * * 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
  104619. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104620. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104621. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104622. * @param name defines the name of the mesh
  104623. * @param options defines the options used to create the mesh
  104624. * @param scene defines the hosting scene
  104625. * @returns the icosahedron mesh
  104626. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  104627. */
  104628. static CreateIcoSphere(name: string, options: {
  104629. radius?: number;
  104630. radiusX?: number;
  104631. radiusY?: number;
  104632. radiusZ?: number;
  104633. flat?: boolean;
  104634. subdivisions?: number;
  104635. sideOrientation?: number;
  104636. frontUVs?: Vector4;
  104637. backUVs?: Vector4;
  104638. updatable?: boolean;
  104639. }, scene: Scene): Mesh;
  104640. /**
  104641. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  104642. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  104643. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  104644. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  104645. * * 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
  104646. * * 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
  104647. * * 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
  104648. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104649. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104650. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  104651. * * 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
  104652. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  104653. * * 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
  104654. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  104655. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104656. * @param name defines the name of the mesh
  104657. * @param options defines the options used to create the mesh
  104658. * @param scene defines the hosting scene
  104659. * @returns the ribbon mesh
  104660. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  104661. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  104662. */
  104663. static CreateRibbon(name: string, options: {
  104664. pathArray: Vector3[][];
  104665. closeArray?: boolean;
  104666. closePath?: boolean;
  104667. offset?: number;
  104668. updatable?: boolean;
  104669. sideOrientation?: number;
  104670. frontUVs?: Vector4;
  104671. backUVs?: Vector4;
  104672. instance?: Mesh;
  104673. invertUV?: boolean;
  104674. uvs?: Vector2[];
  104675. colors?: Color4[];
  104676. }, scene?: Nullable<Scene>): Mesh;
  104677. /**
  104678. * Creates a cylinder or a cone mesh
  104679. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  104680. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  104681. * * 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.
  104682. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  104683. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  104684. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  104685. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  104686. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  104687. * * 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).
  104688. * * 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
  104689. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  104690. * * 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
  104691. * * 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.
  104692. * * If `enclose` is false, a ring surface is one element.
  104693. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  104694. * * 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
  104695. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104696. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104697. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104698. * @param name defines the name of the mesh
  104699. * @param options defines the options used to create the mesh
  104700. * @param scene defines the hosting scene
  104701. * @returns the cylinder mesh
  104702. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  104703. */
  104704. static CreateCylinder(name: string, options: {
  104705. height?: number;
  104706. diameterTop?: number;
  104707. diameterBottom?: number;
  104708. diameter?: number;
  104709. tessellation?: number;
  104710. subdivisions?: number;
  104711. arc?: number;
  104712. faceColors?: Color4[];
  104713. faceUV?: Vector4[];
  104714. updatable?: boolean;
  104715. hasRings?: boolean;
  104716. enclose?: boolean;
  104717. sideOrientation?: number;
  104718. frontUVs?: Vector4;
  104719. backUVs?: Vector4;
  104720. }, scene: any): Mesh;
  104721. /**
  104722. * Creates a torus mesh
  104723. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  104724. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  104725. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  104726. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104727. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104728. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104729. * @param name defines the name of the mesh
  104730. * @param options defines the options used to create the mesh
  104731. * @param scene defines the hosting scene
  104732. * @returns the torus mesh
  104733. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  104734. */
  104735. static CreateTorus(name: string, options: {
  104736. diameter?: number;
  104737. thickness?: number;
  104738. tessellation?: number;
  104739. updatable?: boolean;
  104740. sideOrientation?: number;
  104741. frontUVs?: Vector4;
  104742. backUVs?: Vector4;
  104743. }, scene: any): Mesh;
  104744. /**
  104745. * Creates a torus knot mesh
  104746. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  104747. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  104748. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  104749. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  104750. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104751. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104752. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104753. * @param name defines the name of the mesh
  104754. * @param options defines the options used to create the mesh
  104755. * @param scene defines the hosting scene
  104756. * @returns the torus knot mesh
  104757. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  104758. */
  104759. static CreateTorusKnot(name: string, options: {
  104760. radius?: number;
  104761. tube?: number;
  104762. radialSegments?: number;
  104763. tubularSegments?: number;
  104764. p?: number;
  104765. q?: number;
  104766. updatable?: boolean;
  104767. sideOrientation?: number;
  104768. frontUVs?: Vector4;
  104769. backUVs?: Vector4;
  104770. }, scene: any): Mesh;
  104771. /**
  104772. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  104773. * * 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
  104774. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  104775. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  104776. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  104777. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  104778. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  104779. * * 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
  104780. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  104781. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104782. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  104783. * @param name defines the name of the new line system
  104784. * @param options defines the options used to create the line system
  104785. * @param scene defines the hosting scene
  104786. * @returns a new line system mesh
  104787. */
  104788. static CreateLineSystem(name: string, options: {
  104789. lines: Vector3[][];
  104790. updatable?: boolean;
  104791. instance?: Nullable<LinesMesh>;
  104792. colors?: Nullable<Color4[][]>;
  104793. useVertexAlpha?: boolean;
  104794. }, scene: Nullable<Scene>): LinesMesh;
  104795. /**
  104796. * Creates a line mesh
  104797. * 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
  104798. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  104799. * * The parameter `points` is an array successive Vector3
  104800. * * 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
  104801. * * The optional parameter `colors` is an array of successive Color4, one per line point
  104802. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  104803. * * When updating an instance, remember that only point positions can change, not the number of points
  104804. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104805. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  104806. * @param name defines the name of the new line system
  104807. * @param options defines the options used to create the line system
  104808. * @param scene defines the hosting scene
  104809. * @returns a new line mesh
  104810. */
  104811. static CreateLines(name: string, options: {
  104812. points: Vector3[];
  104813. updatable?: boolean;
  104814. instance?: Nullable<LinesMesh>;
  104815. colors?: Color4[];
  104816. useVertexAlpha?: boolean;
  104817. }, scene?: Nullable<Scene>): LinesMesh;
  104818. /**
  104819. * Creates a dashed line mesh
  104820. * * 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
  104821. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  104822. * * The parameter `points` is an array successive Vector3
  104823. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  104824. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  104825. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  104826. * * 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
  104827. * * When updating an instance, remember that only point positions can change, not the number of points
  104828. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104829. * @param name defines the name of the mesh
  104830. * @param options defines the options used to create the mesh
  104831. * @param scene defines the hosting scene
  104832. * @returns the dashed line mesh
  104833. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  104834. */
  104835. static CreateDashedLines(name: string, options: {
  104836. points: Vector3[];
  104837. dashSize?: number;
  104838. gapSize?: number;
  104839. dashNb?: number;
  104840. updatable?: boolean;
  104841. instance?: LinesMesh;
  104842. }, scene?: Nullable<Scene>): LinesMesh;
  104843. /**
  104844. * 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.
  104845. * * 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.
  104846. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  104847. * * 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.
  104848. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  104849. * * 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
  104850. * * 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
  104851. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  104852. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104853. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104854. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  104855. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104856. * @param name defines the name of the mesh
  104857. * @param options defines the options used to create the mesh
  104858. * @param scene defines the hosting scene
  104859. * @returns the extruded shape mesh
  104860. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  104861. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  104862. */
  104863. static ExtrudeShape(name: string, options: {
  104864. shape: Vector3[];
  104865. path: Vector3[];
  104866. scale?: number;
  104867. rotation?: number;
  104868. cap?: number;
  104869. updatable?: boolean;
  104870. sideOrientation?: number;
  104871. frontUVs?: Vector4;
  104872. backUVs?: Vector4;
  104873. instance?: Mesh;
  104874. invertUV?: boolean;
  104875. }, scene?: Nullable<Scene>): Mesh;
  104876. /**
  104877. * Creates an custom extruded shape mesh.
  104878. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  104879. * * 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.
  104880. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  104881. * * 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
  104882. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  104883. * * 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
  104884. * * It must returns a float value that will be the scale value applied to the shape on each path point
  104885. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  104886. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  104887. * * 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
  104888. * * 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
  104889. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  104890. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104891. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104892. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  104893. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104894. * @param name defines the name of the mesh
  104895. * @param options defines the options used to create the mesh
  104896. * @param scene defines the hosting scene
  104897. * @returns the custom extruded shape mesh
  104898. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  104899. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  104900. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  104901. */
  104902. static ExtrudeShapeCustom(name: string, options: {
  104903. shape: Vector3[];
  104904. path: Vector3[];
  104905. scaleFunction?: any;
  104906. rotationFunction?: any;
  104907. ribbonCloseArray?: boolean;
  104908. ribbonClosePath?: boolean;
  104909. cap?: number;
  104910. updatable?: boolean;
  104911. sideOrientation?: number;
  104912. frontUVs?: Vector4;
  104913. backUVs?: Vector4;
  104914. instance?: Mesh;
  104915. invertUV?: boolean;
  104916. }, scene: Scene): Mesh;
  104917. /**
  104918. * Creates lathe mesh.
  104919. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  104920. * * 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
  104921. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  104922. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  104923. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  104924. * * 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
  104925. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  104926. * * 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
  104927. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104928. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104929. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  104930. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104931. * @param name defines the name of the mesh
  104932. * @param options defines the options used to create the mesh
  104933. * @param scene defines the hosting scene
  104934. * @returns the lathe mesh
  104935. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  104936. */
  104937. static CreateLathe(name: string, options: {
  104938. shape: Vector3[];
  104939. radius?: number;
  104940. tessellation?: number;
  104941. clip?: number;
  104942. arc?: number;
  104943. closed?: boolean;
  104944. updatable?: boolean;
  104945. sideOrientation?: number;
  104946. frontUVs?: Vector4;
  104947. backUVs?: Vector4;
  104948. cap?: number;
  104949. invertUV?: boolean;
  104950. }, scene: Scene): Mesh;
  104951. /**
  104952. * Creates a plane mesh
  104953. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  104954. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  104955. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  104956. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104957. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104958. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104959. * @param name defines the name of the mesh
  104960. * @param options defines the options used to create the mesh
  104961. * @param scene defines the hosting scene
  104962. * @returns the plane mesh
  104963. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  104964. */
  104965. static CreatePlane(name: string, options: {
  104966. size?: number;
  104967. width?: number;
  104968. height?: number;
  104969. sideOrientation?: number;
  104970. frontUVs?: Vector4;
  104971. backUVs?: Vector4;
  104972. updatable?: boolean;
  104973. sourcePlane?: Plane;
  104974. }, scene: Scene): Mesh;
  104975. /**
  104976. * Creates a ground mesh
  104977. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  104978. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  104979. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104980. * @param name defines the name of the mesh
  104981. * @param options defines the options used to create the mesh
  104982. * @param scene defines the hosting scene
  104983. * @returns the ground mesh
  104984. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  104985. */
  104986. static CreateGround(name: string, options: {
  104987. width?: number;
  104988. height?: number;
  104989. subdivisions?: number;
  104990. subdivisionsX?: number;
  104991. subdivisionsY?: number;
  104992. updatable?: boolean;
  104993. }, scene: any): Mesh;
  104994. /**
  104995. * Creates a tiled ground mesh
  104996. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  104997. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  104998. * * 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
  104999. * * 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
  105000. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105001. * @param name defines the name of the mesh
  105002. * @param options defines the options used to create the mesh
  105003. * @param scene defines the hosting scene
  105004. * @returns the tiled ground mesh
  105005. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  105006. */
  105007. static CreateTiledGround(name: string, options: {
  105008. xmin: number;
  105009. zmin: number;
  105010. xmax: number;
  105011. zmax: number;
  105012. subdivisions?: {
  105013. w: number;
  105014. h: number;
  105015. };
  105016. precision?: {
  105017. w: number;
  105018. h: number;
  105019. };
  105020. updatable?: boolean;
  105021. }, scene: Scene): Mesh;
  105022. /**
  105023. * Creates a ground mesh from a height map
  105024. * * The parameter `url` sets the URL of the height map image resource.
  105025. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  105026. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  105027. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  105028. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  105029. * * 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.
  105030. * * 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).
  105031. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  105032. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105033. * @param name defines the name of the mesh
  105034. * @param url defines the url to the height map
  105035. * @param options defines the options used to create the mesh
  105036. * @param scene defines the hosting scene
  105037. * @returns the ground mesh
  105038. * @see https://doc.babylonjs.com/babylon101/height_map
  105039. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  105040. */
  105041. static CreateGroundFromHeightMap(name: string, url: string, options: {
  105042. width?: number;
  105043. height?: number;
  105044. subdivisions?: number;
  105045. minHeight?: number;
  105046. maxHeight?: number;
  105047. colorFilter?: Color3;
  105048. alphaFilter?: number;
  105049. updatable?: boolean;
  105050. onReady?: (mesh: GroundMesh) => void;
  105051. }, scene: Scene): GroundMesh;
  105052. /**
  105053. * Creates a polygon mesh
  105054. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  105055. * * 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
  105056. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105057. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105058. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  105059. * * Remember you can only change the shape positions, not their number when updating a polygon
  105060. * @param name defines the name of the mesh
  105061. * @param options defines the options used to create the mesh
  105062. * @param scene defines the hosting scene
  105063. * @param earcutInjection can be used to inject your own earcut reference
  105064. * @returns the polygon mesh
  105065. */
  105066. static CreatePolygon(name: string, options: {
  105067. shape: Vector3[];
  105068. holes?: Vector3[][];
  105069. depth?: number;
  105070. faceUV?: Vector4[];
  105071. faceColors?: Color4[];
  105072. updatable?: boolean;
  105073. sideOrientation?: number;
  105074. frontUVs?: Vector4;
  105075. backUVs?: Vector4;
  105076. }, scene: Scene, earcutInjection?: any): Mesh;
  105077. /**
  105078. * Creates an extruded polygon mesh, with depth in the Y direction.
  105079. * * 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)
  105080. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  105081. * @param name defines the name of the mesh
  105082. * @param options defines the options used to create the mesh
  105083. * @param scene defines the hosting scene
  105084. * @param earcutInjection can be used to inject your own earcut reference
  105085. * @returns the polygon mesh
  105086. */
  105087. static ExtrudePolygon(name: string, options: {
  105088. shape: Vector3[];
  105089. holes?: Vector3[][];
  105090. depth?: number;
  105091. faceUV?: Vector4[];
  105092. faceColors?: Color4[];
  105093. updatable?: boolean;
  105094. sideOrientation?: number;
  105095. frontUVs?: Vector4;
  105096. backUVs?: Vector4;
  105097. }, scene: Scene, earcutInjection?: any): Mesh;
  105098. /**
  105099. * Creates a tube mesh.
  105100. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  105101. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  105102. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  105103. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  105104. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  105105. * * 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)
  105106. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  105107. * * 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
  105108. * * 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
  105109. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105110. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105111. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105112. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105113. * @param name defines the name of the mesh
  105114. * @param options defines the options used to create the mesh
  105115. * @param scene defines the hosting scene
  105116. * @returns the tube mesh
  105117. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105118. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  105119. */
  105120. static CreateTube(name: string, options: {
  105121. path: Vector3[];
  105122. radius?: number;
  105123. tessellation?: number;
  105124. radiusFunction?: {
  105125. (i: number, distance: number): number;
  105126. };
  105127. cap?: number;
  105128. arc?: number;
  105129. updatable?: boolean;
  105130. sideOrientation?: number;
  105131. frontUVs?: Vector4;
  105132. backUVs?: Vector4;
  105133. instance?: Mesh;
  105134. invertUV?: boolean;
  105135. }, scene: Scene): Mesh;
  105136. /**
  105137. * Creates a polyhedron mesh
  105138. * * 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
  105139. * * The parameter `size` (positive float, default 1) sets the polygon size
  105140. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  105141. * * 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`
  105142. * * 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
  105143. * * 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)`)
  105144. * * 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
  105145. * * 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
  105146. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105147. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105148. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105149. * @param name defines the name of the mesh
  105150. * @param options defines the options used to create the mesh
  105151. * @param scene defines the hosting scene
  105152. * @returns the polyhedron mesh
  105153. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  105154. */
  105155. static CreatePolyhedron(name: string, options: {
  105156. type?: number;
  105157. size?: number;
  105158. sizeX?: number;
  105159. sizeY?: number;
  105160. sizeZ?: number;
  105161. custom?: any;
  105162. faceUV?: Vector4[];
  105163. faceColors?: Color4[];
  105164. flat?: boolean;
  105165. updatable?: boolean;
  105166. sideOrientation?: number;
  105167. frontUVs?: Vector4;
  105168. backUVs?: Vector4;
  105169. }, scene: Scene): Mesh;
  105170. /**
  105171. * Creates a decal mesh.
  105172. * 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
  105173. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  105174. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  105175. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  105176. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  105177. * @param name defines the name of the mesh
  105178. * @param sourceMesh defines the mesh where the decal must be applied
  105179. * @param options defines the options used to create the mesh
  105180. * @param scene defines the hosting scene
  105181. * @returns the decal mesh
  105182. * @see https://doc.babylonjs.com/how_to/decals
  105183. */
  105184. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  105185. position?: Vector3;
  105186. normal?: Vector3;
  105187. size?: Vector3;
  105188. angle?: number;
  105189. }): Mesh;
  105190. }
  105191. }
  105192. declare module BABYLON {
  105193. /**
  105194. * A simplifier interface for future simplification implementations
  105195. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  105196. */
  105197. export interface ISimplifier {
  105198. /**
  105199. * Simplification of a given mesh according to the given settings.
  105200. * Since this requires computation, it is assumed that the function runs async.
  105201. * @param settings The settings of the simplification, including quality and distance
  105202. * @param successCallback A callback that will be called after the mesh was simplified.
  105203. * @param errorCallback in case of an error, this callback will be called. optional.
  105204. */
  105205. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  105206. }
  105207. /**
  105208. * Expected simplification settings.
  105209. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  105210. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  105211. */
  105212. export interface ISimplificationSettings {
  105213. /**
  105214. * Gets or sets the expected quality
  105215. */
  105216. quality: number;
  105217. /**
  105218. * Gets or sets the distance when this optimized version should be used
  105219. */
  105220. distance: number;
  105221. /**
  105222. * Gets an already optimized mesh
  105223. */
  105224. optimizeMesh?: boolean;
  105225. }
  105226. /**
  105227. * Class used to specify simplification options
  105228. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  105229. */
  105230. export class SimplificationSettings implements ISimplificationSettings {
  105231. /** expected quality */
  105232. quality: number;
  105233. /** distance when this optimized version should be used */
  105234. distance: number;
  105235. /** already optimized mesh */
  105236. optimizeMesh?: boolean | undefined;
  105237. /**
  105238. * Creates a SimplificationSettings
  105239. * @param quality expected quality
  105240. * @param distance distance when this optimized version should be used
  105241. * @param optimizeMesh already optimized mesh
  105242. */
  105243. constructor(
  105244. /** expected quality */
  105245. quality: number,
  105246. /** distance when this optimized version should be used */
  105247. distance: number,
  105248. /** already optimized mesh */
  105249. optimizeMesh?: boolean | undefined);
  105250. }
  105251. /**
  105252. * Interface used to define a simplification task
  105253. */
  105254. export interface ISimplificationTask {
  105255. /**
  105256. * Array of settings
  105257. */
  105258. settings: Array<ISimplificationSettings>;
  105259. /**
  105260. * Simplification type
  105261. */
  105262. simplificationType: SimplificationType;
  105263. /**
  105264. * Mesh to simplify
  105265. */
  105266. mesh: Mesh;
  105267. /**
  105268. * Callback called on success
  105269. */
  105270. successCallback?: () => void;
  105271. /**
  105272. * Defines if parallel processing can be used
  105273. */
  105274. parallelProcessing: boolean;
  105275. }
  105276. /**
  105277. * Queue used to order the simplification tasks
  105278. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  105279. */
  105280. export class SimplificationQueue {
  105281. private _simplificationArray;
  105282. /**
  105283. * Gets a boolean indicating that the process is still running
  105284. */
  105285. running: boolean;
  105286. /**
  105287. * Creates a new queue
  105288. */
  105289. constructor();
  105290. /**
  105291. * Adds a new simplification task
  105292. * @param task defines a task to add
  105293. */
  105294. addTask(task: ISimplificationTask): void;
  105295. /**
  105296. * Execute next task
  105297. */
  105298. executeNext(): void;
  105299. /**
  105300. * Execute a simplification task
  105301. * @param task defines the task to run
  105302. */
  105303. runSimplification(task: ISimplificationTask): void;
  105304. private getSimplifier;
  105305. }
  105306. /**
  105307. * The implemented types of simplification
  105308. * At the moment only Quadratic Error Decimation is implemented
  105309. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  105310. */
  105311. export enum SimplificationType {
  105312. /** Quadratic error decimation */
  105313. QUADRATIC = 0
  105314. }
  105315. }
  105316. declare module BABYLON {
  105317. interface Scene {
  105318. /** @hidden (Backing field) */
  105319. _simplificationQueue: SimplificationQueue;
  105320. /**
  105321. * Gets or sets the simplification queue attached to the scene
  105322. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  105323. */
  105324. simplificationQueue: SimplificationQueue;
  105325. }
  105326. interface Mesh {
  105327. /**
  105328. * Simplify the mesh according to the given array of settings.
  105329. * Function will return immediately and will simplify async
  105330. * @param settings a collection of simplification settings
  105331. * @param parallelProcessing should all levels calculate parallel or one after the other
  105332. * @param simplificationType the type of simplification to run
  105333. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  105334. * @returns the current mesh
  105335. */
  105336. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  105337. }
  105338. /**
  105339. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  105340. * created in a scene
  105341. */
  105342. export class SimplicationQueueSceneComponent implements ISceneComponent {
  105343. /**
  105344. * The component name helpfull to identify the component in the list of scene components.
  105345. */
  105346. readonly name: string;
  105347. /**
  105348. * The scene the component belongs to.
  105349. */
  105350. scene: Scene;
  105351. /**
  105352. * Creates a new instance of the component for the given scene
  105353. * @param scene Defines the scene to register the component in
  105354. */
  105355. constructor(scene: Scene);
  105356. /**
  105357. * Registers the component in a given scene
  105358. */
  105359. register(): void;
  105360. /**
  105361. * Rebuilds the elements related to this component in case of
  105362. * context lost for instance.
  105363. */
  105364. rebuild(): void;
  105365. /**
  105366. * Disposes the component and the associated ressources
  105367. */
  105368. dispose(): void;
  105369. private _beforeCameraUpdate;
  105370. }
  105371. }
  105372. declare module BABYLON {
  105373. /**
  105374. * Class used to enable access to IndexedDB
  105375. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  105376. */
  105377. export class Database implements IOfflineProvider {
  105378. private _callbackManifestChecked;
  105379. private _currentSceneUrl;
  105380. private _db;
  105381. private _enableSceneOffline;
  105382. private _enableTexturesOffline;
  105383. private _manifestVersionFound;
  105384. private _mustUpdateRessources;
  105385. private _hasReachedQuota;
  105386. private _isSupported;
  105387. private _idbFactory;
  105388. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  105389. private static IsUASupportingBlobStorage;
  105390. /**
  105391. * Gets a boolean indicating if Database storate is enabled (off by default)
  105392. */
  105393. static IDBStorageEnabled: boolean;
  105394. /**
  105395. * Gets a boolean indicating if scene must be saved in the database
  105396. */
  105397. readonly enableSceneOffline: boolean;
  105398. /**
  105399. * Gets a boolean indicating if textures must be saved in the database
  105400. */
  105401. readonly enableTexturesOffline: boolean;
  105402. /**
  105403. * Creates a new Database
  105404. * @param urlToScene defines the url to load the scene
  105405. * @param callbackManifestChecked defines the callback to use when manifest is checked
  105406. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  105407. */
  105408. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  105409. private static _ParseURL;
  105410. private static _ReturnFullUrlLocation;
  105411. private _checkManifestFile;
  105412. /**
  105413. * Open the database and make it available
  105414. * @param successCallback defines the callback to call on success
  105415. * @param errorCallback defines the callback to call on error
  105416. */
  105417. open(successCallback: () => void, errorCallback: () => void): void;
  105418. /**
  105419. * Loads an image from the database
  105420. * @param url defines the url to load from
  105421. * @param image defines the target DOM image
  105422. */
  105423. loadImage(url: string, image: HTMLImageElement): void;
  105424. private _loadImageFromDBAsync;
  105425. private _saveImageIntoDBAsync;
  105426. private _checkVersionFromDB;
  105427. private _loadVersionFromDBAsync;
  105428. private _saveVersionIntoDBAsync;
  105429. /**
  105430. * Loads a file from database
  105431. * @param url defines the URL to load from
  105432. * @param sceneLoaded defines a callback to call on success
  105433. * @param progressCallBack defines a callback to call when progress changed
  105434. * @param errorCallback defines a callback to call on error
  105435. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  105436. */
  105437. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  105438. private _loadFileAsync;
  105439. private _saveFileAsync;
  105440. /**
  105441. * Validates if xhr data is correct
  105442. * @param xhr defines the request to validate
  105443. * @param dataType defines the expected data type
  105444. * @returns true if data is correct
  105445. */
  105446. private static _ValidateXHRData;
  105447. }
  105448. }
  105449. declare module BABYLON {
  105450. /** @hidden */
  105451. export var gpuUpdateParticlesPixelShader: {
  105452. name: string;
  105453. shader: string;
  105454. };
  105455. }
  105456. declare module BABYLON {
  105457. /** @hidden */
  105458. export var gpuUpdateParticlesVertexShader: {
  105459. name: string;
  105460. shader: string;
  105461. };
  105462. }
  105463. declare module BABYLON {
  105464. /** @hidden */
  105465. export var clipPlaneFragmentDeclaration2: {
  105466. name: string;
  105467. shader: string;
  105468. };
  105469. }
  105470. declare module BABYLON {
  105471. /** @hidden */
  105472. export var gpuRenderParticlesPixelShader: {
  105473. name: string;
  105474. shader: string;
  105475. };
  105476. }
  105477. declare module BABYLON {
  105478. /** @hidden */
  105479. export var clipPlaneVertexDeclaration2: {
  105480. name: string;
  105481. shader: string;
  105482. };
  105483. }
  105484. declare module BABYLON {
  105485. /** @hidden */
  105486. export var gpuRenderParticlesVertexShader: {
  105487. name: string;
  105488. shader: string;
  105489. };
  105490. }
  105491. declare module BABYLON {
  105492. /**
  105493. * This represents a GPU particle system in Babylon
  105494. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  105495. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  105496. */
  105497. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  105498. /**
  105499. * The layer mask we are rendering the particles through.
  105500. */
  105501. layerMask: number;
  105502. private _capacity;
  105503. private _activeCount;
  105504. private _currentActiveCount;
  105505. private _accumulatedCount;
  105506. private _renderEffect;
  105507. private _updateEffect;
  105508. private _buffer0;
  105509. private _buffer1;
  105510. private _spriteBuffer;
  105511. private _updateVAO;
  105512. private _renderVAO;
  105513. private _targetIndex;
  105514. private _sourceBuffer;
  105515. private _targetBuffer;
  105516. private _engine;
  105517. private _currentRenderId;
  105518. private _started;
  105519. private _stopped;
  105520. private _timeDelta;
  105521. private _randomTexture;
  105522. private _randomTexture2;
  105523. private _attributesStrideSize;
  105524. private _updateEffectOptions;
  105525. private _randomTextureSize;
  105526. private _actualFrame;
  105527. private readonly _rawTextureWidth;
  105528. /**
  105529. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  105530. */
  105531. static readonly IsSupported: boolean;
  105532. /**
  105533. * An event triggered when the system is disposed.
  105534. */
  105535. onDisposeObservable: Observable<GPUParticleSystem>;
  105536. /**
  105537. * Gets the maximum number of particles active at the same time.
  105538. * @returns The max number of active particles.
  105539. */
  105540. getCapacity(): number;
  105541. /**
  105542. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  105543. * to override the particles.
  105544. */
  105545. forceDepthWrite: boolean;
  105546. /**
  105547. * Gets or set the number of active particles
  105548. */
  105549. activeParticleCount: number;
  105550. private _preWarmDone;
  105551. /**
  105552. * Is this system ready to be used/rendered
  105553. * @return true if the system is ready
  105554. */
  105555. isReady(): boolean;
  105556. /**
  105557. * Gets if the system has been started. (Note: this will still be true after stop is called)
  105558. * @returns True if it has been started, otherwise false.
  105559. */
  105560. isStarted(): boolean;
  105561. /**
  105562. * Starts the particle system and begins to emit
  105563. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  105564. */
  105565. start(delay?: number): void;
  105566. /**
  105567. * Stops the particle system.
  105568. */
  105569. stop(): void;
  105570. /**
  105571. * Remove all active particles
  105572. */
  105573. reset(): void;
  105574. /**
  105575. * Returns the string "GPUParticleSystem"
  105576. * @returns a string containing the class name
  105577. */
  105578. getClassName(): string;
  105579. private _colorGradientsTexture;
  105580. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  105581. /**
  105582. * Adds a new color gradient
  105583. * @param gradient defines the gradient to use (between 0 and 1)
  105584. * @param color1 defines the color to affect to the specified gradient
  105585. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  105586. * @returns the current particle system
  105587. */
  105588. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  105589. /**
  105590. * Remove a specific color gradient
  105591. * @param gradient defines the gradient to remove
  105592. * @returns the current particle system
  105593. */
  105594. removeColorGradient(gradient: number): GPUParticleSystem;
  105595. private _angularSpeedGradientsTexture;
  105596. private _sizeGradientsTexture;
  105597. private _velocityGradientsTexture;
  105598. private _limitVelocityGradientsTexture;
  105599. private _dragGradientsTexture;
  105600. private _addFactorGradient;
  105601. /**
  105602. * Adds a new size gradient
  105603. * @param gradient defines the gradient to use (between 0 and 1)
  105604. * @param factor defines the size factor to affect to the specified gradient
  105605. * @returns the current particle system
  105606. */
  105607. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  105608. /**
  105609. * Remove a specific size gradient
  105610. * @param gradient defines the gradient to remove
  105611. * @returns the current particle system
  105612. */
  105613. removeSizeGradient(gradient: number): GPUParticleSystem;
  105614. /**
  105615. * Adds a new angular speed gradient
  105616. * @param gradient defines the gradient to use (between 0 and 1)
  105617. * @param factor defines the angular speed to affect to the specified gradient
  105618. * @returns the current particle system
  105619. */
  105620. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  105621. /**
  105622. * Remove a specific angular speed gradient
  105623. * @param gradient defines the gradient to remove
  105624. * @returns the current particle system
  105625. */
  105626. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  105627. /**
  105628. * Adds a new velocity gradient
  105629. * @param gradient defines the gradient to use (between 0 and 1)
  105630. * @param factor defines the velocity to affect to the specified gradient
  105631. * @returns the current particle system
  105632. */
  105633. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  105634. /**
  105635. * Remove a specific velocity gradient
  105636. * @param gradient defines the gradient to remove
  105637. * @returns the current particle system
  105638. */
  105639. removeVelocityGradient(gradient: number): GPUParticleSystem;
  105640. /**
  105641. * Adds a new limit velocity gradient
  105642. * @param gradient defines the gradient to use (between 0 and 1)
  105643. * @param factor defines the limit velocity value to affect to the specified gradient
  105644. * @returns the current particle system
  105645. */
  105646. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  105647. /**
  105648. * Remove a specific limit velocity gradient
  105649. * @param gradient defines the gradient to remove
  105650. * @returns the current particle system
  105651. */
  105652. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  105653. /**
  105654. * Adds a new drag gradient
  105655. * @param gradient defines the gradient to use (between 0 and 1)
  105656. * @param factor defines the drag value to affect to the specified gradient
  105657. * @returns the current particle system
  105658. */
  105659. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  105660. /**
  105661. * Remove a specific drag gradient
  105662. * @param gradient defines the gradient to remove
  105663. * @returns the current particle system
  105664. */
  105665. removeDragGradient(gradient: number): GPUParticleSystem;
  105666. /**
  105667. * Not supported by GPUParticleSystem
  105668. * @param gradient defines the gradient to use (between 0 and 1)
  105669. * @param factor defines the emit rate value to affect to the specified gradient
  105670. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  105671. * @returns the current particle system
  105672. */
  105673. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  105674. /**
  105675. * Not supported by GPUParticleSystem
  105676. * @param gradient defines the gradient to remove
  105677. * @returns the current particle system
  105678. */
  105679. removeEmitRateGradient(gradient: number): IParticleSystem;
  105680. /**
  105681. * Not supported by GPUParticleSystem
  105682. * @param gradient defines the gradient to use (between 0 and 1)
  105683. * @param factor defines the start size value to affect to the specified gradient
  105684. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  105685. * @returns the current particle system
  105686. */
  105687. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  105688. /**
  105689. * Not supported by GPUParticleSystem
  105690. * @param gradient defines the gradient to remove
  105691. * @returns the current particle system
  105692. */
  105693. removeStartSizeGradient(gradient: number): IParticleSystem;
  105694. /**
  105695. * Not supported by GPUParticleSystem
  105696. * @param gradient defines the gradient to use (between 0 and 1)
  105697. * @param min defines the color remap minimal range
  105698. * @param max defines the color remap maximal range
  105699. * @returns the current particle system
  105700. */
  105701. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  105702. /**
  105703. * Not supported by GPUParticleSystem
  105704. * @param gradient defines the gradient to remove
  105705. * @returns the current particle system
  105706. */
  105707. removeColorRemapGradient(): IParticleSystem;
  105708. /**
  105709. * Not supported by GPUParticleSystem
  105710. * @param gradient defines the gradient to use (between 0 and 1)
  105711. * @param min defines the alpha remap minimal range
  105712. * @param max defines the alpha remap maximal range
  105713. * @returns the current particle system
  105714. */
  105715. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  105716. /**
  105717. * Not supported by GPUParticleSystem
  105718. * @param gradient defines the gradient to remove
  105719. * @returns the current particle system
  105720. */
  105721. removeAlphaRemapGradient(): IParticleSystem;
  105722. /**
  105723. * Not supported by GPUParticleSystem
  105724. * @param gradient defines the gradient to use (between 0 and 1)
  105725. * @param color defines the color to affect to the specified gradient
  105726. * @returns the current particle system
  105727. */
  105728. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  105729. /**
  105730. * Not supported by GPUParticleSystem
  105731. * @param gradient defines the gradient to remove
  105732. * @returns the current particle system
  105733. */
  105734. removeRampGradient(): IParticleSystem;
  105735. /**
  105736. * Not supported by GPUParticleSystem
  105737. * @returns the list of ramp gradients
  105738. */
  105739. getRampGradients(): Nullable<Array<Color3Gradient>>;
  105740. /**
  105741. * Not supported by GPUParticleSystem
  105742. * Gets or sets a boolean indicating that ramp gradients must be used
  105743. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  105744. */
  105745. useRampGradients: boolean;
  105746. /**
  105747. * Not supported by GPUParticleSystem
  105748. * @param gradient defines the gradient to use (between 0 and 1)
  105749. * @param factor defines the life time factor to affect to the specified gradient
  105750. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  105751. * @returns the current particle system
  105752. */
  105753. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  105754. /**
  105755. * Not supported by GPUParticleSystem
  105756. * @param gradient defines the gradient to remove
  105757. * @returns the current particle system
  105758. */
  105759. removeLifeTimeGradient(gradient: number): IParticleSystem;
  105760. /**
  105761. * Instantiates a GPU particle system.
  105762. * 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.
  105763. * @param name The name of the particle system
  105764. * @param options The options used to create the system
  105765. * @param scene The scene the particle system belongs to
  105766. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  105767. */
  105768. constructor(name: string, options: Partial<{
  105769. capacity: number;
  105770. randomTextureSize: number;
  105771. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  105772. protected _reset(): void;
  105773. private _createUpdateVAO;
  105774. private _createRenderVAO;
  105775. private _initialize;
  105776. /** @hidden */
  105777. _recreateUpdateEffect(): void;
  105778. /** @hidden */
  105779. _recreateRenderEffect(): void;
  105780. /**
  105781. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  105782. * @param preWarm defines if we are in the pre-warmimg phase
  105783. */
  105784. animate(preWarm?: boolean): void;
  105785. private _createFactorGradientTexture;
  105786. private _createSizeGradientTexture;
  105787. private _createAngularSpeedGradientTexture;
  105788. private _createVelocityGradientTexture;
  105789. private _createLimitVelocityGradientTexture;
  105790. private _createDragGradientTexture;
  105791. private _createColorGradientTexture;
  105792. /**
  105793. * Renders the particle system in its current state
  105794. * @param preWarm defines if the system should only update the particles but not render them
  105795. * @returns the current number of particles
  105796. */
  105797. render(preWarm?: boolean): number;
  105798. /**
  105799. * Rebuilds the particle system
  105800. */
  105801. rebuild(): void;
  105802. private _releaseBuffers;
  105803. private _releaseVAOs;
  105804. /**
  105805. * Disposes the particle system and free the associated resources
  105806. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  105807. */
  105808. dispose(disposeTexture?: boolean): void;
  105809. /**
  105810. * Clones the particle system.
  105811. * @param name The name of the cloned object
  105812. * @param newEmitter The new emitter to use
  105813. * @returns the cloned particle system
  105814. */
  105815. clone(name: string, newEmitter: any): GPUParticleSystem;
  105816. /**
  105817. * Serializes the particle system to a JSON object.
  105818. * @returns the JSON object
  105819. */
  105820. serialize(): any;
  105821. /**
  105822. * Parses a JSON object to create a GPU particle system.
  105823. * @param parsedParticleSystem The JSON object to parse
  105824. * @param scene The scene to create the particle system in
  105825. * @param rootUrl The root url to use to load external dependencies like texture
  105826. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  105827. * @returns the parsed GPU particle system
  105828. */
  105829. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  105830. }
  105831. }
  105832. declare module BABYLON {
  105833. /**
  105834. * Represents a set of particle systems working together to create a specific effect
  105835. */
  105836. export class ParticleSystemSet implements IDisposable {
  105837. private _emitterCreationOptions;
  105838. private _emitterNode;
  105839. /**
  105840. * Gets the particle system list
  105841. */
  105842. systems: IParticleSystem[];
  105843. /**
  105844. * Gets the emitter node used with this set
  105845. */
  105846. readonly emitterNode: Nullable<TransformNode>;
  105847. /**
  105848. * Creates a new emitter mesh as a sphere
  105849. * @param options defines the options used to create the sphere
  105850. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  105851. * @param scene defines the hosting scene
  105852. */
  105853. setEmitterAsSphere(options: {
  105854. diameter: number;
  105855. segments: number;
  105856. color: Color3;
  105857. }, renderingGroupId: number, scene: Scene): void;
  105858. /**
  105859. * Starts all particle systems of the set
  105860. * @param emitter defines an optional mesh to use as emitter for the particle systems
  105861. */
  105862. start(emitter?: AbstractMesh): void;
  105863. /**
  105864. * Release all associated resources
  105865. */
  105866. dispose(): void;
  105867. /**
  105868. * Serialize the set into a JSON compatible object
  105869. * @returns a JSON compatible representation of the set
  105870. */
  105871. serialize(): any;
  105872. /**
  105873. * Parse a new ParticleSystemSet from a serialized source
  105874. * @param data defines a JSON compatible representation of the set
  105875. * @param scene defines the hosting scene
  105876. * @param gpu defines if we want GPU particles or CPU particles
  105877. * @returns a new ParticleSystemSet
  105878. */
  105879. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  105880. }
  105881. }
  105882. declare module BABYLON {
  105883. /**
  105884. * This class is made for on one-liner static method to help creating particle system set.
  105885. */
  105886. export class ParticleHelper {
  105887. /**
  105888. * Gets or sets base Assets URL
  105889. */
  105890. static BaseAssetsUrl: string;
  105891. /**
  105892. * Create a default particle system that you can tweak
  105893. * @param emitter defines the emitter to use
  105894. * @param capacity defines the system capacity (default is 500 particles)
  105895. * @param scene defines the hosting scene
  105896. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  105897. * @returns the new Particle system
  105898. */
  105899. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  105900. /**
  105901. * This is the main static method (one-liner) of this helper to create different particle systems
  105902. * @param type This string represents the type to the particle system to create
  105903. * @param scene The scene where the particle system should live
  105904. * @param gpu If the system will use gpu
  105905. * @returns the ParticleSystemSet created
  105906. */
  105907. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  105908. /**
  105909. * Static function used to export a particle system to a ParticleSystemSet variable.
  105910. * Please note that the emitter shape is not exported
  105911. * @param systems defines the particle systems to export
  105912. * @returns the created particle system set
  105913. */
  105914. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  105915. }
  105916. }
  105917. declare module BABYLON {
  105918. interface Engine {
  105919. /**
  105920. * Create an effect to use with particle systems.
  105921. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  105922. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  105923. * @param uniformsNames defines a list of attribute names
  105924. * @param samplers defines an array of string used to represent textures
  105925. * @param defines defines the string containing the defines to use to compile the shaders
  105926. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  105927. * @param onCompiled defines a function to call when the effect creation is successful
  105928. * @param onError defines a function to call when the effect creation has failed
  105929. * @returns the new Effect
  105930. */
  105931. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  105932. }
  105933. interface Mesh {
  105934. /**
  105935. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  105936. * @returns an array of IParticleSystem
  105937. */
  105938. getEmittedParticleSystems(): IParticleSystem[];
  105939. /**
  105940. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  105941. * @returns an array of IParticleSystem
  105942. */
  105943. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  105944. }
  105945. /**
  105946. * @hidden
  105947. */
  105948. export var _IDoNeedToBeInTheBuild: number;
  105949. }
  105950. declare module BABYLON {
  105951. interface Scene {
  105952. /** @hidden (Backing field) */
  105953. _physicsEngine: Nullable<IPhysicsEngine>;
  105954. /**
  105955. * Gets the current physics engine
  105956. * @returns a IPhysicsEngine or null if none attached
  105957. */
  105958. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  105959. /**
  105960. * Enables physics to the current scene
  105961. * @param gravity defines the scene's gravity for the physics engine
  105962. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  105963. * @return a boolean indicating if the physics engine was initialized
  105964. */
  105965. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  105966. /**
  105967. * Disables and disposes the physics engine associated with the scene
  105968. */
  105969. disablePhysicsEngine(): void;
  105970. /**
  105971. * Gets a boolean indicating if there is an active physics engine
  105972. * @returns a boolean indicating if there is an active physics engine
  105973. */
  105974. isPhysicsEnabled(): boolean;
  105975. /**
  105976. * Deletes a physics compound impostor
  105977. * @param compound defines the compound to delete
  105978. */
  105979. deleteCompoundImpostor(compound: any): void;
  105980. /**
  105981. * An event triggered when physic simulation is about to be run
  105982. */
  105983. onBeforePhysicsObservable: Observable<Scene>;
  105984. /**
  105985. * An event triggered when physic simulation has been done
  105986. */
  105987. onAfterPhysicsObservable: Observable<Scene>;
  105988. }
  105989. interface AbstractMesh {
  105990. /** @hidden */
  105991. _physicsImpostor: Nullable<PhysicsImpostor>;
  105992. /**
  105993. * Gets or sets impostor used for physic simulation
  105994. * @see http://doc.babylonjs.com/features/physics_engine
  105995. */
  105996. physicsImpostor: Nullable<PhysicsImpostor>;
  105997. /**
  105998. * Gets the current physics impostor
  105999. * @see http://doc.babylonjs.com/features/physics_engine
  106000. * @returns a physics impostor or null
  106001. */
  106002. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  106003. /** Apply a physic impulse to the mesh
  106004. * @param force defines the force to apply
  106005. * @param contactPoint defines where to apply the force
  106006. * @returns the current mesh
  106007. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  106008. */
  106009. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  106010. /**
  106011. * Creates a physic joint between two meshes
  106012. * @param otherMesh defines the other mesh to use
  106013. * @param pivot1 defines the pivot to use on this mesh
  106014. * @param pivot2 defines the pivot to use on the other mesh
  106015. * @param options defines additional options (can be plugin dependent)
  106016. * @returns the current mesh
  106017. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  106018. */
  106019. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  106020. /** @hidden */
  106021. _disposePhysicsObserver: Nullable<Observer<Node>>;
  106022. }
  106023. /**
  106024. * Defines the physics engine scene component responsible to manage a physics engine
  106025. */
  106026. export class PhysicsEngineSceneComponent implements ISceneComponent {
  106027. /**
  106028. * The component name helpful to identify the component in the list of scene components.
  106029. */
  106030. readonly name: string;
  106031. /**
  106032. * The scene the component belongs to.
  106033. */
  106034. scene: Scene;
  106035. /**
  106036. * Creates a new instance of the component for the given scene
  106037. * @param scene Defines the scene to register the component in
  106038. */
  106039. constructor(scene: Scene);
  106040. /**
  106041. * Registers the component in a given scene
  106042. */
  106043. register(): void;
  106044. /**
  106045. * Rebuilds the elements related to this component in case of
  106046. * context lost for instance.
  106047. */
  106048. rebuild(): void;
  106049. /**
  106050. * Disposes the component and the associated ressources
  106051. */
  106052. dispose(): void;
  106053. }
  106054. }
  106055. declare module BABYLON {
  106056. /**
  106057. * A helper for physics simulations
  106058. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106059. */
  106060. export class PhysicsHelper {
  106061. private _scene;
  106062. private _physicsEngine;
  106063. /**
  106064. * Initializes the Physics helper
  106065. * @param scene Babylon.js scene
  106066. */
  106067. constructor(scene: Scene);
  106068. /**
  106069. * Applies a radial explosion impulse
  106070. * @param origin the origin of the explosion
  106071. * @param radius the explosion radius
  106072. * @param strength the explosion strength
  106073. * @param falloff possible options: Constant & Linear. Defaults to Constant
  106074. * @returns A physics radial explosion event, or null
  106075. */
  106076. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  106077. /**
  106078. * Applies a radial explosion force
  106079. * @param origin the origin of the explosion
  106080. * @param radius the explosion radius
  106081. * @param strength the explosion strength
  106082. * @param falloff possible options: Constant & Linear. Defaults to Constant
  106083. * @returns A physics radial explosion event, or null
  106084. */
  106085. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  106086. /**
  106087. * Creates a gravitational field
  106088. * @param origin the origin of the explosion
  106089. * @param radius the explosion radius
  106090. * @param strength the explosion strength
  106091. * @param falloff possible options: Constant & Linear. Defaults to Constant
  106092. * @returns A physics gravitational field event, or null
  106093. */
  106094. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  106095. /**
  106096. * Creates a physics updraft event
  106097. * @param origin the origin of the updraft
  106098. * @param radius the radius of the updraft
  106099. * @param strength the strength of the updraft
  106100. * @param height the height of the updraft
  106101. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  106102. * @returns A physics updraft event, or null
  106103. */
  106104. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  106105. /**
  106106. * Creates a physics vortex event
  106107. * @param origin the of the vortex
  106108. * @param radius the radius of the vortex
  106109. * @param strength the strength of the vortex
  106110. * @param height the height of the vortex
  106111. * @returns a Physics vortex event, or null
  106112. * A physics vortex event or null
  106113. */
  106114. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  106115. }
  106116. /**
  106117. * Represents a physics radial explosion event
  106118. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106119. */
  106120. export class PhysicsRadialExplosionEvent {
  106121. private _scene;
  106122. private _sphere;
  106123. private _sphereOptions;
  106124. private _rays;
  106125. private _dataFetched;
  106126. /**
  106127. * Initializes a radial explosioin event
  106128. * @param scene BabylonJS scene
  106129. */
  106130. constructor(scene: Scene);
  106131. /**
  106132. * Returns the data related to the radial explosion event (sphere & rays).
  106133. * @returns The radial explosion event data
  106134. */
  106135. getData(): PhysicsRadialExplosionEventData;
  106136. /**
  106137. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  106138. * @param impostor A physics imposter
  106139. * @param origin the origin of the explosion
  106140. * @param radius the explosion radius
  106141. * @param strength the explosion strength
  106142. * @param falloff possible options: Constant & Linear
  106143. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  106144. */
  106145. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  106146. /**
  106147. * Disposes the sphere.
  106148. * @param force Specifies if the sphere should be disposed by force
  106149. */
  106150. dispose(force?: boolean): void;
  106151. /*** Helpers ***/
  106152. private _prepareSphere;
  106153. private _intersectsWithSphere;
  106154. }
  106155. /**
  106156. * Represents a gravitational field event
  106157. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106158. */
  106159. export class PhysicsGravitationalFieldEvent {
  106160. private _physicsHelper;
  106161. private _scene;
  106162. private _origin;
  106163. private _radius;
  106164. private _strength;
  106165. private _falloff;
  106166. private _tickCallback;
  106167. private _sphere;
  106168. private _dataFetched;
  106169. /**
  106170. * Initializes the physics gravitational field event
  106171. * @param physicsHelper A physics helper
  106172. * @param scene BabylonJS scene
  106173. * @param origin The origin position of the gravitational field event
  106174. * @param radius The radius of the gravitational field event
  106175. * @param strength The strength of the gravitational field event
  106176. * @param falloff The falloff for the gravitational field event
  106177. */
  106178. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  106179. /**
  106180. * Returns the data related to the gravitational field event (sphere).
  106181. * @returns A gravitational field event
  106182. */
  106183. getData(): PhysicsGravitationalFieldEventData;
  106184. /**
  106185. * Enables the gravitational field.
  106186. */
  106187. enable(): void;
  106188. /**
  106189. * Disables the gravitational field.
  106190. */
  106191. disable(): void;
  106192. /**
  106193. * Disposes the sphere.
  106194. * @param force The force to dispose from the gravitational field event
  106195. */
  106196. dispose(force?: boolean): void;
  106197. private _tick;
  106198. }
  106199. /**
  106200. * Represents a physics updraft event
  106201. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106202. */
  106203. export class PhysicsUpdraftEvent {
  106204. private _scene;
  106205. private _origin;
  106206. private _radius;
  106207. private _strength;
  106208. private _height;
  106209. private _updraftMode;
  106210. private _physicsEngine;
  106211. private _originTop;
  106212. private _originDirection;
  106213. private _tickCallback;
  106214. private _cylinder;
  106215. private _cylinderPosition;
  106216. private _dataFetched;
  106217. /**
  106218. * Initializes the physics updraft event
  106219. * @param _scene BabylonJS scene
  106220. * @param _origin The origin position of the updraft
  106221. * @param _radius The radius of the updraft
  106222. * @param _strength The strength of the updraft
  106223. * @param _height The height of the updraft
  106224. * @param _updraftMode The mode of the updraft
  106225. */
  106226. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  106227. /**
  106228. * Returns the data related to the updraft event (cylinder).
  106229. * @returns A physics updraft event
  106230. */
  106231. getData(): PhysicsUpdraftEventData;
  106232. /**
  106233. * Enables the updraft.
  106234. */
  106235. enable(): void;
  106236. /**
  106237. * Disables the cortex.
  106238. */
  106239. disable(): void;
  106240. /**
  106241. * Disposes the sphere.
  106242. * @param force Specifies if the updraft should be disposed by force
  106243. */
  106244. dispose(force?: boolean): void;
  106245. private getImpostorForceAndContactPoint;
  106246. private _tick;
  106247. /*** Helpers ***/
  106248. private _prepareCylinder;
  106249. private _intersectsWithCylinder;
  106250. }
  106251. /**
  106252. * Represents a physics vortex event
  106253. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106254. */
  106255. export class PhysicsVortexEvent {
  106256. private _scene;
  106257. private _origin;
  106258. private _radius;
  106259. private _strength;
  106260. private _height;
  106261. private _physicsEngine;
  106262. private _originTop;
  106263. private _centripetalForceThreshold;
  106264. private _updraftMultiplier;
  106265. private _tickCallback;
  106266. private _cylinder;
  106267. private _cylinderPosition;
  106268. private _dataFetched;
  106269. /**
  106270. * Initializes the physics vortex event
  106271. * @param _scene The BabylonJS scene
  106272. * @param _origin The origin position of the vortex
  106273. * @param _radius The radius of the vortex
  106274. * @param _strength The strength of the vortex
  106275. * @param _height The height of the vortex
  106276. */
  106277. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  106278. /**
  106279. * Returns the data related to the vortex event (cylinder).
  106280. * @returns The physics vortex event data
  106281. */
  106282. getData(): PhysicsVortexEventData;
  106283. /**
  106284. * Enables the vortex.
  106285. */
  106286. enable(): void;
  106287. /**
  106288. * Disables the cortex.
  106289. */
  106290. disable(): void;
  106291. /**
  106292. * Disposes the sphere.
  106293. * @param force
  106294. */
  106295. dispose(force?: boolean): void;
  106296. private getImpostorForceAndContactPoint;
  106297. private _tick;
  106298. /*** Helpers ***/
  106299. private _prepareCylinder;
  106300. private _intersectsWithCylinder;
  106301. }
  106302. /**
  106303. * The strenght of the force in correspondence to the distance of the affected object
  106304. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106305. */
  106306. export enum PhysicsRadialImpulseFalloff {
  106307. /** Defines that impulse is constant in strength across it's whole radius */
  106308. Constant = 0,
  106309. /** DEfines that impulse gets weaker if it's further from the origin */
  106310. Linear = 1
  106311. }
  106312. /**
  106313. * The strength of the force in correspondence to the distance of the affected object
  106314. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106315. */
  106316. export enum PhysicsUpdraftMode {
  106317. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  106318. Center = 0,
  106319. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  106320. Perpendicular = 1
  106321. }
  106322. /**
  106323. * Interface for a physics force and contact point
  106324. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106325. */
  106326. export interface PhysicsForceAndContactPoint {
  106327. /**
  106328. * The force applied at the contact point
  106329. */
  106330. force: Vector3;
  106331. /**
  106332. * The contact point
  106333. */
  106334. contactPoint: Vector3;
  106335. }
  106336. /**
  106337. * Interface for radial explosion event data
  106338. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106339. */
  106340. export interface PhysicsRadialExplosionEventData {
  106341. /**
  106342. * A sphere used for the radial explosion event
  106343. */
  106344. sphere: Mesh;
  106345. /**
  106346. * An array of rays for the radial explosion event
  106347. */
  106348. rays: Array<Ray>;
  106349. }
  106350. /**
  106351. * Interface for gravitational field event data
  106352. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106353. */
  106354. export interface PhysicsGravitationalFieldEventData {
  106355. /**
  106356. * A sphere mesh used for the gravitational field event
  106357. */
  106358. sphere: Mesh;
  106359. }
  106360. /**
  106361. * Interface for updraft event data
  106362. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106363. */
  106364. export interface PhysicsUpdraftEventData {
  106365. /**
  106366. * A cylinder used for the updraft event
  106367. */
  106368. cylinder: Mesh;
  106369. }
  106370. /**
  106371. * Interface for vortex event data
  106372. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106373. */
  106374. export interface PhysicsVortexEventData {
  106375. /**
  106376. * A cylinder used for the vortex event
  106377. */
  106378. cylinder: Mesh;
  106379. }
  106380. }
  106381. declare module BABYLON {
  106382. /**
  106383. * AmmoJS Physics plugin
  106384. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106385. * @see https://github.com/kripken/ammo.js/
  106386. */
  106387. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  106388. private _useDeltaForWorldStep;
  106389. /**
  106390. * Reference to the Ammo library
  106391. */
  106392. bjsAMMO: any;
  106393. /**
  106394. * Created ammoJS world which physics bodies are added to
  106395. */
  106396. world: any;
  106397. /**
  106398. * Name of the plugin
  106399. */
  106400. name: string;
  106401. private _timeStep;
  106402. private _fixedTimeStep;
  106403. private _maxSteps;
  106404. private _tmpQuaternion;
  106405. private _tmpAmmoTransform;
  106406. private _tmpAmmoQuaternion;
  106407. private _tmpAmmoConcreteContactResultCallback;
  106408. private _collisionConfiguration;
  106409. private _dispatcher;
  106410. private _overlappingPairCache;
  106411. private _solver;
  106412. private _tmpAmmoVectorA;
  106413. private _tmpAmmoVectorB;
  106414. private _tmpAmmoVectorC;
  106415. private _tmpContactCallbackResult;
  106416. private static readonly DISABLE_COLLISION_FLAG;
  106417. private static readonly KINEMATIC_FLAG;
  106418. private static readonly DISABLE_DEACTIVATION_FLAG;
  106419. /**
  106420. * Initializes the ammoJS plugin
  106421. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  106422. * @param ammoInjection can be used to inject your own ammo reference
  106423. */
  106424. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  106425. /**
  106426. * Sets the gravity of the physics world (m/(s^2))
  106427. * @param gravity Gravity to set
  106428. */
  106429. setGravity(gravity: Vector3): void;
  106430. /**
  106431. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  106432. * @param timeStep timestep to use in seconds
  106433. */
  106434. setTimeStep(timeStep: number): void;
  106435. /**
  106436. * 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)
  106437. * @param fixedTimeStep fixedTimeStep to use in seconds
  106438. */
  106439. setFixedTimeStep(fixedTimeStep: number): void;
  106440. /**
  106441. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  106442. * @param maxSteps the maximum number of steps by the physics engine per frame
  106443. */
  106444. setMaxSteps(maxSteps: number): void;
  106445. /**
  106446. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  106447. * @returns the current timestep in seconds
  106448. */
  106449. getTimeStep(): number;
  106450. private _isImpostorInContact;
  106451. private _isImpostorPairInContact;
  106452. private _stepSimulation;
  106453. /**
  106454. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  106455. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  106456. * After the step the babylon meshes are set to the position of the physics imposters
  106457. * @param delta amount of time to step forward
  106458. * @param impostors array of imposters to update before/after the step
  106459. */
  106460. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  106461. private _tmpVector;
  106462. private _tmpMatrix;
  106463. /**
  106464. * Applies an implulse on the imposter
  106465. * @param impostor imposter to apply impulse
  106466. * @param force amount of force to be applied to the imposter
  106467. * @param contactPoint the location to apply the impulse on the imposter
  106468. */
  106469. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  106470. /**
  106471. * Applies a force on the imposter
  106472. * @param impostor imposter to apply force
  106473. * @param force amount of force to be applied to the imposter
  106474. * @param contactPoint the location to apply the force on the imposter
  106475. */
  106476. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  106477. /**
  106478. * Creates a physics body using the plugin
  106479. * @param impostor the imposter to create the physics body on
  106480. */
  106481. generatePhysicsBody(impostor: PhysicsImpostor): void;
  106482. /**
  106483. * Removes the physics body from the imposter and disposes of the body's memory
  106484. * @param impostor imposter to remove the physics body from
  106485. */
  106486. removePhysicsBody(impostor: PhysicsImpostor): void;
  106487. /**
  106488. * Generates a joint
  106489. * @param impostorJoint the imposter joint to create the joint with
  106490. */
  106491. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  106492. /**
  106493. * Removes a joint
  106494. * @param impostorJoint the imposter joint to remove the joint from
  106495. */
  106496. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  106497. private _addMeshVerts;
  106498. private _createShape;
  106499. /**
  106500. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  106501. * @param impostor imposter containing the physics body and babylon object
  106502. */
  106503. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  106504. /**
  106505. * Sets the babylon object's position/rotation from the physics body's position/rotation
  106506. * @param impostor imposter containing the physics body and babylon object
  106507. * @param newPosition new position
  106508. * @param newRotation new rotation
  106509. */
  106510. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  106511. /**
  106512. * If this plugin is supported
  106513. * @returns true if its supported
  106514. */
  106515. isSupported(): boolean;
  106516. /**
  106517. * Sets the linear velocity of the physics body
  106518. * @param impostor imposter to set the velocity on
  106519. * @param velocity velocity to set
  106520. */
  106521. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  106522. /**
  106523. * Sets the angular velocity of the physics body
  106524. * @param impostor imposter to set the velocity on
  106525. * @param velocity velocity to set
  106526. */
  106527. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  106528. /**
  106529. * gets the linear velocity
  106530. * @param impostor imposter to get linear velocity from
  106531. * @returns linear velocity
  106532. */
  106533. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  106534. /**
  106535. * gets the angular velocity
  106536. * @param impostor imposter to get angular velocity from
  106537. * @returns angular velocity
  106538. */
  106539. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  106540. /**
  106541. * Sets the mass of physics body
  106542. * @param impostor imposter to set the mass on
  106543. * @param mass mass to set
  106544. */
  106545. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  106546. /**
  106547. * Gets the mass of the physics body
  106548. * @param impostor imposter to get the mass from
  106549. * @returns mass
  106550. */
  106551. getBodyMass(impostor: PhysicsImpostor): number;
  106552. /**
  106553. * Gets friction of the impostor
  106554. * @param impostor impostor to get friction from
  106555. * @returns friction value
  106556. */
  106557. getBodyFriction(impostor: PhysicsImpostor): number;
  106558. /**
  106559. * Sets friction of the impostor
  106560. * @param impostor impostor to set friction on
  106561. * @param friction friction value
  106562. */
  106563. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  106564. /**
  106565. * Gets restitution of the impostor
  106566. * @param impostor impostor to get restitution from
  106567. * @returns restitution value
  106568. */
  106569. getBodyRestitution(impostor: PhysicsImpostor): number;
  106570. /**
  106571. * Sets resitution of the impostor
  106572. * @param impostor impostor to set resitution on
  106573. * @param restitution resitution value
  106574. */
  106575. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  106576. /**
  106577. * Sleeps the physics body and stops it from being active
  106578. * @param impostor impostor to sleep
  106579. */
  106580. sleepBody(impostor: PhysicsImpostor): void;
  106581. /**
  106582. * Activates the physics body
  106583. * @param impostor impostor to activate
  106584. */
  106585. wakeUpBody(impostor: PhysicsImpostor): void;
  106586. /**
  106587. * Updates the distance parameters of the joint
  106588. * @param joint joint to update
  106589. * @param maxDistance maximum distance of the joint
  106590. * @param minDistance minimum distance of the joint
  106591. */
  106592. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  106593. /**
  106594. * Sets a motor on the joint
  106595. * @param joint joint to set motor on
  106596. * @param speed speed of the motor
  106597. * @param maxForce maximum force of the motor
  106598. * @param motorIndex index of the motor
  106599. */
  106600. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  106601. /**
  106602. * Sets the motors limit
  106603. * @param joint joint to set limit on
  106604. * @param upperLimit upper limit
  106605. * @param lowerLimit lower limit
  106606. */
  106607. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  106608. /**
  106609. * Syncs the position and rotation of a mesh with the impostor
  106610. * @param mesh mesh to sync
  106611. * @param impostor impostor to update the mesh with
  106612. */
  106613. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  106614. /**
  106615. * Gets the radius of the impostor
  106616. * @param impostor impostor to get radius from
  106617. * @returns the radius
  106618. */
  106619. getRadius(impostor: PhysicsImpostor): number;
  106620. /**
  106621. * Gets the box size of the impostor
  106622. * @param impostor impostor to get box size from
  106623. * @param result the resulting box size
  106624. */
  106625. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  106626. /**
  106627. * Disposes of the impostor
  106628. */
  106629. dispose(): void;
  106630. }
  106631. }
  106632. declare module BABYLON {
  106633. /** @hidden */
  106634. export var blackAndWhitePixelShader: {
  106635. name: string;
  106636. shader: string;
  106637. };
  106638. }
  106639. declare module BABYLON {
  106640. /**
  106641. * Post process used to render in black and white
  106642. */
  106643. export class BlackAndWhitePostProcess extends PostProcess {
  106644. /**
  106645. * Linear about to convert he result to black and white (default: 1)
  106646. */
  106647. degree: number;
  106648. /**
  106649. * Creates a black and white post process
  106650. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  106651. * @param name The name of the effect.
  106652. * @param options The required width/height ratio to downsize to before computing the render pass.
  106653. * @param camera The camera to apply the render pass to.
  106654. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106655. * @param engine The engine which the post process will be applied. (default: current engine)
  106656. * @param reusable If the post process can be reused on the same frame. (default: false)
  106657. */
  106658. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  106659. }
  106660. }
  106661. declare module BABYLON {
  106662. /**
  106663. * This represents a set of one or more post processes in Babylon.
  106664. * A post process can be used to apply a shader to a texture after it is rendered.
  106665. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  106666. */
  106667. export class PostProcessRenderEffect {
  106668. private _postProcesses;
  106669. private _getPostProcesses;
  106670. private _singleInstance;
  106671. private _cameras;
  106672. private _indicesForCamera;
  106673. /**
  106674. * Name of the effect
  106675. * @hidden
  106676. */
  106677. _name: string;
  106678. /**
  106679. * Instantiates a post process render effect.
  106680. * A post process can be used to apply a shader to a texture after it is rendered.
  106681. * @param engine The engine the effect is tied to
  106682. * @param name The name of the effect
  106683. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  106684. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  106685. */
  106686. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  106687. /**
  106688. * Checks if all the post processes in the effect are supported.
  106689. */
  106690. readonly isSupported: boolean;
  106691. /**
  106692. * Updates the current state of the effect
  106693. * @hidden
  106694. */
  106695. _update(): void;
  106696. /**
  106697. * Attaches the effect on cameras
  106698. * @param cameras The camera to attach to.
  106699. * @hidden
  106700. */
  106701. _attachCameras(cameras: Camera): void;
  106702. /**
  106703. * Attaches the effect on cameras
  106704. * @param cameras The camera to attach to.
  106705. * @hidden
  106706. */
  106707. _attachCameras(cameras: Camera[]): void;
  106708. /**
  106709. * Detatches the effect on cameras
  106710. * @param cameras The camera to detatch from.
  106711. * @hidden
  106712. */
  106713. _detachCameras(cameras: Camera): void;
  106714. /**
  106715. * Detatches the effect on cameras
  106716. * @param cameras The camera to detatch from.
  106717. * @hidden
  106718. */
  106719. _detachCameras(cameras: Camera[]): void;
  106720. /**
  106721. * Enables the effect on given cameras
  106722. * @param cameras The camera to enable.
  106723. * @hidden
  106724. */
  106725. _enable(cameras: Camera): void;
  106726. /**
  106727. * Enables the effect on given cameras
  106728. * @param cameras The camera to enable.
  106729. * @hidden
  106730. */
  106731. _enable(cameras: Nullable<Camera[]>): void;
  106732. /**
  106733. * Disables the effect on the given cameras
  106734. * @param cameras The camera to disable.
  106735. * @hidden
  106736. */
  106737. _disable(cameras: Camera): void;
  106738. /**
  106739. * Disables the effect on the given cameras
  106740. * @param cameras The camera to disable.
  106741. * @hidden
  106742. */
  106743. _disable(cameras: Nullable<Camera[]>): void;
  106744. /**
  106745. * Gets a list of the post processes contained in the effect.
  106746. * @param camera The camera to get the post processes on.
  106747. * @returns The list of the post processes in the effect.
  106748. */
  106749. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  106750. }
  106751. }
  106752. declare module BABYLON {
  106753. /** @hidden */
  106754. export var extractHighlightsPixelShader: {
  106755. name: string;
  106756. shader: string;
  106757. };
  106758. }
  106759. declare module BABYLON {
  106760. /**
  106761. * 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.
  106762. */
  106763. export class ExtractHighlightsPostProcess extends PostProcess {
  106764. /**
  106765. * The luminance threshold, pixels below this value will be set to black.
  106766. */
  106767. threshold: number;
  106768. /** @hidden */
  106769. _exposure: number;
  106770. /**
  106771. * Post process which has the input texture to be used when performing highlight extraction
  106772. * @hidden
  106773. */
  106774. _inputPostProcess: Nullable<PostProcess>;
  106775. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106776. }
  106777. }
  106778. declare module BABYLON {
  106779. /** @hidden */
  106780. export var bloomMergePixelShader: {
  106781. name: string;
  106782. shader: string;
  106783. };
  106784. }
  106785. declare module BABYLON {
  106786. /**
  106787. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  106788. */
  106789. export class BloomMergePostProcess extends PostProcess {
  106790. /** Weight of the bloom to be added to the original input. */
  106791. weight: number;
  106792. /**
  106793. * Creates a new instance of @see BloomMergePostProcess
  106794. * @param name The name of the effect.
  106795. * @param originalFromInput Post process which's input will be used for the merge.
  106796. * @param blurred Blurred highlights post process which's output will be used.
  106797. * @param weight Weight of the bloom to be added to the original input.
  106798. * @param options The required width/height ratio to downsize to before computing the render pass.
  106799. * @param camera The camera to apply the render pass to.
  106800. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106801. * @param engine The engine which the post process will be applied. (default: current engine)
  106802. * @param reusable If the post process can be reused on the same frame. (default: false)
  106803. * @param textureType Type of textures used when performing the post process. (default: 0)
  106804. * @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)
  106805. */
  106806. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  106807. /** Weight of the bloom to be added to the original input. */
  106808. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106809. }
  106810. }
  106811. declare module BABYLON {
  106812. /**
  106813. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  106814. */
  106815. export class BloomEffect extends PostProcessRenderEffect {
  106816. private bloomScale;
  106817. /**
  106818. * @hidden Internal
  106819. */
  106820. _effects: Array<PostProcess>;
  106821. /**
  106822. * @hidden Internal
  106823. */
  106824. _downscale: ExtractHighlightsPostProcess;
  106825. private _blurX;
  106826. private _blurY;
  106827. private _merge;
  106828. /**
  106829. * The luminance threshold to find bright areas of the image to bloom.
  106830. */
  106831. threshold: number;
  106832. /**
  106833. * The strength of the bloom.
  106834. */
  106835. weight: number;
  106836. /**
  106837. * Specifies the size of the bloom blur kernel, relative to the final output size
  106838. */
  106839. kernel: number;
  106840. /**
  106841. * Creates a new instance of @see BloomEffect
  106842. * @param scene The scene the effect belongs to.
  106843. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  106844. * @param bloomKernel The size of the kernel to be used when applying the blur.
  106845. * @param bloomWeight The the strength of bloom.
  106846. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  106847. * @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)
  106848. */
  106849. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  106850. /**
  106851. * Disposes each of the internal effects for a given camera.
  106852. * @param camera The camera to dispose the effect on.
  106853. */
  106854. disposeEffects(camera: Camera): void;
  106855. /**
  106856. * @hidden Internal
  106857. */
  106858. _updateEffects(): void;
  106859. /**
  106860. * Internal
  106861. * @returns if all the contained post processes are ready.
  106862. * @hidden
  106863. */
  106864. _isReady(): boolean;
  106865. }
  106866. }
  106867. declare module BABYLON {
  106868. /** @hidden */
  106869. export var chromaticAberrationPixelShader: {
  106870. name: string;
  106871. shader: string;
  106872. };
  106873. }
  106874. declare module BABYLON {
  106875. /**
  106876. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  106877. */
  106878. export class ChromaticAberrationPostProcess extends PostProcess {
  106879. /**
  106880. * The amount of seperation of rgb channels (default: 30)
  106881. */
  106882. aberrationAmount: number;
  106883. /**
  106884. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  106885. */
  106886. radialIntensity: number;
  106887. /**
  106888. * 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))
  106889. */
  106890. direction: Vector2;
  106891. /**
  106892. * 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))
  106893. */
  106894. centerPosition: Vector2;
  106895. /**
  106896. * Creates a new instance ChromaticAberrationPostProcess
  106897. * @param name The name of the effect.
  106898. * @param screenWidth The width of the screen to apply the effect on.
  106899. * @param screenHeight The height of the screen to apply the effect on.
  106900. * @param options The required width/height ratio to downsize to before computing the render pass.
  106901. * @param camera The camera to apply the render pass to.
  106902. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106903. * @param engine The engine which the post process will be applied. (default: current engine)
  106904. * @param reusable If the post process can be reused on the same frame. (default: false)
  106905. * @param textureType Type of textures used when performing the post process. (default: 0)
  106906. * @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)
  106907. */
  106908. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106909. }
  106910. }
  106911. declare module BABYLON {
  106912. /** @hidden */
  106913. export var circleOfConfusionPixelShader: {
  106914. name: string;
  106915. shader: string;
  106916. };
  106917. }
  106918. declare module BABYLON {
  106919. /**
  106920. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  106921. */
  106922. export class CircleOfConfusionPostProcess extends PostProcess {
  106923. /**
  106924. * 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.
  106925. */
  106926. lensSize: number;
  106927. /**
  106928. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  106929. */
  106930. fStop: number;
  106931. /**
  106932. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  106933. */
  106934. focusDistance: number;
  106935. /**
  106936. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  106937. */
  106938. focalLength: number;
  106939. private _depthTexture;
  106940. /**
  106941. * Creates a new instance CircleOfConfusionPostProcess
  106942. * @param name The name of the effect.
  106943. * @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.
  106944. * @param options The required width/height ratio to downsize to before computing the render pass.
  106945. * @param camera The camera to apply the render pass to.
  106946. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106947. * @param engine The engine which the post process will be applied. (default: current engine)
  106948. * @param reusable If the post process can be reused on the same frame. (default: false)
  106949. * @param textureType Type of textures used when performing the post process. (default: 0)
  106950. * @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)
  106951. */
  106952. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106953. /**
  106954. * 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.
  106955. */
  106956. depthTexture: RenderTargetTexture;
  106957. }
  106958. }
  106959. declare module BABYLON {
  106960. /** @hidden */
  106961. export var colorCorrectionPixelShader: {
  106962. name: string;
  106963. shader: string;
  106964. };
  106965. }
  106966. declare module BABYLON {
  106967. /**
  106968. *
  106969. * This post-process allows the modification of rendered colors by using
  106970. * a 'look-up table' (LUT). This effect is also called Color Grading.
  106971. *
  106972. * The object needs to be provided an url to a texture containing the color
  106973. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  106974. * Use an image editing software to tweak the LUT to match your needs.
  106975. *
  106976. * For an example of a color LUT, see here:
  106977. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  106978. * For explanations on color grading, see here:
  106979. * @see http://udn.epicgames.com/Three/ColorGrading.html
  106980. *
  106981. */
  106982. export class ColorCorrectionPostProcess extends PostProcess {
  106983. private _colorTableTexture;
  106984. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  106985. }
  106986. }
  106987. declare module BABYLON {
  106988. /** @hidden */
  106989. export var convolutionPixelShader: {
  106990. name: string;
  106991. shader: string;
  106992. };
  106993. }
  106994. declare module BABYLON {
  106995. /**
  106996. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  106997. * input texture to perform effects such as edge detection or sharpening
  106998. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  106999. */
  107000. export class ConvolutionPostProcess extends PostProcess {
  107001. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  107002. kernel: number[];
  107003. /**
  107004. * Creates a new instance ConvolutionPostProcess
  107005. * @param name The name of the effect.
  107006. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  107007. * @param options The required width/height ratio to downsize to before computing the render pass.
  107008. * @param camera The camera to apply the render pass to.
  107009. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107010. * @param engine The engine which the post process will be applied. (default: current engine)
  107011. * @param reusable If the post process can be reused on the same frame. (default: false)
  107012. * @param textureType Type of textures used when performing the post process. (default: 0)
  107013. */
  107014. constructor(name: string,
  107015. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  107016. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  107017. /**
  107018. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  107019. */
  107020. static EdgeDetect0Kernel: number[];
  107021. /**
  107022. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  107023. */
  107024. static EdgeDetect1Kernel: number[];
  107025. /**
  107026. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  107027. */
  107028. static EdgeDetect2Kernel: number[];
  107029. /**
  107030. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  107031. */
  107032. static SharpenKernel: number[];
  107033. /**
  107034. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  107035. */
  107036. static EmbossKernel: number[];
  107037. /**
  107038. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  107039. */
  107040. static GaussianKernel: number[];
  107041. }
  107042. }
  107043. declare module BABYLON {
  107044. /**
  107045. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  107046. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  107047. * based on samples that have a large difference in distance than the center pixel.
  107048. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  107049. */
  107050. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  107051. direction: Vector2;
  107052. /**
  107053. * Creates a new instance CircleOfConfusionPostProcess
  107054. * @param name The name of the effect.
  107055. * @param scene The scene the effect belongs to.
  107056. * @param direction The direction the blur should be applied.
  107057. * @param kernel The size of the kernel used to blur.
  107058. * @param options The required width/height ratio to downsize to before computing the render pass.
  107059. * @param camera The camera to apply the render pass to.
  107060. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  107061. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  107062. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107063. * @param engine The engine which the post process will be applied. (default: current engine)
  107064. * @param reusable If the post process can be reused on the same frame. (default: false)
  107065. * @param textureType Type of textures used when performing the post process. (default: 0)
  107066. * @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)
  107067. */
  107068. 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);
  107069. }
  107070. }
  107071. declare module BABYLON {
  107072. /** @hidden */
  107073. export var depthOfFieldMergePixelShader: {
  107074. name: string;
  107075. shader: string;
  107076. };
  107077. }
  107078. declare module BABYLON {
  107079. /**
  107080. * Options to be set when merging outputs from the default pipeline.
  107081. */
  107082. export class DepthOfFieldMergePostProcessOptions {
  107083. /**
  107084. * The original image to merge on top of
  107085. */
  107086. originalFromInput: PostProcess;
  107087. /**
  107088. * Parameters to perform the merge of the depth of field effect
  107089. */
  107090. depthOfField?: {
  107091. circleOfConfusion: PostProcess;
  107092. blurSteps: Array<PostProcess>;
  107093. };
  107094. /**
  107095. * Parameters to perform the merge of bloom effect
  107096. */
  107097. bloom?: {
  107098. blurred: PostProcess;
  107099. weight: number;
  107100. };
  107101. }
  107102. /**
  107103. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  107104. */
  107105. export class DepthOfFieldMergePostProcess extends PostProcess {
  107106. private blurSteps;
  107107. /**
  107108. * Creates a new instance of DepthOfFieldMergePostProcess
  107109. * @param name The name of the effect.
  107110. * @param originalFromInput Post process which's input will be used for the merge.
  107111. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  107112. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  107113. * @param options The required width/height ratio to downsize to before computing the render pass.
  107114. * @param camera The camera to apply the render pass to.
  107115. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107116. * @param engine The engine which the post process will be applied. (default: current engine)
  107117. * @param reusable If the post process can be reused on the same frame. (default: false)
  107118. * @param textureType Type of textures used when performing the post process. (default: 0)
  107119. * @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)
  107120. */
  107121. 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);
  107122. /**
  107123. * Updates the effect with the current post process compile time values and recompiles the shader.
  107124. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  107125. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  107126. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  107127. * @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
  107128. * @param onCompiled Called when the shader has been compiled.
  107129. * @param onError Called if there is an error when compiling a shader.
  107130. */
  107131. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  107132. }
  107133. }
  107134. declare module BABYLON {
  107135. /**
  107136. * Specifies the level of max blur that should be applied when using the depth of field effect
  107137. */
  107138. export enum DepthOfFieldEffectBlurLevel {
  107139. /**
  107140. * Subtle blur
  107141. */
  107142. Low = 0,
  107143. /**
  107144. * Medium blur
  107145. */
  107146. Medium = 1,
  107147. /**
  107148. * Large blur
  107149. */
  107150. High = 2
  107151. }
  107152. /**
  107153. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  107154. */
  107155. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  107156. private _circleOfConfusion;
  107157. /**
  107158. * @hidden Internal, blurs from high to low
  107159. */
  107160. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  107161. private _depthOfFieldBlurY;
  107162. private _dofMerge;
  107163. /**
  107164. * @hidden Internal post processes in depth of field effect
  107165. */
  107166. _effects: Array<PostProcess>;
  107167. /**
  107168. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  107169. */
  107170. focalLength: number;
  107171. /**
  107172. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  107173. */
  107174. fStop: number;
  107175. /**
  107176. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  107177. */
  107178. focusDistance: number;
  107179. /**
  107180. * 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.
  107181. */
  107182. lensSize: number;
  107183. /**
  107184. * Creates a new instance DepthOfFieldEffect
  107185. * @param scene The scene the effect belongs to.
  107186. * @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.
  107187. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  107188. * @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)
  107189. */
  107190. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  107191. /**
  107192. * 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.
  107193. */
  107194. depthTexture: RenderTargetTexture;
  107195. /**
  107196. * Disposes each of the internal effects for a given camera.
  107197. * @param camera The camera to dispose the effect on.
  107198. */
  107199. disposeEffects(camera: Camera): void;
  107200. /**
  107201. * @hidden Internal
  107202. */
  107203. _updateEffects(): void;
  107204. /**
  107205. * Internal
  107206. * @returns if all the contained post processes are ready.
  107207. * @hidden
  107208. */
  107209. _isReady(): boolean;
  107210. }
  107211. }
  107212. declare module BABYLON {
  107213. /** @hidden */
  107214. export var displayPassPixelShader: {
  107215. name: string;
  107216. shader: string;
  107217. };
  107218. }
  107219. declare module BABYLON {
  107220. /**
  107221. * DisplayPassPostProcess which produces an output the same as it's input
  107222. */
  107223. export class DisplayPassPostProcess extends PostProcess {
  107224. /**
  107225. * Creates the DisplayPassPostProcess
  107226. * @param name The name of the effect.
  107227. * @param options The required width/height ratio to downsize to before computing the render pass.
  107228. * @param camera The camera to apply the render pass to.
  107229. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107230. * @param engine The engine which the post process will be applied. (default: current engine)
  107231. * @param reusable If the post process can be reused on the same frame. (default: false)
  107232. */
  107233. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  107234. }
  107235. }
  107236. declare module BABYLON {
  107237. /** @hidden */
  107238. export var filterPixelShader: {
  107239. name: string;
  107240. shader: string;
  107241. };
  107242. }
  107243. declare module BABYLON {
  107244. /**
  107245. * Applies a kernel filter to the image
  107246. */
  107247. export class FilterPostProcess extends PostProcess {
  107248. /** The matrix to be applied to the image */
  107249. kernelMatrix: Matrix;
  107250. /**
  107251. *
  107252. * @param name The name of the effect.
  107253. * @param kernelMatrix The matrix to be applied to the image
  107254. * @param options The required width/height ratio to downsize to before computing the render pass.
  107255. * @param camera The camera to apply the render pass to.
  107256. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107257. * @param engine The engine which the post process will be applied. (default: current engine)
  107258. * @param reusable If the post process can be reused on the same frame. (default: false)
  107259. */
  107260. constructor(name: string,
  107261. /** The matrix to be applied to the image */
  107262. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  107263. }
  107264. }
  107265. declare module BABYLON {
  107266. /** @hidden */
  107267. export var fxaaPixelShader: {
  107268. name: string;
  107269. shader: string;
  107270. };
  107271. }
  107272. declare module BABYLON {
  107273. /** @hidden */
  107274. export var fxaaVertexShader: {
  107275. name: string;
  107276. shader: string;
  107277. };
  107278. }
  107279. declare module BABYLON {
  107280. /**
  107281. * Fxaa post process
  107282. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  107283. */
  107284. export class FxaaPostProcess extends PostProcess {
  107285. /** @hidden */
  107286. texelWidth: number;
  107287. /** @hidden */
  107288. texelHeight: number;
  107289. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  107290. private _getDefines;
  107291. }
  107292. }
  107293. declare module BABYLON {
  107294. /** @hidden */
  107295. export var grainPixelShader: {
  107296. name: string;
  107297. shader: string;
  107298. };
  107299. }
  107300. declare module BABYLON {
  107301. /**
  107302. * The GrainPostProcess adds noise to the image at mid luminance levels
  107303. */
  107304. export class GrainPostProcess extends PostProcess {
  107305. /**
  107306. * The intensity of the grain added (default: 30)
  107307. */
  107308. intensity: number;
  107309. /**
  107310. * If the grain should be randomized on every frame
  107311. */
  107312. animated: boolean;
  107313. /**
  107314. * Creates a new instance of @see GrainPostProcess
  107315. * @param name The name of the effect.
  107316. * @param options The required width/height ratio to downsize to before computing the render pass.
  107317. * @param camera The camera to apply the render pass to.
  107318. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107319. * @param engine The engine which the post process will be applied. (default: current engine)
  107320. * @param reusable If the post process can be reused on the same frame. (default: false)
  107321. * @param textureType Type of textures used when performing the post process. (default: 0)
  107322. * @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)
  107323. */
  107324. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  107325. }
  107326. }
  107327. declare module BABYLON {
  107328. /** @hidden */
  107329. export var highlightsPixelShader: {
  107330. name: string;
  107331. shader: string;
  107332. };
  107333. }
  107334. declare module BABYLON {
  107335. /**
  107336. * Extracts highlights from the image
  107337. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  107338. */
  107339. export class HighlightsPostProcess extends PostProcess {
  107340. /**
  107341. * Extracts highlights from the image
  107342. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  107343. * @param name The name of the effect.
  107344. * @param options The required width/height ratio to downsize to before computing the render pass.
  107345. * @param camera The camera to apply the render pass to.
  107346. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107347. * @param engine The engine which the post process will be applied. (default: current engine)
  107348. * @param reusable If the post process can be reused on the same frame. (default: false)
  107349. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  107350. */
  107351. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  107352. }
  107353. }
  107354. declare module BABYLON {
  107355. /** @hidden */
  107356. export var mrtFragmentDeclaration: {
  107357. name: string;
  107358. shader: string;
  107359. };
  107360. }
  107361. declare module BABYLON {
  107362. /** @hidden */
  107363. export var geometryPixelShader: {
  107364. name: string;
  107365. shader: string;
  107366. };
  107367. }
  107368. declare module BABYLON {
  107369. /** @hidden */
  107370. export var geometryVertexShader: {
  107371. name: string;
  107372. shader: string;
  107373. };
  107374. }
  107375. declare module BABYLON {
  107376. /**
  107377. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  107378. */
  107379. export class GeometryBufferRenderer {
  107380. /**
  107381. * Constant used to retrieve the position texture index in the G-Buffer textures array
  107382. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  107383. */
  107384. static readonly POSITION_TEXTURE_TYPE: number;
  107385. /**
  107386. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  107387. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  107388. */
  107389. static readonly VELOCITY_TEXTURE_TYPE: number;
  107390. /**
  107391. * Dictionary used to store the previous transformation matrices of each rendered mesh
  107392. * in order to compute objects velocities when enableVelocity is set to "true"
  107393. * @hidden
  107394. */
  107395. _previousTransformationMatrices: {
  107396. [index: number]: Matrix;
  107397. };
  107398. private _scene;
  107399. private _multiRenderTarget;
  107400. private _ratio;
  107401. private _enablePosition;
  107402. private _enableVelocity;
  107403. private _positionIndex;
  107404. private _velocityIndex;
  107405. protected _effect: Effect;
  107406. protected _cachedDefines: string;
  107407. /**
  107408. * Set the render list (meshes to be rendered) used in the G buffer.
  107409. */
  107410. renderList: Mesh[];
  107411. /**
  107412. * Gets wether or not G buffer are supported by the running hardware.
  107413. * This requires draw buffer supports
  107414. */
  107415. readonly isSupported: boolean;
  107416. /**
  107417. * Returns the index of the given texture type in the G-Buffer textures array
  107418. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  107419. * @returns the index of the given texture type in the G-Buffer textures array
  107420. */
  107421. getTextureIndex(textureType: number): number;
  107422. /**
  107423. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  107424. */
  107425. /**
  107426. * Sets whether or not objects positions are enabled for the G buffer.
  107427. */
  107428. enablePosition: boolean;
  107429. /**
  107430. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  107431. */
  107432. /**
  107433. * Sets wether or not objects velocities are enabled for the G buffer.
  107434. */
  107435. enableVelocity: boolean;
  107436. /**
  107437. * Gets the scene associated with the buffer.
  107438. */
  107439. readonly scene: Scene;
  107440. /**
  107441. * Gets the ratio used by the buffer during its creation.
  107442. * How big is the buffer related to the main canvas.
  107443. */
  107444. readonly ratio: number;
  107445. /** @hidden */
  107446. static _SceneComponentInitialization: (scene: Scene) => void;
  107447. /**
  107448. * Creates a new G Buffer for the scene
  107449. * @param scene The scene the buffer belongs to
  107450. * @param ratio How big is the buffer related to the main canvas.
  107451. */
  107452. constructor(scene: Scene, ratio?: number);
  107453. /**
  107454. * Checks wether everything is ready to render a submesh to the G buffer.
  107455. * @param subMesh the submesh to check readiness for
  107456. * @param useInstances is the mesh drawn using instance or not
  107457. * @returns true if ready otherwise false
  107458. */
  107459. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  107460. /**
  107461. * Gets the current underlying G Buffer.
  107462. * @returns the buffer
  107463. */
  107464. getGBuffer(): MultiRenderTarget;
  107465. /**
  107466. * Gets the number of samples used to render the buffer (anti aliasing).
  107467. */
  107468. /**
  107469. * Sets the number of samples used to render the buffer (anti aliasing).
  107470. */
  107471. samples: number;
  107472. /**
  107473. * Disposes the renderer and frees up associated resources.
  107474. */
  107475. dispose(): void;
  107476. protected _createRenderTargets(): void;
  107477. }
  107478. }
  107479. declare module BABYLON {
  107480. /** @hidden */
  107481. export var motionBlurPixelShader: {
  107482. name: string;
  107483. shader: string;
  107484. };
  107485. }
  107486. declare module BABYLON {
  107487. /**
  107488. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  107489. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  107490. * As an example, all you have to do is to create the post-process:
  107491. * var mb = new BABYLON.MotionBlurPostProcess(
  107492. * 'mb', // The name of the effect.
  107493. * scene, // The scene containing the objects to blur according to their velocity.
  107494. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  107495. * camera // The camera to apply the render pass to.
  107496. * );
  107497. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  107498. */
  107499. export class MotionBlurPostProcess extends PostProcess {
  107500. /**
  107501. * Defines how much the image is blurred by the movement. Default value is equal to 1
  107502. */
  107503. motionStrength: number;
  107504. /**
  107505. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  107506. */
  107507. /**
  107508. * Sets the number of iterations to be used for motion blur quality
  107509. */
  107510. motionBlurSamples: number;
  107511. private _motionBlurSamples;
  107512. private _geometryBufferRenderer;
  107513. /**
  107514. * Creates a new instance MotionBlurPostProcess
  107515. * @param name The name of the effect.
  107516. * @param scene The scene containing the objects to blur according to their velocity.
  107517. * @param options The required width/height ratio to downsize to before computing the render pass.
  107518. * @param camera The camera to apply the render pass to.
  107519. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107520. * @param engine The engine which the post process will be applied. (default: current engine)
  107521. * @param reusable If the post process can be reused on the same frame. (default: false)
  107522. * @param textureType Type of textures used when performing the post process. (default: 0)
  107523. * @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)
  107524. */
  107525. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  107526. /**
  107527. * Disposes the post process.
  107528. * @param camera The camera to dispose the post process on.
  107529. */
  107530. dispose(camera?: Camera): void;
  107531. }
  107532. }
  107533. declare module BABYLON {
  107534. /** @hidden */
  107535. export var refractionPixelShader: {
  107536. name: string;
  107537. shader: string;
  107538. };
  107539. }
  107540. declare module BABYLON {
  107541. /**
  107542. * Post process which applies a refractin texture
  107543. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  107544. */
  107545. export class RefractionPostProcess extends PostProcess {
  107546. /** the base color of the refraction (used to taint the rendering) */
  107547. color: Color3;
  107548. /** simulated refraction depth */
  107549. depth: number;
  107550. /** the coefficient of the base color (0 to remove base color tainting) */
  107551. colorLevel: number;
  107552. private _refTexture;
  107553. private _ownRefractionTexture;
  107554. /**
  107555. * Gets or sets the refraction texture
  107556. * Please note that you are responsible for disposing the texture if you set it manually
  107557. */
  107558. refractionTexture: Texture;
  107559. /**
  107560. * Initializes the RefractionPostProcess
  107561. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  107562. * @param name The name of the effect.
  107563. * @param refractionTextureUrl Url of the refraction texture to use
  107564. * @param color the base color of the refraction (used to taint the rendering)
  107565. * @param depth simulated refraction depth
  107566. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  107567. * @param camera The camera to apply the render pass to.
  107568. * @param options The required width/height ratio to downsize to before computing the render pass.
  107569. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107570. * @param engine The engine which the post process will be applied. (default: current engine)
  107571. * @param reusable If the post process can be reused on the same frame. (default: false)
  107572. */
  107573. constructor(name: string, refractionTextureUrl: string,
  107574. /** the base color of the refraction (used to taint the rendering) */
  107575. color: Color3,
  107576. /** simulated refraction depth */
  107577. depth: number,
  107578. /** the coefficient of the base color (0 to remove base color tainting) */
  107579. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  107580. /**
  107581. * Disposes of the post process
  107582. * @param camera Camera to dispose post process on
  107583. */
  107584. dispose(camera: Camera): void;
  107585. }
  107586. }
  107587. declare module BABYLON {
  107588. /** @hidden */
  107589. export var sharpenPixelShader: {
  107590. name: string;
  107591. shader: string;
  107592. };
  107593. }
  107594. declare module BABYLON {
  107595. /**
  107596. * The SharpenPostProcess applies a sharpen kernel to every pixel
  107597. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  107598. */
  107599. export class SharpenPostProcess extends PostProcess {
  107600. /**
  107601. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  107602. */
  107603. colorAmount: number;
  107604. /**
  107605. * How much sharpness should be applied (default: 0.3)
  107606. */
  107607. edgeAmount: number;
  107608. /**
  107609. * Creates a new instance ConvolutionPostProcess
  107610. * @param name The name of the effect.
  107611. * @param options The required width/height ratio to downsize to before computing the render pass.
  107612. * @param camera The camera to apply the render pass to.
  107613. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107614. * @param engine The engine which the post process will be applied. (default: current engine)
  107615. * @param reusable If the post process can be reused on the same frame. (default: false)
  107616. * @param textureType Type of textures used when performing the post process. (default: 0)
  107617. * @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)
  107618. */
  107619. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  107620. }
  107621. }
  107622. declare module BABYLON {
  107623. /**
  107624. * PostProcessRenderPipeline
  107625. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  107626. */
  107627. export class PostProcessRenderPipeline {
  107628. private engine;
  107629. private _renderEffects;
  107630. private _renderEffectsForIsolatedPass;
  107631. /**
  107632. * @hidden
  107633. */
  107634. protected _cameras: Camera[];
  107635. /** @hidden */
  107636. _name: string;
  107637. /**
  107638. * Gets pipeline name
  107639. */
  107640. readonly name: string;
  107641. /**
  107642. * Initializes a PostProcessRenderPipeline
  107643. * @param engine engine to add the pipeline to
  107644. * @param name name of the pipeline
  107645. */
  107646. constructor(engine: Engine, name: string);
  107647. /**
  107648. * Gets the class name
  107649. * @returns "PostProcessRenderPipeline"
  107650. */
  107651. getClassName(): string;
  107652. /**
  107653. * If all the render effects in the pipeline are supported
  107654. */
  107655. readonly isSupported: boolean;
  107656. /**
  107657. * Adds an effect to the pipeline
  107658. * @param renderEffect the effect to add
  107659. */
  107660. addEffect(renderEffect: PostProcessRenderEffect): void;
  107661. /** @hidden */
  107662. _rebuild(): void;
  107663. /** @hidden */
  107664. _enableEffect(renderEffectName: string, cameras: Camera): void;
  107665. /** @hidden */
  107666. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  107667. /** @hidden */
  107668. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  107669. /** @hidden */
  107670. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  107671. /** @hidden */
  107672. _attachCameras(cameras: Camera, unique: boolean): void;
  107673. /** @hidden */
  107674. _attachCameras(cameras: Camera[], unique: boolean): void;
  107675. /** @hidden */
  107676. _detachCameras(cameras: Camera): void;
  107677. /** @hidden */
  107678. _detachCameras(cameras: Nullable<Camera[]>): void;
  107679. /** @hidden */
  107680. _update(): void;
  107681. /** @hidden */
  107682. _reset(): void;
  107683. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  107684. /**
  107685. * Disposes of the pipeline
  107686. */
  107687. dispose(): void;
  107688. }
  107689. }
  107690. declare module BABYLON {
  107691. /**
  107692. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  107693. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  107694. */
  107695. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  107696. private _scene;
  107697. private _camerasToBeAttached;
  107698. /**
  107699. * ID of the sharpen post process,
  107700. */
  107701. private readonly SharpenPostProcessId;
  107702. /**
  107703. * @ignore
  107704. * ID of the image processing post process;
  107705. */
  107706. readonly ImageProcessingPostProcessId: string;
  107707. /**
  107708. * @ignore
  107709. * ID of the Fast Approximate Anti-Aliasing post process;
  107710. */
  107711. readonly FxaaPostProcessId: string;
  107712. /**
  107713. * ID of the chromatic aberration post process,
  107714. */
  107715. private readonly ChromaticAberrationPostProcessId;
  107716. /**
  107717. * ID of the grain post process
  107718. */
  107719. private readonly GrainPostProcessId;
  107720. /**
  107721. * Sharpen post process which will apply a sharpen convolution to enhance edges
  107722. */
  107723. sharpen: SharpenPostProcess;
  107724. private _sharpenEffect;
  107725. private bloom;
  107726. /**
  107727. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  107728. */
  107729. depthOfField: DepthOfFieldEffect;
  107730. /**
  107731. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  107732. */
  107733. fxaa: FxaaPostProcess;
  107734. /**
  107735. * Image post processing pass used to perform operations such as tone mapping or color grading.
  107736. */
  107737. imageProcessing: ImageProcessingPostProcess;
  107738. /**
  107739. * Chromatic aberration post process which will shift rgb colors in the image
  107740. */
  107741. chromaticAberration: ChromaticAberrationPostProcess;
  107742. private _chromaticAberrationEffect;
  107743. /**
  107744. * Grain post process which add noise to the image
  107745. */
  107746. grain: GrainPostProcess;
  107747. private _grainEffect;
  107748. /**
  107749. * Glow post process which adds a glow to emissive areas of the image
  107750. */
  107751. private _glowLayer;
  107752. /**
  107753. * Animations which can be used to tweak settings over a period of time
  107754. */
  107755. animations: Animation[];
  107756. private _imageProcessingConfigurationObserver;
  107757. private _sharpenEnabled;
  107758. private _bloomEnabled;
  107759. private _depthOfFieldEnabled;
  107760. private _depthOfFieldBlurLevel;
  107761. private _fxaaEnabled;
  107762. private _imageProcessingEnabled;
  107763. private _defaultPipelineTextureType;
  107764. private _bloomScale;
  107765. private _chromaticAberrationEnabled;
  107766. private _grainEnabled;
  107767. private _buildAllowed;
  107768. /**
  107769. * Gets active scene
  107770. */
  107771. readonly scene: Scene;
  107772. /**
  107773. * Enable or disable the sharpen process from the pipeline
  107774. */
  107775. sharpenEnabled: boolean;
  107776. private _resizeObserver;
  107777. private _hardwareScaleLevel;
  107778. private _bloomKernel;
  107779. /**
  107780. * Specifies the size of the bloom blur kernel, relative to the final output size
  107781. */
  107782. bloomKernel: number;
  107783. /**
  107784. * Specifies the weight of the bloom in the final rendering
  107785. */
  107786. private _bloomWeight;
  107787. /**
  107788. * Specifies the luma threshold for the area that will be blurred by the bloom
  107789. */
  107790. private _bloomThreshold;
  107791. private _hdr;
  107792. /**
  107793. * The strength of the bloom.
  107794. */
  107795. bloomWeight: number;
  107796. /**
  107797. * The strength of the bloom.
  107798. */
  107799. bloomThreshold: number;
  107800. /**
  107801. * The scale of the bloom, lower value will provide better performance.
  107802. */
  107803. bloomScale: number;
  107804. /**
  107805. * Enable or disable the bloom from the pipeline
  107806. */
  107807. bloomEnabled: boolean;
  107808. private _rebuildBloom;
  107809. /**
  107810. * If the depth of field is enabled.
  107811. */
  107812. depthOfFieldEnabled: boolean;
  107813. /**
  107814. * Blur level of the depth of field effect. (Higher blur will effect performance)
  107815. */
  107816. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  107817. /**
  107818. * If the anti aliasing is enabled.
  107819. */
  107820. fxaaEnabled: boolean;
  107821. private _samples;
  107822. /**
  107823. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  107824. */
  107825. samples: number;
  107826. /**
  107827. * If image processing is enabled.
  107828. */
  107829. imageProcessingEnabled: boolean;
  107830. /**
  107831. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  107832. */
  107833. glowLayerEnabled: boolean;
  107834. /**
  107835. * Enable or disable the chromaticAberration process from the pipeline
  107836. */
  107837. chromaticAberrationEnabled: boolean;
  107838. /**
  107839. * Enable or disable the grain process from the pipeline
  107840. */
  107841. grainEnabled: boolean;
  107842. /**
  107843. * @constructor
  107844. * @param name - The rendering pipeline name (default: "")
  107845. * @param hdr - If high dynamic range textures should be used (default: true)
  107846. * @param scene - The scene linked to this pipeline (default: the last created scene)
  107847. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  107848. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  107849. */
  107850. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  107851. /**
  107852. * Get the class name
  107853. * @returns "DefaultRenderingPipeline"
  107854. */
  107855. getClassName(): string;
  107856. /**
  107857. * Force the compilation of the entire pipeline.
  107858. */
  107859. prepare(): void;
  107860. private _hasCleared;
  107861. private _prevPostProcess;
  107862. private _prevPrevPostProcess;
  107863. private _setAutoClearAndTextureSharing;
  107864. private _depthOfFieldSceneObserver;
  107865. private _buildPipeline;
  107866. private _disposePostProcesses;
  107867. /**
  107868. * Adds a camera to the pipeline
  107869. * @param camera the camera to be added
  107870. */
  107871. addCamera(camera: Camera): void;
  107872. /**
  107873. * Removes a camera from the pipeline
  107874. * @param camera the camera to remove
  107875. */
  107876. removeCamera(camera: Camera): void;
  107877. /**
  107878. * Dispose of the pipeline and stop all post processes
  107879. */
  107880. dispose(): void;
  107881. /**
  107882. * Serialize the rendering pipeline (Used when exporting)
  107883. * @returns the serialized object
  107884. */
  107885. serialize(): any;
  107886. /**
  107887. * Parse the serialized pipeline
  107888. * @param source Source pipeline.
  107889. * @param scene The scene to load the pipeline to.
  107890. * @param rootUrl The URL of the serialized pipeline.
  107891. * @returns An instantiated pipeline from the serialized object.
  107892. */
  107893. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  107894. }
  107895. }
  107896. declare module BABYLON {
  107897. /** @hidden */
  107898. export var lensHighlightsPixelShader: {
  107899. name: string;
  107900. shader: string;
  107901. };
  107902. }
  107903. declare module BABYLON {
  107904. /** @hidden */
  107905. export var depthOfFieldPixelShader: {
  107906. name: string;
  107907. shader: string;
  107908. };
  107909. }
  107910. declare module BABYLON {
  107911. /**
  107912. * BABYLON.JS Chromatic Aberration GLSL Shader
  107913. * Author: Olivier Guyot
  107914. * Separates very slightly R, G and B colors on the edges of the screen
  107915. * Inspired by Francois Tarlier & Martins Upitis
  107916. */
  107917. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  107918. /**
  107919. * @ignore
  107920. * The chromatic aberration PostProcess id in the pipeline
  107921. */
  107922. LensChromaticAberrationEffect: string;
  107923. /**
  107924. * @ignore
  107925. * The highlights enhancing PostProcess id in the pipeline
  107926. */
  107927. HighlightsEnhancingEffect: string;
  107928. /**
  107929. * @ignore
  107930. * The depth-of-field PostProcess id in the pipeline
  107931. */
  107932. LensDepthOfFieldEffect: string;
  107933. private _scene;
  107934. private _depthTexture;
  107935. private _grainTexture;
  107936. private _chromaticAberrationPostProcess;
  107937. private _highlightsPostProcess;
  107938. private _depthOfFieldPostProcess;
  107939. private _edgeBlur;
  107940. private _grainAmount;
  107941. private _chromaticAberration;
  107942. private _distortion;
  107943. private _highlightsGain;
  107944. private _highlightsThreshold;
  107945. private _dofDistance;
  107946. private _dofAperture;
  107947. private _dofDarken;
  107948. private _dofPentagon;
  107949. private _blurNoise;
  107950. /**
  107951. * @constructor
  107952. *
  107953. * Effect parameters are as follow:
  107954. * {
  107955. * chromatic_aberration: number; // from 0 to x (1 for realism)
  107956. * edge_blur: number; // from 0 to x (1 for realism)
  107957. * distortion: number; // from 0 to x (1 for realism)
  107958. * grain_amount: number; // from 0 to 1
  107959. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  107960. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  107961. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  107962. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  107963. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  107964. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  107965. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  107966. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  107967. * }
  107968. * Note: if an effect parameter is unset, effect is disabled
  107969. *
  107970. * @param name The rendering pipeline name
  107971. * @param parameters - An object containing all parameters (see above)
  107972. * @param scene The scene linked to this pipeline
  107973. * @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)
  107974. * @param cameras The array of cameras that the rendering pipeline will be attached to
  107975. */
  107976. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  107977. /**
  107978. * Sets the amount of blur at the edges
  107979. * @param amount blur amount
  107980. */
  107981. setEdgeBlur(amount: number): void;
  107982. /**
  107983. * Sets edge blur to 0
  107984. */
  107985. disableEdgeBlur(): void;
  107986. /**
  107987. * Sets the amout of grain
  107988. * @param amount Amount of grain
  107989. */
  107990. setGrainAmount(amount: number): void;
  107991. /**
  107992. * Set grain amount to 0
  107993. */
  107994. disableGrain(): void;
  107995. /**
  107996. * Sets the chromatic aberration amount
  107997. * @param amount amount of chromatic aberration
  107998. */
  107999. setChromaticAberration(amount: number): void;
  108000. /**
  108001. * Sets chromatic aberration amount to 0
  108002. */
  108003. disableChromaticAberration(): void;
  108004. /**
  108005. * Sets the EdgeDistortion amount
  108006. * @param amount amount of EdgeDistortion
  108007. */
  108008. setEdgeDistortion(amount: number): void;
  108009. /**
  108010. * Sets edge distortion to 0
  108011. */
  108012. disableEdgeDistortion(): void;
  108013. /**
  108014. * Sets the FocusDistance amount
  108015. * @param amount amount of FocusDistance
  108016. */
  108017. setFocusDistance(amount: number): void;
  108018. /**
  108019. * Disables depth of field
  108020. */
  108021. disableDepthOfField(): void;
  108022. /**
  108023. * Sets the Aperture amount
  108024. * @param amount amount of Aperture
  108025. */
  108026. setAperture(amount: number): void;
  108027. /**
  108028. * Sets the DarkenOutOfFocus amount
  108029. * @param amount amount of DarkenOutOfFocus
  108030. */
  108031. setDarkenOutOfFocus(amount: number): void;
  108032. /**
  108033. * Creates a pentagon bokeh effect
  108034. */
  108035. enablePentagonBokeh(): void;
  108036. /**
  108037. * Disables the pentagon bokeh effect
  108038. */
  108039. disablePentagonBokeh(): void;
  108040. /**
  108041. * Enables noise blur
  108042. */
  108043. enableNoiseBlur(): void;
  108044. /**
  108045. * Disables noise blur
  108046. */
  108047. disableNoiseBlur(): void;
  108048. /**
  108049. * Sets the HighlightsGain amount
  108050. * @param amount amount of HighlightsGain
  108051. */
  108052. setHighlightsGain(amount: number): void;
  108053. /**
  108054. * Sets the HighlightsThreshold amount
  108055. * @param amount amount of HighlightsThreshold
  108056. */
  108057. setHighlightsThreshold(amount: number): void;
  108058. /**
  108059. * Disables highlights
  108060. */
  108061. disableHighlights(): void;
  108062. /**
  108063. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  108064. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  108065. */
  108066. dispose(disableDepthRender?: boolean): void;
  108067. private _createChromaticAberrationPostProcess;
  108068. private _createHighlightsPostProcess;
  108069. private _createDepthOfFieldPostProcess;
  108070. private _createGrainTexture;
  108071. }
  108072. }
  108073. declare module BABYLON {
  108074. /** @hidden */
  108075. export var ssao2PixelShader: {
  108076. name: string;
  108077. shader: string;
  108078. };
  108079. }
  108080. declare module BABYLON {
  108081. /** @hidden */
  108082. export var ssaoCombinePixelShader: {
  108083. name: string;
  108084. shader: string;
  108085. };
  108086. }
  108087. declare module BABYLON {
  108088. /**
  108089. * Render pipeline to produce ssao effect
  108090. */
  108091. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  108092. /**
  108093. * @ignore
  108094. * The PassPostProcess id in the pipeline that contains the original scene color
  108095. */
  108096. SSAOOriginalSceneColorEffect: string;
  108097. /**
  108098. * @ignore
  108099. * The SSAO PostProcess id in the pipeline
  108100. */
  108101. SSAORenderEffect: string;
  108102. /**
  108103. * @ignore
  108104. * The horizontal blur PostProcess id in the pipeline
  108105. */
  108106. SSAOBlurHRenderEffect: string;
  108107. /**
  108108. * @ignore
  108109. * The vertical blur PostProcess id in the pipeline
  108110. */
  108111. SSAOBlurVRenderEffect: string;
  108112. /**
  108113. * @ignore
  108114. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  108115. */
  108116. SSAOCombineRenderEffect: string;
  108117. /**
  108118. * The output strength of the SSAO post-process. Default value is 1.0.
  108119. */
  108120. totalStrength: number;
  108121. /**
  108122. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  108123. */
  108124. maxZ: number;
  108125. /**
  108126. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  108127. */
  108128. minZAspect: number;
  108129. private _samples;
  108130. /**
  108131. * Number of samples used for the SSAO calculations. Default value is 8
  108132. */
  108133. samples: number;
  108134. private _textureSamples;
  108135. /**
  108136. * Number of samples to use for antialiasing
  108137. */
  108138. textureSamples: number;
  108139. /**
  108140. * Ratio object used for SSAO ratio and blur ratio
  108141. */
  108142. private _ratio;
  108143. /**
  108144. * Dynamically generated sphere sampler.
  108145. */
  108146. private _sampleSphere;
  108147. /**
  108148. * Blur filter offsets
  108149. */
  108150. private _samplerOffsets;
  108151. private _expensiveBlur;
  108152. /**
  108153. * If bilateral blur should be used
  108154. */
  108155. expensiveBlur: boolean;
  108156. /**
  108157. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  108158. */
  108159. radius: number;
  108160. /**
  108161. * The base color of the SSAO post-process
  108162. * The final result is "base + ssao" between [0, 1]
  108163. */
  108164. base: number;
  108165. /**
  108166. * Support test.
  108167. */
  108168. static readonly IsSupported: boolean;
  108169. private _scene;
  108170. private _depthTexture;
  108171. private _normalTexture;
  108172. private _randomTexture;
  108173. private _originalColorPostProcess;
  108174. private _ssaoPostProcess;
  108175. private _blurHPostProcess;
  108176. private _blurVPostProcess;
  108177. private _ssaoCombinePostProcess;
  108178. private _firstUpdate;
  108179. /**
  108180. * Gets active scene
  108181. */
  108182. readonly scene: Scene;
  108183. /**
  108184. * @constructor
  108185. * @param name The rendering pipeline name
  108186. * @param scene The scene linked to this pipeline
  108187. * @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 }
  108188. * @param cameras The array of cameras that the rendering pipeline will be attached to
  108189. */
  108190. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  108191. /**
  108192. * Get the class name
  108193. * @returns "SSAO2RenderingPipeline"
  108194. */
  108195. getClassName(): string;
  108196. /**
  108197. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  108198. */
  108199. dispose(disableGeometryBufferRenderer?: boolean): void;
  108200. private _createBlurPostProcess;
  108201. /** @hidden */
  108202. _rebuild(): void;
  108203. private _bits;
  108204. private _radicalInverse_VdC;
  108205. private _hammersley;
  108206. private _hemisphereSample_uniform;
  108207. private _generateHemisphere;
  108208. private _createSSAOPostProcess;
  108209. private _createSSAOCombinePostProcess;
  108210. private _createRandomTexture;
  108211. /**
  108212. * Serialize the rendering pipeline (Used when exporting)
  108213. * @returns the serialized object
  108214. */
  108215. serialize(): any;
  108216. /**
  108217. * Parse the serialized pipeline
  108218. * @param source Source pipeline.
  108219. * @param scene The scene to load the pipeline to.
  108220. * @param rootUrl The URL of the serialized pipeline.
  108221. * @returns An instantiated pipeline from the serialized object.
  108222. */
  108223. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  108224. }
  108225. }
  108226. declare module BABYLON {
  108227. /** @hidden */
  108228. export var ssaoPixelShader: {
  108229. name: string;
  108230. shader: string;
  108231. };
  108232. }
  108233. declare module BABYLON {
  108234. /**
  108235. * Render pipeline to produce ssao effect
  108236. */
  108237. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  108238. /**
  108239. * @ignore
  108240. * The PassPostProcess id in the pipeline that contains the original scene color
  108241. */
  108242. SSAOOriginalSceneColorEffect: string;
  108243. /**
  108244. * @ignore
  108245. * The SSAO PostProcess id in the pipeline
  108246. */
  108247. SSAORenderEffect: string;
  108248. /**
  108249. * @ignore
  108250. * The horizontal blur PostProcess id in the pipeline
  108251. */
  108252. SSAOBlurHRenderEffect: string;
  108253. /**
  108254. * @ignore
  108255. * The vertical blur PostProcess id in the pipeline
  108256. */
  108257. SSAOBlurVRenderEffect: string;
  108258. /**
  108259. * @ignore
  108260. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  108261. */
  108262. SSAOCombineRenderEffect: string;
  108263. /**
  108264. * The output strength of the SSAO post-process. Default value is 1.0.
  108265. */
  108266. totalStrength: number;
  108267. /**
  108268. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  108269. */
  108270. radius: number;
  108271. /**
  108272. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  108273. * Must not be equal to fallOff and superior to fallOff.
  108274. * Default value is 0.0075
  108275. */
  108276. area: number;
  108277. /**
  108278. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  108279. * Must not be equal to area and inferior to area.
  108280. * Default value is 0.000001
  108281. */
  108282. fallOff: number;
  108283. /**
  108284. * The base color of the SSAO post-process
  108285. * The final result is "base + ssao" between [0, 1]
  108286. */
  108287. base: number;
  108288. private _scene;
  108289. private _depthTexture;
  108290. private _randomTexture;
  108291. private _originalColorPostProcess;
  108292. private _ssaoPostProcess;
  108293. private _blurHPostProcess;
  108294. private _blurVPostProcess;
  108295. private _ssaoCombinePostProcess;
  108296. private _firstUpdate;
  108297. /**
  108298. * Gets active scene
  108299. */
  108300. readonly scene: Scene;
  108301. /**
  108302. * @constructor
  108303. * @param name - The rendering pipeline name
  108304. * @param scene - The scene linked to this pipeline
  108305. * @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 }
  108306. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  108307. */
  108308. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  108309. /**
  108310. * Get the class name
  108311. * @returns "SSAORenderingPipeline"
  108312. */
  108313. getClassName(): string;
  108314. /**
  108315. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  108316. */
  108317. dispose(disableDepthRender?: boolean): void;
  108318. private _createBlurPostProcess;
  108319. /** @hidden */
  108320. _rebuild(): void;
  108321. private _createSSAOPostProcess;
  108322. private _createSSAOCombinePostProcess;
  108323. private _createRandomTexture;
  108324. }
  108325. }
  108326. declare module BABYLON {
  108327. /** @hidden */
  108328. export var standardPixelShader: {
  108329. name: string;
  108330. shader: string;
  108331. };
  108332. }
  108333. declare module BABYLON {
  108334. /**
  108335. * Standard rendering pipeline
  108336. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  108337. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  108338. */
  108339. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  108340. /**
  108341. * Public members
  108342. */
  108343. /**
  108344. * Post-process which contains the original scene color before the pipeline applies all the effects
  108345. */
  108346. originalPostProcess: Nullable<PostProcess>;
  108347. /**
  108348. * Post-process used to down scale an image x4
  108349. */
  108350. downSampleX4PostProcess: Nullable<PostProcess>;
  108351. /**
  108352. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  108353. */
  108354. brightPassPostProcess: Nullable<PostProcess>;
  108355. /**
  108356. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  108357. */
  108358. blurHPostProcesses: PostProcess[];
  108359. /**
  108360. * Post-process array storing all the vertical blur post-processes used by the pipeline
  108361. */
  108362. blurVPostProcesses: PostProcess[];
  108363. /**
  108364. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  108365. */
  108366. textureAdderPostProcess: Nullable<PostProcess>;
  108367. /**
  108368. * Post-process used to create volumetric lighting effect
  108369. */
  108370. volumetricLightPostProcess: Nullable<PostProcess>;
  108371. /**
  108372. * Post-process used to smooth the previous volumetric light post-process on the X axis
  108373. */
  108374. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  108375. /**
  108376. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  108377. */
  108378. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  108379. /**
  108380. * Post-process used to merge the volumetric light effect and the real scene color
  108381. */
  108382. volumetricLightMergePostProces: Nullable<PostProcess>;
  108383. /**
  108384. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  108385. */
  108386. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  108387. /**
  108388. * Base post-process used to calculate the average luminance of the final image for HDR
  108389. */
  108390. luminancePostProcess: Nullable<PostProcess>;
  108391. /**
  108392. * Post-processes used to create down sample post-processes in order to get
  108393. * the average luminance of the final image for HDR
  108394. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  108395. */
  108396. luminanceDownSamplePostProcesses: PostProcess[];
  108397. /**
  108398. * Post-process used to create a HDR effect (light adaptation)
  108399. */
  108400. hdrPostProcess: Nullable<PostProcess>;
  108401. /**
  108402. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  108403. */
  108404. textureAdderFinalPostProcess: Nullable<PostProcess>;
  108405. /**
  108406. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  108407. */
  108408. lensFlareFinalPostProcess: Nullable<PostProcess>;
  108409. /**
  108410. * Post-process used to merge the final HDR post-process and the real scene color
  108411. */
  108412. hdrFinalPostProcess: Nullable<PostProcess>;
  108413. /**
  108414. * Post-process used to create a lens flare effect
  108415. */
  108416. lensFlarePostProcess: Nullable<PostProcess>;
  108417. /**
  108418. * Post-process that merges the result of the lens flare post-process and the real scene color
  108419. */
  108420. lensFlareComposePostProcess: Nullable<PostProcess>;
  108421. /**
  108422. * Post-process used to create a motion blur effect
  108423. */
  108424. motionBlurPostProcess: Nullable<PostProcess>;
  108425. /**
  108426. * Post-process used to create a depth of field effect
  108427. */
  108428. depthOfFieldPostProcess: Nullable<PostProcess>;
  108429. /**
  108430. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  108431. */
  108432. fxaaPostProcess: Nullable<FxaaPostProcess>;
  108433. /**
  108434. * Represents the brightness threshold in order to configure the illuminated surfaces
  108435. */
  108436. brightThreshold: number;
  108437. /**
  108438. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  108439. */
  108440. blurWidth: number;
  108441. /**
  108442. * Sets if the blur for highlighted surfaces must be only horizontal
  108443. */
  108444. horizontalBlur: boolean;
  108445. /**
  108446. * Sets the overall exposure used by the pipeline
  108447. */
  108448. exposure: number;
  108449. /**
  108450. * Texture used typically to simulate "dirty" on camera lens
  108451. */
  108452. lensTexture: Nullable<Texture>;
  108453. /**
  108454. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  108455. */
  108456. volumetricLightCoefficient: number;
  108457. /**
  108458. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  108459. */
  108460. volumetricLightPower: number;
  108461. /**
  108462. * Used the set the blur intensity to smooth the volumetric lights
  108463. */
  108464. volumetricLightBlurScale: number;
  108465. /**
  108466. * Light (spot or directional) used to generate the volumetric lights rays
  108467. * The source light must have a shadow generate so the pipeline can get its
  108468. * depth map
  108469. */
  108470. sourceLight: Nullable<SpotLight | DirectionalLight>;
  108471. /**
  108472. * For eye adaptation, represents the minimum luminance the eye can see
  108473. */
  108474. hdrMinimumLuminance: number;
  108475. /**
  108476. * For eye adaptation, represents the decrease luminance speed
  108477. */
  108478. hdrDecreaseRate: number;
  108479. /**
  108480. * For eye adaptation, represents the increase luminance speed
  108481. */
  108482. hdrIncreaseRate: number;
  108483. /**
  108484. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  108485. */
  108486. lensColorTexture: Nullable<Texture>;
  108487. /**
  108488. * The overall strengh for the lens flare effect
  108489. */
  108490. lensFlareStrength: number;
  108491. /**
  108492. * Dispersion coefficient for lens flare ghosts
  108493. */
  108494. lensFlareGhostDispersal: number;
  108495. /**
  108496. * Main lens flare halo width
  108497. */
  108498. lensFlareHaloWidth: number;
  108499. /**
  108500. * Based on the lens distortion effect, defines how much the lens flare result
  108501. * is distorted
  108502. */
  108503. lensFlareDistortionStrength: number;
  108504. /**
  108505. * Lens star texture must be used to simulate rays on the flares and is available
  108506. * in the documentation
  108507. */
  108508. lensStarTexture: Nullable<Texture>;
  108509. /**
  108510. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  108511. * flare effect by taking account of the dirt texture
  108512. */
  108513. lensFlareDirtTexture: Nullable<Texture>;
  108514. /**
  108515. * Represents the focal length for the depth of field effect
  108516. */
  108517. depthOfFieldDistance: number;
  108518. /**
  108519. * Represents the blur intensity for the blurred part of the depth of field effect
  108520. */
  108521. depthOfFieldBlurWidth: number;
  108522. /**
  108523. * For motion blur, defines how much the image is blurred by the movement
  108524. */
  108525. motionStrength: number;
  108526. /**
  108527. * List of animations for the pipeline (IAnimatable implementation)
  108528. */
  108529. animations: Animation[];
  108530. /**
  108531. * Private members
  108532. */
  108533. private _scene;
  108534. private _currentDepthOfFieldSource;
  108535. private _basePostProcess;
  108536. private _hdrCurrentLuminance;
  108537. private _floatTextureType;
  108538. private _ratio;
  108539. private _bloomEnabled;
  108540. private _depthOfFieldEnabled;
  108541. private _vlsEnabled;
  108542. private _lensFlareEnabled;
  108543. private _hdrEnabled;
  108544. private _motionBlurEnabled;
  108545. private _fxaaEnabled;
  108546. private _motionBlurSamples;
  108547. private _volumetricLightStepsCount;
  108548. private _samples;
  108549. /**
  108550. * @ignore
  108551. * Specifies if the bloom pipeline is enabled
  108552. */
  108553. BloomEnabled: boolean;
  108554. /**
  108555. * @ignore
  108556. * Specifies if the depth of field pipeline is enabed
  108557. */
  108558. DepthOfFieldEnabled: boolean;
  108559. /**
  108560. * @ignore
  108561. * Specifies if the lens flare pipeline is enabed
  108562. */
  108563. LensFlareEnabled: boolean;
  108564. /**
  108565. * @ignore
  108566. * Specifies if the HDR pipeline is enabled
  108567. */
  108568. HDREnabled: boolean;
  108569. /**
  108570. * @ignore
  108571. * Specifies if the volumetric lights scattering effect is enabled
  108572. */
  108573. VLSEnabled: boolean;
  108574. /**
  108575. * @ignore
  108576. * Specifies if the motion blur effect is enabled
  108577. */
  108578. MotionBlurEnabled: boolean;
  108579. /**
  108580. * Specifies if anti-aliasing is enabled
  108581. */
  108582. fxaaEnabled: boolean;
  108583. /**
  108584. * Specifies the number of steps used to calculate the volumetric lights
  108585. * Typically in interval [50, 200]
  108586. */
  108587. volumetricLightStepsCount: number;
  108588. /**
  108589. * Specifies the number of samples used for the motion blur effect
  108590. * Typically in interval [16, 64]
  108591. */
  108592. motionBlurSamples: number;
  108593. /**
  108594. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  108595. */
  108596. samples: number;
  108597. /**
  108598. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  108599. * @constructor
  108600. * @param name The rendering pipeline name
  108601. * @param scene The scene linked to this pipeline
  108602. * @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)
  108603. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  108604. * @param cameras The array of cameras that the rendering pipeline will be attached to
  108605. */
  108606. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  108607. private _buildPipeline;
  108608. private _createDownSampleX4PostProcess;
  108609. private _createBrightPassPostProcess;
  108610. private _createBlurPostProcesses;
  108611. private _createTextureAdderPostProcess;
  108612. private _createVolumetricLightPostProcess;
  108613. private _createLuminancePostProcesses;
  108614. private _createHdrPostProcess;
  108615. private _createLensFlarePostProcess;
  108616. private _createDepthOfFieldPostProcess;
  108617. private _createMotionBlurPostProcess;
  108618. private _getDepthTexture;
  108619. private _disposePostProcesses;
  108620. /**
  108621. * Dispose of the pipeline and stop all post processes
  108622. */
  108623. dispose(): void;
  108624. /**
  108625. * Serialize the rendering pipeline (Used when exporting)
  108626. * @returns the serialized object
  108627. */
  108628. serialize(): any;
  108629. /**
  108630. * Parse the serialized pipeline
  108631. * @param source Source pipeline.
  108632. * @param scene The scene to load the pipeline to.
  108633. * @param rootUrl The URL of the serialized pipeline.
  108634. * @returns An instantiated pipeline from the serialized object.
  108635. */
  108636. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  108637. /**
  108638. * Luminance steps
  108639. */
  108640. static LuminanceSteps: number;
  108641. }
  108642. }
  108643. declare module BABYLON {
  108644. /**
  108645. * PostProcessRenderPipelineManager class
  108646. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  108647. */
  108648. export class PostProcessRenderPipelineManager {
  108649. private _renderPipelines;
  108650. /**
  108651. * Initializes a PostProcessRenderPipelineManager
  108652. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  108653. */
  108654. constructor();
  108655. /**
  108656. * Gets the list of supported render pipelines
  108657. */
  108658. readonly supportedPipelines: PostProcessRenderPipeline[];
  108659. /**
  108660. * Adds a pipeline to the manager
  108661. * @param renderPipeline The pipeline to add
  108662. */
  108663. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  108664. /**
  108665. * Attaches a camera to the pipeline
  108666. * @param renderPipelineName The name of the pipeline to attach to
  108667. * @param cameras the camera to attach
  108668. * @param unique if the camera can be attached multiple times to the pipeline
  108669. */
  108670. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  108671. /**
  108672. * Detaches a camera from the pipeline
  108673. * @param renderPipelineName The name of the pipeline to detach from
  108674. * @param cameras the camera to detach
  108675. */
  108676. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  108677. /**
  108678. * Enables an effect by name on a pipeline
  108679. * @param renderPipelineName the name of the pipeline to enable the effect in
  108680. * @param renderEffectName the name of the effect to enable
  108681. * @param cameras the cameras that the effect should be enabled on
  108682. */
  108683. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  108684. /**
  108685. * Disables an effect by name on a pipeline
  108686. * @param renderPipelineName the name of the pipeline to disable the effect in
  108687. * @param renderEffectName the name of the effect to disable
  108688. * @param cameras the cameras that the effect should be disabled on
  108689. */
  108690. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  108691. /**
  108692. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  108693. */
  108694. update(): void;
  108695. /** @hidden */
  108696. _rebuild(): void;
  108697. /**
  108698. * Disposes of the manager and pipelines
  108699. */
  108700. dispose(): void;
  108701. }
  108702. }
  108703. declare module BABYLON {
  108704. interface Scene {
  108705. /** @hidden (Backing field) */
  108706. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  108707. /**
  108708. * Gets the postprocess render pipeline manager
  108709. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  108710. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  108711. */
  108712. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  108713. }
  108714. /**
  108715. * Defines the Render Pipeline scene component responsible to rendering pipelines
  108716. */
  108717. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  108718. /**
  108719. * The component name helpfull to identify the component in the list of scene components.
  108720. */
  108721. readonly name: string;
  108722. /**
  108723. * The scene the component belongs to.
  108724. */
  108725. scene: Scene;
  108726. /**
  108727. * Creates a new instance of the component for the given scene
  108728. * @param scene Defines the scene to register the component in
  108729. */
  108730. constructor(scene: Scene);
  108731. /**
  108732. * Registers the component in a given scene
  108733. */
  108734. register(): void;
  108735. /**
  108736. * Rebuilds the elements related to this component in case of
  108737. * context lost for instance.
  108738. */
  108739. rebuild(): void;
  108740. /**
  108741. * Disposes the component and the associated ressources
  108742. */
  108743. dispose(): void;
  108744. private _gatherRenderTargets;
  108745. }
  108746. }
  108747. declare module BABYLON {
  108748. /** @hidden */
  108749. export var tonemapPixelShader: {
  108750. name: string;
  108751. shader: string;
  108752. };
  108753. }
  108754. declare module BABYLON {
  108755. /** Defines operator used for tonemapping */
  108756. export enum TonemappingOperator {
  108757. /** Hable */
  108758. Hable = 0,
  108759. /** Reinhard */
  108760. Reinhard = 1,
  108761. /** HejiDawson */
  108762. HejiDawson = 2,
  108763. /** Photographic */
  108764. Photographic = 3
  108765. }
  108766. /**
  108767. * Defines a post process to apply tone mapping
  108768. */
  108769. export class TonemapPostProcess extends PostProcess {
  108770. private _operator;
  108771. /** Defines the required exposure adjustement */
  108772. exposureAdjustment: number;
  108773. /**
  108774. * Creates a new TonemapPostProcess
  108775. * @param name defines the name of the postprocess
  108776. * @param _operator defines the operator to use
  108777. * @param exposureAdjustment defines the required exposure adjustement
  108778. * @param camera defines the camera to use (can be null)
  108779. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  108780. * @param engine defines the hosting engine (can be ignore if camera is set)
  108781. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  108782. */
  108783. constructor(name: string, _operator: TonemappingOperator,
  108784. /** Defines the required exposure adjustement */
  108785. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  108786. }
  108787. }
  108788. declare module BABYLON {
  108789. /** @hidden */
  108790. export var depthVertexShader: {
  108791. name: string;
  108792. shader: string;
  108793. };
  108794. }
  108795. declare module BABYLON {
  108796. /** @hidden */
  108797. export var volumetricLightScatteringPixelShader: {
  108798. name: string;
  108799. shader: string;
  108800. };
  108801. }
  108802. declare module BABYLON {
  108803. /** @hidden */
  108804. export var volumetricLightScatteringPassPixelShader: {
  108805. name: string;
  108806. shader: string;
  108807. };
  108808. }
  108809. declare module BABYLON {
  108810. /**
  108811. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  108812. */
  108813. export class VolumetricLightScatteringPostProcess extends PostProcess {
  108814. private _volumetricLightScatteringPass;
  108815. private _volumetricLightScatteringRTT;
  108816. private _viewPort;
  108817. private _screenCoordinates;
  108818. private _cachedDefines;
  108819. /**
  108820. * If not undefined, the mesh position is computed from the attached node position
  108821. */
  108822. attachedNode: {
  108823. position: Vector3;
  108824. };
  108825. /**
  108826. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  108827. */
  108828. customMeshPosition: Vector3;
  108829. /**
  108830. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  108831. */
  108832. useCustomMeshPosition: boolean;
  108833. /**
  108834. * If the post-process should inverse the light scattering direction
  108835. */
  108836. invert: boolean;
  108837. /**
  108838. * The internal mesh used by the post-process
  108839. */
  108840. mesh: Mesh;
  108841. /**
  108842. * @hidden
  108843. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  108844. */
  108845. useDiffuseColor: boolean;
  108846. /**
  108847. * Array containing the excluded meshes not rendered in the internal pass
  108848. */
  108849. excludedMeshes: AbstractMesh[];
  108850. /**
  108851. * Controls the overall intensity of the post-process
  108852. */
  108853. exposure: number;
  108854. /**
  108855. * Dissipates each sample's contribution in range [0, 1]
  108856. */
  108857. decay: number;
  108858. /**
  108859. * Controls the overall intensity of each sample
  108860. */
  108861. weight: number;
  108862. /**
  108863. * Controls the density of each sample
  108864. */
  108865. density: number;
  108866. /**
  108867. * @constructor
  108868. * @param name The post-process name
  108869. * @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)
  108870. * @param camera The camera that the post-process will be attached to
  108871. * @param mesh The mesh used to create the light scattering
  108872. * @param samples The post-process quality, default 100
  108873. * @param samplingModeThe post-process filtering mode
  108874. * @param engine The babylon engine
  108875. * @param reusable If the post-process is reusable
  108876. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  108877. */
  108878. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  108879. /**
  108880. * Returns the string "VolumetricLightScatteringPostProcess"
  108881. * @returns "VolumetricLightScatteringPostProcess"
  108882. */
  108883. getClassName(): string;
  108884. private _isReady;
  108885. /**
  108886. * Sets the new light position for light scattering effect
  108887. * @param position The new custom light position
  108888. */
  108889. setCustomMeshPosition(position: Vector3): void;
  108890. /**
  108891. * Returns the light position for light scattering effect
  108892. * @return Vector3 The custom light position
  108893. */
  108894. getCustomMeshPosition(): Vector3;
  108895. /**
  108896. * Disposes the internal assets and detaches the post-process from the camera
  108897. */
  108898. dispose(camera: Camera): void;
  108899. /**
  108900. * Returns the render target texture used by the post-process
  108901. * @return the render target texture used by the post-process
  108902. */
  108903. getPass(): RenderTargetTexture;
  108904. private _meshExcluded;
  108905. private _createPass;
  108906. private _updateMeshScreenCoordinates;
  108907. /**
  108908. * Creates a default mesh for the Volumeric Light Scattering post-process
  108909. * @param name The mesh name
  108910. * @param scene The scene where to create the mesh
  108911. * @return the default mesh
  108912. */
  108913. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  108914. }
  108915. }
  108916. declare module BABYLON {
  108917. interface Scene {
  108918. /** @hidden (Backing field) */
  108919. _boundingBoxRenderer: BoundingBoxRenderer;
  108920. /** @hidden (Backing field) */
  108921. _forceShowBoundingBoxes: boolean;
  108922. /**
  108923. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  108924. */
  108925. forceShowBoundingBoxes: boolean;
  108926. /**
  108927. * Gets the bounding box renderer associated with the scene
  108928. * @returns a BoundingBoxRenderer
  108929. */
  108930. getBoundingBoxRenderer(): BoundingBoxRenderer;
  108931. }
  108932. interface AbstractMesh {
  108933. /** @hidden (Backing field) */
  108934. _showBoundingBox: boolean;
  108935. /**
  108936. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  108937. */
  108938. showBoundingBox: boolean;
  108939. }
  108940. /**
  108941. * Component responsible of rendering the bounding box of the meshes in a scene.
  108942. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  108943. */
  108944. export class BoundingBoxRenderer implements ISceneComponent {
  108945. /**
  108946. * The component name helpfull to identify the component in the list of scene components.
  108947. */
  108948. readonly name: string;
  108949. /**
  108950. * The scene the component belongs to.
  108951. */
  108952. scene: Scene;
  108953. /**
  108954. * Color of the bounding box lines placed in front of an object
  108955. */
  108956. frontColor: Color3;
  108957. /**
  108958. * Color of the bounding box lines placed behind an object
  108959. */
  108960. backColor: Color3;
  108961. /**
  108962. * Defines if the renderer should show the back lines or not
  108963. */
  108964. showBackLines: boolean;
  108965. /**
  108966. * @hidden
  108967. */
  108968. renderList: SmartArray<BoundingBox>;
  108969. private _colorShader;
  108970. private _vertexBuffers;
  108971. private _indexBuffer;
  108972. /**
  108973. * Instantiates a new bounding box renderer in a scene.
  108974. * @param scene the scene the renderer renders in
  108975. */
  108976. constructor(scene: Scene);
  108977. /**
  108978. * Registers the component in a given scene
  108979. */
  108980. register(): void;
  108981. private _evaluateSubMesh;
  108982. private _activeMesh;
  108983. private _prepareRessources;
  108984. private _createIndexBuffer;
  108985. /**
  108986. * Rebuilds the elements related to this component in case of
  108987. * context lost for instance.
  108988. */
  108989. rebuild(): void;
  108990. /**
  108991. * @hidden
  108992. */
  108993. reset(): void;
  108994. /**
  108995. * Render the bounding boxes of a specific rendering group
  108996. * @param renderingGroupId defines the rendering group to render
  108997. */
  108998. render(renderingGroupId: number): void;
  108999. /**
  109000. * In case of occlusion queries, we can render the occlusion bounding box through this method
  109001. * @param mesh Define the mesh to render the occlusion bounding box for
  109002. */
  109003. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  109004. /**
  109005. * Dispose and release the resources attached to this renderer.
  109006. */
  109007. dispose(): void;
  109008. }
  109009. }
  109010. declare module BABYLON {
  109011. /** @hidden */
  109012. export var depthPixelShader: {
  109013. name: string;
  109014. shader: string;
  109015. };
  109016. }
  109017. declare module BABYLON {
  109018. /**
  109019. * This represents a depth renderer in Babylon.
  109020. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  109021. */
  109022. export class DepthRenderer {
  109023. private _scene;
  109024. private _depthMap;
  109025. private _effect;
  109026. private _cachedDefines;
  109027. private _camera;
  109028. /**
  109029. * Specifiess that the depth renderer will only be used within
  109030. * the camera it is created for.
  109031. * This can help forcing its rendering during the camera processing.
  109032. */
  109033. useOnlyInActiveCamera: boolean;
  109034. /** @hidden */
  109035. static _SceneComponentInitialization: (scene: Scene) => void;
  109036. /**
  109037. * Instantiates a depth renderer
  109038. * @param scene The scene the renderer belongs to
  109039. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  109040. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  109041. */
  109042. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  109043. /**
  109044. * Creates the depth rendering effect and checks if the effect is ready.
  109045. * @param subMesh The submesh to be used to render the depth map of
  109046. * @param useInstances If multiple world instances should be used
  109047. * @returns if the depth renderer is ready to render the depth map
  109048. */
  109049. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  109050. /**
  109051. * Gets the texture which the depth map will be written to.
  109052. * @returns The depth map texture
  109053. */
  109054. getDepthMap(): RenderTargetTexture;
  109055. /**
  109056. * Disposes of the depth renderer.
  109057. */
  109058. dispose(): void;
  109059. }
  109060. }
  109061. declare module BABYLON {
  109062. interface Scene {
  109063. /** @hidden (Backing field) */
  109064. _depthRenderer: {
  109065. [id: string]: DepthRenderer;
  109066. };
  109067. /**
  109068. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  109069. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  109070. * @returns the created depth renderer
  109071. */
  109072. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  109073. /**
  109074. * Disables a depth renderer for a given camera
  109075. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  109076. */
  109077. disableDepthRenderer(camera?: Nullable<Camera>): void;
  109078. }
  109079. /**
  109080. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  109081. * in several rendering techniques.
  109082. */
  109083. export class DepthRendererSceneComponent implements ISceneComponent {
  109084. /**
  109085. * The component name helpfull to identify the component in the list of scene components.
  109086. */
  109087. readonly name: string;
  109088. /**
  109089. * The scene the component belongs to.
  109090. */
  109091. scene: Scene;
  109092. /**
  109093. * Creates a new instance of the component for the given scene
  109094. * @param scene Defines the scene to register the component in
  109095. */
  109096. constructor(scene: Scene);
  109097. /**
  109098. * Registers the component in a given scene
  109099. */
  109100. register(): void;
  109101. /**
  109102. * Rebuilds the elements related to this component in case of
  109103. * context lost for instance.
  109104. */
  109105. rebuild(): void;
  109106. /**
  109107. * Disposes the component and the associated ressources
  109108. */
  109109. dispose(): void;
  109110. private _gatherRenderTargets;
  109111. private _gatherActiveCameraRenderTargets;
  109112. }
  109113. }
  109114. declare module BABYLON {
  109115. interface Scene {
  109116. /** @hidden (Backing field) */
  109117. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  109118. /**
  109119. * Gets or Sets the current geometry buffer associated to the scene.
  109120. */
  109121. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  109122. /**
  109123. * Enables a GeometryBufferRender and associates it with the scene
  109124. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  109125. * @returns the GeometryBufferRenderer
  109126. */
  109127. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  109128. /**
  109129. * Disables the GeometryBufferRender associated with the scene
  109130. */
  109131. disableGeometryBufferRenderer(): void;
  109132. }
  109133. /**
  109134. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  109135. * in several rendering techniques.
  109136. */
  109137. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  109138. /**
  109139. * The component name helpful to identify the component in the list of scene components.
  109140. */
  109141. readonly name: string;
  109142. /**
  109143. * The scene the component belongs to.
  109144. */
  109145. scene: Scene;
  109146. /**
  109147. * Creates a new instance of the component for the given scene
  109148. * @param scene Defines the scene to register the component in
  109149. */
  109150. constructor(scene: Scene);
  109151. /**
  109152. * Registers the component in a given scene
  109153. */
  109154. register(): void;
  109155. /**
  109156. * Rebuilds the elements related to this component in case of
  109157. * context lost for instance.
  109158. */
  109159. rebuild(): void;
  109160. /**
  109161. * Disposes the component and the associated ressources
  109162. */
  109163. dispose(): void;
  109164. private _gatherRenderTargets;
  109165. }
  109166. }
  109167. declare module BABYLON {
  109168. /** @hidden */
  109169. export var outlinePixelShader: {
  109170. name: string;
  109171. shader: string;
  109172. };
  109173. }
  109174. declare module BABYLON {
  109175. /** @hidden */
  109176. export var outlineVertexShader: {
  109177. name: string;
  109178. shader: string;
  109179. };
  109180. }
  109181. declare module BABYLON {
  109182. interface Scene {
  109183. /** @hidden */
  109184. _outlineRenderer: OutlineRenderer;
  109185. /**
  109186. * Gets the outline renderer associated with the scene
  109187. * @returns a OutlineRenderer
  109188. */
  109189. getOutlineRenderer(): OutlineRenderer;
  109190. }
  109191. interface AbstractMesh {
  109192. /** @hidden (Backing field) */
  109193. _renderOutline: boolean;
  109194. /**
  109195. * Gets or sets a boolean indicating if the outline must be rendered as well
  109196. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  109197. */
  109198. renderOutline: boolean;
  109199. /** @hidden (Backing field) */
  109200. _renderOverlay: boolean;
  109201. /**
  109202. * Gets or sets a boolean indicating if the overlay must be rendered as well
  109203. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  109204. */
  109205. renderOverlay: boolean;
  109206. }
  109207. /**
  109208. * This class is responsible to draw bothe outline/overlay of meshes.
  109209. * It should not be used directly but through the available method on mesh.
  109210. */
  109211. export class OutlineRenderer implements ISceneComponent {
  109212. /**
  109213. * The name of the component. Each component must have a unique name.
  109214. */
  109215. name: string;
  109216. /**
  109217. * The scene the component belongs to.
  109218. */
  109219. scene: Scene;
  109220. /**
  109221. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  109222. */
  109223. zOffset: number;
  109224. private _engine;
  109225. private _effect;
  109226. private _cachedDefines;
  109227. private _savedDepthWrite;
  109228. /**
  109229. * Instantiates a new outline renderer. (There could be only one per scene).
  109230. * @param scene Defines the scene it belongs to
  109231. */
  109232. constructor(scene: Scene);
  109233. /**
  109234. * Register the component to one instance of a scene.
  109235. */
  109236. register(): void;
  109237. /**
  109238. * Rebuilds the elements related to this component in case of
  109239. * context lost for instance.
  109240. */
  109241. rebuild(): void;
  109242. /**
  109243. * Disposes the component and the associated ressources.
  109244. */
  109245. dispose(): void;
  109246. /**
  109247. * Renders the outline in the canvas.
  109248. * @param subMesh Defines the sumesh to render
  109249. * @param batch Defines the batch of meshes in case of instances
  109250. * @param useOverlay Defines if the rendering is for the overlay or the outline
  109251. */
  109252. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  109253. /**
  109254. * Returns whether or not the outline renderer is ready for a given submesh.
  109255. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  109256. * @param subMesh Defines the submesh to check readyness for
  109257. * @param useInstances Defines wheter wee are trying to render instances or not
  109258. * @returns true if ready otherwise false
  109259. */
  109260. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  109261. private _beforeRenderingMesh;
  109262. private _afterRenderingMesh;
  109263. }
  109264. }
  109265. declare module BABYLON {
  109266. /**
  109267. * Defines the list of states available for a task inside a AssetsManager
  109268. */
  109269. export enum AssetTaskState {
  109270. /**
  109271. * Initialization
  109272. */
  109273. INIT = 0,
  109274. /**
  109275. * Running
  109276. */
  109277. RUNNING = 1,
  109278. /**
  109279. * Done
  109280. */
  109281. DONE = 2,
  109282. /**
  109283. * Error
  109284. */
  109285. ERROR = 3
  109286. }
  109287. /**
  109288. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  109289. */
  109290. export abstract class AbstractAssetTask {
  109291. /**
  109292. * Task name
  109293. */ name: string;
  109294. /**
  109295. * Callback called when the task is successful
  109296. */
  109297. onSuccess: (task: any) => void;
  109298. /**
  109299. * Callback called when the task is not successful
  109300. */
  109301. onError: (task: any, message?: string, exception?: any) => void;
  109302. /**
  109303. * Creates a new AssetsManager
  109304. * @param name defines the name of the task
  109305. */
  109306. constructor(
  109307. /**
  109308. * Task name
  109309. */ name: string);
  109310. private _isCompleted;
  109311. private _taskState;
  109312. private _errorObject;
  109313. /**
  109314. * Get if the task is completed
  109315. */
  109316. readonly isCompleted: boolean;
  109317. /**
  109318. * Gets the current state of the task
  109319. */
  109320. readonly taskState: AssetTaskState;
  109321. /**
  109322. * Gets the current error object (if task is in error)
  109323. */
  109324. readonly errorObject: {
  109325. message?: string;
  109326. exception?: any;
  109327. };
  109328. /**
  109329. * Internal only
  109330. * @hidden
  109331. */
  109332. _setErrorObject(message?: string, exception?: any): void;
  109333. /**
  109334. * Execute the current task
  109335. * @param scene defines the scene where you want your assets to be loaded
  109336. * @param onSuccess is a callback called when the task is successfully executed
  109337. * @param onError is a callback called if an error occurs
  109338. */
  109339. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  109340. /**
  109341. * Execute the current task
  109342. * @param scene defines the scene where you want your assets to be loaded
  109343. * @param onSuccess is a callback called when the task is successfully executed
  109344. * @param onError is a callback called if an error occurs
  109345. */
  109346. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  109347. /**
  109348. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  109349. * This can be used with failed tasks that have the reason for failure fixed.
  109350. */
  109351. reset(): void;
  109352. private onErrorCallback;
  109353. private onDoneCallback;
  109354. }
  109355. /**
  109356. * Define the interface used by progress events raised during assets loading
  109357. */
  109358. export interface IAssetsProgressEvent {
  109359. /**
  109360. * Defines the number of remaining tasks to process
  109361. */
  109362. remainingCount: number;
  109363. /**
  109364. * Defines the total number of tasks
  109365. */
  109366. totalCount: number;
  109367. /**
  109368. * Defines the task that was just processed
  109369. */
  109370. task: AbstractAssetTask;
  109371. }
  109372. /**
  109373. * Class used to share progress information about assets loading
  109374. */
  109375. export class AssetsProgressEvent implements IAssetsProgressEvent {
  109376. /**
  109377. * Defines the number of remaining tasks to process
  109378. */
  109379. remainingCount: number;
  109380. /**
  109381. * Defines the total number of tasks
  109382. */
  109383. totalCount: number;
  109384. /**
  109385. * Defines the task that was just processed
  109386. */
  109387. task: AbstractAssetTask;
  109388. /**
  109389. * Creates a AssetsProgressEvent
  109390. * @param remainingCount defines the number of remaining tasks to process
  109391. * @param totalCount defines the total number of tasks
  109392. * @param task defines the task that was just processed
  109393. */
  109394. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  109395. }
  109396. /**
  109397. * Define a task used by AssetsManager to load meshes
  109398. */
  109399. export class MeshAssetTask extends AbstractAssetTask {
  109400. /**
  109401. * Defines the name of the task
  109402. */
  109403. name: string;
  109404. /**
  109405. * Defines the list of mesh's names you want to load
  109406. */
  109407. meshesNames: any;
  109408. /**
  109409. * Defines the root url to use as a base to load your meshes and associated resources
  109410. */
  109411. rootUrl: string;
  109412. /**
  109413. * Defines the filename of the scene to load from
  109414. */
  109415. sceneFilename: string;
  109416. /**
  109417. * Gets the list of loaded meshes
  109418. */
  109419. loadedMeshes: Array<AbstractMesh>;
  109420. /**
  109421. * Gets the list of loaded particle systems
  109422. */
  109423. loadedParticleSystems: Array<IParticleSystem>;
  109424. /**
  109425. * Gets the list of loaded skeletons
  109426. */
  109427. loadedSkeletons: Array<Skeleton>;
  109428. /**
  109429. * Gets the list of loaded animation groups
  109430. */
  109431. loadedAnimationGroups: Array<AnimationGroup>;
  109432. /**
  109433. * Callback called when the task is successful
  109434. */
  109435. onSuccess: (task: MeshAssetTask) => void;
  109436. /**
  109437. * Callback called when the task is successful
  109438. */
  109439. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  109440. /**
  109441. * Creates a new MeshAssetTask
  109442. * @param name defines the name of the task
  109443. * @param meshesNames defines the list of mesh's names you want to load
  109444. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  109445. * @param sceneFilename defines the filename of the scene to load from
  109446. */
  109447. constructor(
  109448. /**
  109449. * Defines the name of the task
  109450. */
  109451. name: string,
  109452. /**
  109453. * Defines the list of mesh's names you want to load
  109454. */
  109455. meshesNames: any,
  109456. /**
  109457. * Defines the root url to use as a base to load your meshes and associated resources
  109458. */
  109459. rootUrl: string,
  109460. /**
  109461. * Defines the filename of the scene to load from
  109462. */
  109463. sceneFilename: string);
  109464. /**
  109465. * Execute the current task
  109466. * @param scene defines the scene where you want your assets to be loaded
  109467. * @param onSuccess is a callback called when the task is successfully executed
  109468. * @param onError is a callback called if an error occurs
  109469. */
  109470. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  109471. }
  109472. /**
  109473. * Define a task used by AssetsManager to load text content
  109474. */
  109475. export class TextFileAssetTask extends AbstractAssetTask {
  109476. /**
  109477. * Defines the name of the task
  109478. */
  109479. name: string;
  109480. /**
  109481. * Defines the location of the file to load
  109482. */
  109483. url: string;
  109484. /**
  109485. * Gets the loaded text string
  109486. */
  109487. text: string;
  109488. /**
  109489. * Callback called when the task is successful
  109490. */
  109491. onSuccess: (task: TextFileAssetTask) => void;
  109492. /**
  109493. * Callback called when the task is successful
  109494. */
  109495. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  109496. /**
  109497. * Creates a new TextFileAssetTask object
  109498. * @param name defines the name of the task
  109499. * @param url defines the location of the file to load
  109500. */
  109501. constructor(
  109502. /**
  109503. * Defines the name of the task
  109504. */
  109505. name: string,
  109506. /**
  109507. * Defines the location of the file to load
  109508. */
  109509. url: string);
  109510. /**
  109511. * Execute the current task
  109512. * @param scene defines the scene where you want your assets to be loaded
  109513. * @param onSuccess is a callback called when the task is successfully executed
  109514. * @param onError is a callback called if an error occurs
  109515. */
  109516. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  109517. }
  109518. /**
  109519. * Define a task used by AssetsManager to load binary data
  109520. */
  109521. export class BinaryFileAssetTask extends AbstractAssetTask {
  109522. /**
  109523. * Defines the name of the task
  109524. */
  109525. name: string;
  109526. /**
  109527. * Defines the location of the file to load
  109528. */
  109529. url: string;
  109530. /**
  109531. * Gets the lodaded data (as an array buffer)
  109532. */
  109533. data: ArrayBuffer;
  109534. /**
  109535. * Callback called when the task is successful
  109536. */
  109537. onSuccess: (task: BinaryFileAssetTask) => void;
  109538. /**
  109539. * Callback called when the task is successful
  109540. */
  109541. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  109542. /**
  109543. * Creates a new BinaryFileAssetTask object
  109544. * @param name defines the name of the new task
  109545. * @param url defines the location of the file to load
  109546. */
  109547. constructor(
  109548. /**
  109549. * Defines the name of the task
  109550. */
  109551. name: string,
  109552. /**
  109553. * Defines the location of the file to load
  109554. */
  109555. url: string);
  109556. /**
  109557. * Execute the current task
  109558. * @param scene defines the scene where you want your assets to be loaded
  109559. * @param onSuccess is a callback called when the task is successfully executed
  109560. * @param onError is a callback called if an error occurs
  109561. */
  109562. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  109563. }
  109564. /**
  109565. * Define a task used by AssetsManager to load images
  109566. */
  109567. export class ImageAssetTask extends AbstractAssetTask {
  109568. /**
  109569. * Defines the name of the task
  109570. */
  109571. name: string;
  109572. /**
  109573. * Defines the location of the image to load
  109574. */
  109575. url: string;
  109576. /**
  109577. * Gets the loaded images
  109578. */
  109579. image: HTMLImageElement;
  109580. /**
  109581. * Callback called when the task is successful
  109582. */
  109583. onSuccess: (task: ImageAssetTask) => void;
  109584. /**
  109585. * Callback called when the task is successful
  109586. */
  109587. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  109588. /**
  109589. * Creates a new ImageAssetTask
  109590. * @param name defines the name of the task
  109591. * @param url defines the location of the image to load
  109592. */
  109593. constructor(
  109594. /**
  109595. * Defines the name of the task
  109596. */
  109597. name: string,
  109598. /**
  109599. * Defines the location of the image to load
  109600. */
  109601. url: string);
  109602. /**
  109603. * Execute the current task
  109604. * @param scene defines the scene where you want your assets to be loaded
  109605. * @param onSuccess is a callback called when the task is successfully executed
  109606. * @param onError is a callback called if an error occurs
  109607. */
  109608. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  109609. }
  109610. /**
  109611. * Defines the interface used by texture loading tasks
  109612. */
  109613. export interface ITextureAssetTask<TEX extends BaseTexture> {
  109614. /**
  109615. * Gets the loaded texture
  109616. */
  109617. texture: TEX;
  109618. }
  109619. /**
  109620. * Define a task used by AssetsManager to load 2D textures
  109621. */
  109622. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  109623. /**
  109624. * Defines the name of the task
  109625. */
  109626. name: string;
  109627. /**
  109628. * Defines the location of the file to load
  109629. */
  109630. url: string;
  109631. /**
  109632. * Defines if mipmap should not be generated (default is false)
  109633. */
  109634. noMipmap?: boolean | undefined;
  109635. /**
  109636. * Defines if texture must be inverted on Y axis (default is false)
  109637. */
  109638. invertY?: boolean | undefined;
  109639. /**
  109640. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  109641. */
  109642. samplingMode: number;
  109643. /**
  109644. * Gets the loaded texture
  109645. */
  109646. texture: Texture;
  109647. /**
  109648. * Callback called when the task is successful
  109649. */
  109650. onSuccess: (task: TextureAssetTask) => void;
  109651. /**
  109652. * Callback called when the task is successful
  109653. */
  109654. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  109655. /**
  109656. * Creates a new TextureAssetTask object
  109657. * @param name defines the name of the task
  109658. * @param url defines the location of the file to load
  109659. * @param noMipmap defines if mipmap should not be generated (default is false)
  109660. * @param invertY defines if texture must be inverted on Y axis (default is false)
  109661. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  109662. */
  109663. constructor(
  109664. /**
  109665. * Defines the name of the task
  109666. */
  109667. name: string,
  109668. /**
  109669. * Defines the location of the file to load
  109670. */
  109671. url: string,
  109672. /**
  109673. * Defines if mipmap should not be generated (default is false)
  109674. */
  109675. noMipmap?: boolean | undefined,
  109676. /**
  109677. * Defines if texture must be inverted on Y axis (default is false)
  109678. */
  109679. invertY?: boolean | undefined,
  109680. /**
  109681. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  109682. */
  109683. samplingMode?: number);
  109684. /**
  109685. * Execute the current task
  109686. * @param scene defines the scene where you want your assets to be loaded
  109687. * @param onSuccess is a callback called when the task is successfully executed
  109688. * @param onError is a callback called if an error occurs
  109689. */
  109690. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  109691. }
  109692. /**
  109693. * Define a task used by AssetsManager to load cube textures
  109694. */
  109695. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  109696. /**
  109697. * Defines the name of the task
  109698. */
  109699. name: string;
  109700. /**
  109701. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  109702. */
  109703. url: string;
  109704. /**
  109705. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  109706. */
  109707. extensions?: string[] | undefined;
  109708. /**
  109709. * Defines if mipmaps should not be generated (default is false)
  109710. */
  109711. noMipmap?: boolean | undefined;
  109712. /**
  109713. * Defines the explicit list of files (undefined by default)
  109714. */
  109715. files?: string[] | undefined;
  109716. /**
  109717. * Gets the loaded texture
  109718. */
  109719. texture: CubeTexture;
  109720. /**
  109721. * Callback called when the task is successful
  109722. */
  109723. onSuccess: (task: CubeTextureAssetTask) => void;
  109724. /**
  109725. * Callback called when the task is successful
  109726. */
  109727. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  109728. /**
  109729. * Creates a new CubeTextureAssetTask
  109730. * @param name defines the name of the task
  109731. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  109732. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  109733. * @param noMipmap defines if mipmaps should not be generated (default is false)
  109734. * @param files defines the explicit list of files (undefined by default)
  109735. */
  109736. constructor(
  109737. /**
  109738. * Defines the name of the task
  109739. */
  109740. name: string,
  109741. /**
  109742. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  109743. */
  109744. url: string,
  109745. /**
  109746. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  109747. */
  109748. extensions?: string[] | undefined,
  109749. /**
  109750. * Defines if mipmaps should not be generated (default is false)
  109751. */
  109752. noMipmap?: boolean | undefined,
  109753. /**
  109754. * Defines the explicit list of files (undefined by default)
  109755. */
  109756. files?: string[] | undefined);
  109757. /**
  109758. * Execute the current task
  109759. * @param scene defines the scene where you want your assets to be loaded
  109760. * @param onSuccess is a callback called when the task is successfully executed
  109761. * @param onError is a callback called if an error occurs
  109762. */
  109763. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  109764. }
  109765. /**
  109766. * Define a task used by AssetsManager to load HDR cube textures
  109767. */
  109768. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  109769. /**
  109770. * Defines the name of the task
  109771. */
  109772. name: string;
  109773. /**
  109774. * Defines the location of the file to load
  109775. */
  109776. url: string;
  109777. /**
  109778. * Defines the desired size (the more it increases the longer the generation will be)
  109779. */
  109780. size: number;
  109781. /**
  109782. * Defines if mipmaps should not be generated (default is false)
  109783. */
  109784. noMipmap: boolean;
  109785. /**
  109786. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  109787. */
  109788. generateHarmonics: boolean;
  109789. /**
  109790. * 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)
  109791. */
  109792. gammaSpace: boolean;
  109793. /**
  109794. * Internal Use Only
  109795. */
  109796. reserved: boolean;
  109797. /**
  109798. * Gets the loaded texture
  109799. */
  109800. texture: HDRCubeTexture;
  109801. /**
  109802. * Callback called when the task is successful
  109803. */
  109804. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  109805. /**
  109806. * Callback called when the task is successful
  109807. */
  109808. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  109809. /**
  109810. * Creates a new HDRCubeTextureAssetTask object
  109811. * @param name defines the name of the task
  109812. * @param url defines the location of the file to load
  109813. * @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.
  109814. * @param noMipmap defines if mipmaps should not be generated (default is false)
  109815. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  109816. * @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)
  109817. * @param reserved Internal use only
  109818. */
  109819. constructor(
  109820. /**
  109821. * Defines the name of the task
  109822. */
  109823. name: string,
  109824. /**
  109825. * Defines the location of the file to load
  109826. */
  109827. url: string,
  109828. /**
  109829. * Defines the desired size (the more it increases the longer the generation will be)
  109830. */
  109831. size: number,
  109832. /**
  109833. * Defines if mipmaps should not be generated (default is false)
  109834. */
  109835. noMipmap?: boolean,
  109836. /**
  109837. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  109838. */
  109839. generateHarmonics?: boolean,
  109840. /**
  109841. * 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)
  109842. */
  109843. gammaSpace?: boolean,
  109844. /**
  109845. * Internal Use Only
  109846. */
  109847. reserved?: boolean);
  109848. /**
  109849. * Execute the current task
  109850. * @param scene defines the scene where you want your assets to be loaded
  109851. * @param onSuccess is a callback called when the task is successfully executed
  109852. * @param onError is a callback called if an error occurs
  109853. */
  109854. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  109855. }
  109856. /**
  109857. * This class can be used to easily import assets into a scene
  109858. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  109859. */
  109860. export class AssetsManager {
  109861. private _scene;
  109862. private _isLoading;
  109863. protected _tasks: AbstractAssetTask[];
  109864. protected _waitingTasksCount: number;
  109865. protected _totalTasksCount: number;
  109866. /**
  109867. * Callback called when all tasks are processed
  109868. */
  109869. onFinish: (tasks: AbstractAssetTask[]) => void;
  109870. /**
  109871. * Callback called when a task is successful
  109872. */
  109873. onTaskSuccess: (task: AbstractAssetTask) => void;
  109874. /**
  109875. * Callback called when a task had an error
  109876. */
  109877. onTaskError: (task: AbstractAssetTask) => void;
  109878. /**
  109879. * Callback called when a task is done (whatever the result is)
  109880. */
  109881. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  109882. /**
  109883. * Observable called when all tasks are processed
  109884. */
  109885. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  109886. /**
  109887. * Observable called when a task had an error
  109888. */
  109889. onTaskErrorObservable: Observable<AbstractAssetTask>;
  109890. /**
  109891. * Observable called when a task is successful
  109892. */
  109893. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  109894. /**
  109895. * Observable called when a task is done (whatever the result is)
  109896. */
  109897. onProgressObservable: Observable<IAssetsProgressEvent>;
  109898. /**
  109899. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  109900. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  109901. */
  109902. useDefaultLoadingScreen: boolean;
  109903. /**
  109904. * Creates a new AssetsManager
  109905. * @param scene defines the scene to work on
  109906. */
  109907. constructor(scene: Scene);
  109908. /**
  109909. * Add a MeshAssetTask to the list of active tasks
  109910. * @param taskName defines the name of the new task
  109911. * @param meshesNames defines the name of meshes to load
  109912. * @param rootUrl defines the root url to use to locate files
  109913. * @param sceneFilename defines the filename of the scene file
  109914. * @returns a new MeshAssetTask object
  109915. */
  109916. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  109917. /**
  109918. * Add a TextFileAssetTask to the list of active tasks
  109919. * @param taskName defines the name of the new task
  109920. * @param url defines the url of the file to load
  109921. * @returns a new TextFileAssetTask object
  109922. */
  109923. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  109924. /**
  109925. * Add a BinaryFileAssetTask to the list of active tasks
  109926. * @param taskName defines the name of the new task
  109927. * @param url defines the url of the file to load
  109928. * @returns a new BinaryFileAssetTask object
  109929. */
  109930. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  109931. /**
  109932. * Add a ImageAssetTask to the list of active tasks
  109933. * @param taskName defines the name of the new task
  109934. * @param url defines the url of the file to load
  109935. * @returns a new ImageAssetTask object
  109936. */
  109937. addImageTask(taskName: string, url: string): ImageAssetTask;
  109938. /**
  109939. * Add a TextureAssetTask to the list of active tasks
  109940. * @param taskName defines the name of the new task
  109941. * @param url defines the url of the file to load
  109942. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  109943. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  109944. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  109945. * @returns a new TextureAssetTask object
  109946. */
  109947. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  109948. /**
  109949. * Add a CubeTextureAssetTask to the list of active tasks
  109950. * @param taskName defines the name of the new task
  109951. * @param url defines the url of the file to load
  109952. * @param extensions defines the extension to use to load the cube map (can be null)
  109953. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  109954. * @param files defines the list of files to load (can be null)
  109955. * @returns a new CubeTextureAssetTask object
  109956. */
  109957. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  109958. /**
  109959. *
  109960. * Add a HDRCubeTextureAssetTask to the list of active tasks
  109961. * @param taskName defines the name of the new task
  109962. * @param url defines the url of the file to load
  109963. * @param size defines the size you want for the cubemap (can be null)
  109964. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  109965. * @param generateHarmonics defines if you want to automatically generate (true by default)
  109966. * @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)
  109967. * @param reserved Internal use only
  109968. * @returns a new HDRCubeTextureAssetTask object
  109969. */
  109970. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  109971. /**
  109972. * Remove a task from the assets manager.
  109973. * @param task the task to remove
  109974. */
  109975. removeTask(task: AbstractAssetTask): void;
  109976. private _decreaseWaitingTasksCount;
  109977. private _runTask;
  109978. /**
  109979. * Reset the AssetsManager and remove all tasks
  109980. * @return the current instance of the AssetsManager
  109981. */
  109982. reset(): AssetsManager;
  109983. /**
  109984. * Start the loading process
  109985. * @return the current instance of the AssetsManager
  109986. */
  109987. load(): AssetsManager;
  109988. }
  109989. }
  109990. declare module BABYLON {
  109991. /**
  109992. * Wrapper class for promise with external resolve and reject.
  109993. */
  109994. export class Deferred<T> {
  109995. /**
  109996. * The promise associated with this deferred object.
  109997. */
  109998. readonly promise: Promise<T>;
  109999. private _resolve;
  110000. private _reject;
  110001. /**
  110002. * The resolve method of the promise associated with this deferred object.
  110003. */
  110004. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  110005. /**
  110006. * The reject method of the promise associated with this deferred object.
  110007. */
  110008. readonly reject: (reason?: any) => void;
  110009. /**
  110010. * Constructor for this deferred object.
  110011. */
  110012. constructor();
  110013. }
  110014. }
  110015. declare module BABYLON {
  110016. /**
  110017. * Class used to help managing file picking and drag'n'drop
  110018. */
  110019. export class FilesInput {
  110020. /**
  110021. * List of files ready to be loaded
  110022. */
  110023. static readonly FilesToLoad: {
  110024. [key: string]: File;
  110025. };
  110026. /**
  110027. * Callback called when a file is processed
  110028. */
  110029. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  110030. private _engine;
  110031. private _currentScene;
  110032. private _sceneLoadedCallback;
  110033. private _progressCallback;
  110034. private _additionalRenderLoopLogicCallback;
  110035. private _textureLoadingCallback;
  110036. private _startingProcessingFilesCallback;
  110037. private _onReloadCallback;
  110038. private _errorCallback;
  110039. private _elementToMonitor;
  110040. private _sceneFileToLoad;
  110041. private _filesToLoad;
  110042. /**
  110043. * Creates a new FilesInput
  110044. * @param engine defines the rendering engine
  110045. * @param scene defines the hosting scene
  110046. * @param sceneLoadedCallback callback called when scene is loaded
  110047. * @param progressCallback callback called to track progress
  110048. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  110049. * @param textureLoadingCallback callback called when a texture is loading
  110050. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  110051. * @param onReloadCallback callback called when a reload is requested
  110052. * @param errorCallback callback call if an error occurs
  110053. */
  110054. 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);
  110055. private _dragEnterHandler;
  110056. private _dragOverHandler;
  110057. private _dropHandler;
  110058. /**
  110059. * Calls this function to listen to drag'n'drop events on a specific DOM element
  110060. * @param elementToMonitor defines the DOM element to track
  110061. */
  110062. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  110063. /**
  110064. * Release all associated resources
  110065. */
  110066. dispose(): void;
  110067. private renderFunction;
  110068. private drag;
  110069. private drop;
  110070. private _traverseFolder;
  110071. private _processFiles;
  110072. /**
  110073. * Load files from a drop event
  110074. * @param event defines the drop event to use as source
  110075. */
  110076. loadFiles(event: any): void;
  110077. private _processReload;
  110078. /**
  110079. * Reload the current scene from the loaded files
  110080. */
  110081. reload(): void;
  110082. }
  110083. }
  110084. declare module BABYLON {
  110085. /**
  110086. * Defines the root class used to create scene optimization to use with SceneOptimizer
  110087. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  110088. */
  110089. export class SceneOptimization {
  110090. /**
  110091. * Defines the priority of this optimization (0 by default which means first in the list)
  110092. */
  110093. priority: number;
  110094. /**
  110095. * Gets a string describing the action executed by the current optimization
  110096. * @returns description string
  110097. */
  110098. getDescription(): string;
  110099. /**
  110100. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  110101. * @param scene defines the current scene where to apply this optimization
  110102. * @param optimizer defines the current optimizer
  110103. * @returns true if everything that can be done was applied
  110104. */
  110105. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  110106. /**
  110107. * Creates the SceneOptimization object
  110108. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  110109. * @param desc defines the description associated with the optimization
  110110. */
  110111. constructor(
  110112. /**
  110113. * Defines the priority of this optimization (0 by default which means first in the list)
  110114. */
  110115. priority?: number);
  110116. }
  110117. /**
  110118. * Defines an optimization used to reduce the size of render target textures
  110119. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  110120. */
  110121. export class TextureOptimization extends SceneOptimization {
  110122. /**
  110123. * Defines the priority of this optimization (0 by default which means first in the list)
  110124. */
  110125. priority: number;
  110126. /**
  110127. * 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
  110128. */
  110129. maximumSize: number;
  110130. /**
  110131. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  110132. */
  110133. step: number;
  110134. /**
  110135. * Gets a string describing the action executed by the current optimization
  110136. * @returns description string
  110137. */
  110138. getDescription(): string;
  110139. /**
  110140. * Creates the TextureOptimization object
  110141. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  110142. * @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
  110143. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  110144. */
  110145. constructor(
  110146. /**
  110147. * Defines the priority of this optimization (0 by default which means first in the list)
  110148. */
  110149. priority?: number,
  110150. /**
  110151. * 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
  110152. */
  110153. maximumSize?: number,
  110154. /**
  110155. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  110156. */
  110157. step?: number);
  110158. /**
  110159. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  110160. * @param scene defines the current scene where to apply this optimization
  110161. * @param optimizer defines the current optimizer
  110162. * @returns true if everything that can be done was applied
  110163. */
  110164. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  110165. }
  110166. /**
  110167. * Defines an optimization used to increase or decrease the rendering resolution
  110168. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  110169. */
  110170. export class HardwareScalingOptimization extends SceneOptimization {
  110171. /**
  110172. * Defines the priority of this optimization (0 by default which means first in the list)
  110173. */
  110174. priority: number;
  110175. /**
  110176. * Defines the maximum scale to use (2 by default)
  110177. */
  110178. maximumScale: number;
  110179. /**
  110180. * Defines the step to use between two passes (0.5 by default)
  110181. */
  110182. step: number;
  110183. private _currentScale;
  110184. private _directionOffset;
  110185. /**
  110186. * Gets a string describing the action executed by the current optimization
  110187. * @return description string
  110188. */
  110189. getDescription(): string;
  110190. /**
  110191. * Creates the HardwareScalingOptimization object
  110192. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  110193. * @param maximumScale defines the maximum scale to use (2 by default)
  110194. * @param step defines the step to use between two passes (0.5 by default)
  110195. */
  110196. constructor(
  110197. /**
  110198. * Defines the priority of this optimization (0 by default which means first in the list)
  110199. */
  110200. priority?: number,
  110201. /**
  110202. * Defines the maximum scale to use (2 by default)
  110203. */
  110204. maximumScale?: number,
  110205. /**
  110206. * Defines the step to use between two passes (0.5 by default)
  110207. */
  110208. step?: number);
  110209. /**
  110210. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  110211. * @param scene defines the current scene where to apply this optimization
  110212. * @param optimizer defines the current optimizer
  110213. * @returns true if everything that can be done was applied
  110214. */
  110215. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  110216. }
  110217. /**
  110218. * Defines an optimization used to remove shadows
  110219. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  110220. */
  110221. export class ShadowsOptimization extends SceneOptimization {
  110222. /**
  110223. * Gets a string describing the action executed by the current optimization
  110224. * @return description string
  110225. */
  110226. getDescription(): string;
  110227. /**
  110228. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  110229. * @param scene defines the current scene where to apply this optimization
  110230. * @param optimizer defines the current optimizer
  110231. * @returns true if everything that can be done was applied
  110232. */
  110233. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  110234. }
  110235. /**
  110236. * Defines an optimization used to turn post-processes off
  110237. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  110238. */
  110239. export class PostProcessesOptimization extends SceneOptimization {
  110240. /**
  110241. * Gets a string describing the action executed by the current optimization
  110242. * @return description string
  110243. */
  110244. getDescription(): string;
  110245. /**
  110246. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  110247. * @param scene defines the current scene where to apply this optimization
  110248. * @param optimizer defines the current optimizer
  110249. * @returns true if everything that can be done was applied
  110250. */
  110251. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  110252. }
  110253. /**
  110254. * Defines an optimization used to turn lens flares off
  110255. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  110256. */
  110257. export class LensFlaresOptimization extends SceneOptimization {
  110258. /**
  110259. * Gets a string describing the action executed by the current optimization
  110260. * @return description string
  110261. */
  110262. getDescription(): string;
  110263. /**
  110264. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  110265. * @param scene defines the current scene where to apply this optimization
  110266. * @param optimizer defines the current optimizer
  110267. * @returns true if everything that can be done was applied
  110268. */
  110269. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  110270. }
  110271. /**
  110272. * Defines an optimization based on user defined callback.
  110273. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  110274. */
  110275. export class CustomOptimization extends SceneOptimization {
  110276. /**
  110277. * Callback called to apply the custom optimization.
  110278. */
  110279. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  110280. /**
  110281. * Callback called to get custom description
  110282. */
  110283. onGetDescription: () => string;
  110284. /**
  110285. * Gets a string describing the action executed by the current optimization
  110286. * @returns description string
  110287. */
  110288. getDescription(): string;
  110289. /**
  110290. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  110291. * @param scene defines the current scene where to apply this optimization
  110292. * @param optimizer defines the current optimizer
  110293. * @returns true if everything that can be done was applied
  110294. */
  110295. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  110296. }
  110297. /**
  110298. * Defines an optimization used to turn particles off
  110299. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  110300. */
  110301. export class ParticlesOptimization extends SceneOptimization {
  110302. /**
  110303. * Gets a string describing the action executed by the current optimization
  110304. * @return description string
  110305. */
  110306. getDescription(): string;
  110307. /**
  110308. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  110309. * @param scene defines the current scene where to apply this optimization
  110310. * @param optimizer defines the current optimizer
  110311. * @returns true if everything that can be done was applied
  110312. */
  110313. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  110314. }
  110315. /**
  110316. * Defines an optimization used to turn render targets off
  110317. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  110318. */
  110319. export class RenderTargetsOptimization extends SceneOptimization {
  110320. /**
  110321. * Gets a string describing the action executed by the current optimization
  110322. * @return description string
  110323. */
  110324. getDescription(): string;
  110325. /**
  110326. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  110327. * @param scene defines the current scene where to apply this optimization
  110328. * @param optimizer defines the current optimizer
  110329. * @returns true if everything that can be done was applied
  110330. */
  110331. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  110332. }
  110333. /**
  110334. * Defines an optimization used to merge meshes with compatible materials
  110335. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  110336. */
  110337. export class MergeMeshesOptimization extends SceneOptimization {
  110338. private static _UpdateSelectionTree;
  110339. /**
  110340. * Gets or sets a boolean which defines if optimization octree has to be updated
  110341. */
  110342. /**
  110343. * Gets or sets a boolean which defines if optimization octree has to be updated
  110344. */
  110345. static UpdateSelectionTree: boolean;
  110346. /**
  110347. * Gets a string describing the action executed by the current optimization
  110348. * @return description string
  110349. */
  110350. getDescription(): string;
  110351. private _canBeMerged;
  110352. /**
  110353. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  110354. * @param scene defines the current scene where to apply this optimization
  110355. * @param optimizer defines the current optimizer
  110356. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  110357. * @returns true if everything that can be done was applied
  110358. */
  110359. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  110360. }
  110361. /**
  110362. * Defines a list of options used by SceneOptimizer
  110363. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  110364. */
  110365. export class SceneOptimizerOptions {
  110366. /**
  110367. * Defines the target frame rate to reach (60 by default)
  110368. */
  110369. targetFrameRate: number;
  110370. /**
  110371. * Defines the interval between two checkes (2000ms by default)
  110372. */
  110373. trackerDuration: number;
  110374. /**
  110375. * Gets the list of optimizations to apply
  110376. */
  110377. optimizations: SceneOptimization[];
  110378. /**
  110379. * Creates a new list of options used by SceneOptimizer
  110380. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  110381. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  110382. */
  110383. constructor(
  110384. /**
  110385. * Defines the target frame rate to reach (60 by default)
  110386. */
  110387. targetFrameRate?: number,
  110388. /**
  110389. * Defines the interval between two checkes (2000ms by default)
  110390. */
  110391. trackerDuration?: number);
  110392. /**
  110393. * Add a new optimization
  110394. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  110395. * @returns the current SceneOptimizerOptions
  110396. */
  110397. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  110398. /**
  110399. * Add a new custom optimization
  110400. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  110401. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  110402. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  110403. * @returns the current SceneOptimizerOptions
  110404. */
  110405. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  110406. /**
  110407. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  110408. * @param targetFrameRate defines the target frame rate (60 by default)
  110409. * @returns a SceneOptimizerOptions object
  110410. */
  110411. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  110412. /**
  110413. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  110414. * @param targetFrameRate defines the target frame rate (60 by default)
  110415. * @returns a SceneOptimizerOptions object
  110416. */
  110417. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  110418. /**
  110419. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  110420. * @param targetFrameRate defines the target frame rate (60 by default)
  110421. * @returns a SceneOptimizerOptions object
  110422. */
  110423. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  110424. }
  110425. /**
  110426. * Class used to run optimizations in order to reach a target frame rate
  110427. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  110428. */
  110429. export class SceneOptimizer implements IDisposable {
  110430. private _isRunning;
  110431. private _options;
  110432. private _scene;
  110433. private _currentPriorityLevel;
  110434. private _targetFrameRate;
  110435. private _trackerDuration;
  110436. private _currentFrameRate;
  110437. private _sceneDisposeObserver;
  110438. private _improvementMode;
  110439. /**
  110440. * Defines an observable called when the optimizer reaches the target frame rate
  110441. */
  110442. onSuccessObservable: Observable<SceneOptimizer>;
  110443. /**
  110444. * Defines an observable called when the optimizer enables an optimization
  110445. */
  110446. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  110447. /**
  110448. * Defines an observable called when the optimizer is not able to reach the target frame rate
  110449. */
  110450. onFailureObservable: Observable<SceneOptimizer>;
  110451. /**
  110452. * Gets a boolean indicating if the optimizer is in improvement mode
  110453. */
  110454. readonly isInImprovementMode: boolean;
  110455. /**
  110456. * Gets the current priority level (0 at start)
  110457. */
  110458. readonly currentPriorityLevel: number;
  110459. /**
  110460. * Gets the current frame rate checked by the SceneOptimizer
  110461. */
  110462. readonly currentFrameRate: number;
  110463. /**
  110464. * Gets or sets the current target frame rate (60 by default)
  110465. */
  110466. /**
  110467. * Gets or sets the current target frame rate (60 by default)
  110468. */
  110469. targetFrameRate: number;
  110470. /**
  110471. * Gets or sets the current interval between two checks (every 2000ms by default)
  110472. */
  110473. /**
  110474. * Gets or sets the current interval between two checks (every 2000ms by default)
  110475. */
  110476. trackerDuration: number;
  110477. /**
  110478. * Gets the list of active optimizations
  110479. */
  110480. readonly optimizations: SceneOptimization[];
  110481. /**
  110482. * Creates a new SceneOptimizer
  110483. * @param scene defines the scene to work on
  110484. * @param options defines the options to use with the SceneOptimizer
  110485. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  110486. * @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)
  110487. */
  110488. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  110489. /**
  110490. * Stops the current optimizer
  110491. */
  110492. stop(): void;
  110493. /**
  110494. * Reset the optimizer to initial step (current priority level = 0)
  110495. */
  110496. reset(): void;
  110497. /**
  110498. * Start the optimizer. By default it will try to reach a specific framerate
  110499. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  110500. */
  110501. start(): void;
  110502. private _checkCurrentState;
  110503. /**
  110504. * Release all resources
  110505. */
  110506. dispose(): void;
  110507. /**
  110508. * Helper function to create a SceneOptimizer with one single line of code
  110509. * @param scene defines the scene to work on
  110510. * @param options defines the options to use with the SceneOptimizer
  110511. * @param onSuccess defines a callback to call on success
  110512. * @param onFailure defines a callback to call on failure
  110513. * @returns the new SceneOptimizer object
  110514. */
  110515. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  110516. }
  110517. }
  110518. declare module BABYLON {
  110519. /**
  110520. * Class used to serialize a scene into a string
  110521. */
  110522. export class SceneSerializer {
  110523. /**
  110524. * Clear cache used by a previous serialization
  110525. */
  110526. static ClearCache(): void;
  110527. /**
  110528. * Serialize a scene into a JSON compatible object
  110529. * @param scene defines the scene to serialize
  110530. * @returns a JSON compatible object
  110531. */
  110532. static Serialize(scene: Scene): any;
  110533. /**
  110534. * Serialize a mesh into a JSON compatible object
  110535. * @param toSerialize defines the mesh to serialize
  110536. * @param withParents defines if parents must be serialized as well
  110537. * @param withChildren defines if children must be serialized as well
  110538. * @returns a JSON compatible object
  110539. */
  110540. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  110541. }
  110542. }
  110543. declare module BABYLON {
  110544. /**
  110545. * This represents the different options avilable for the video capture.
  110546. */
  110547. export interface VideoRecorderOptions {
  110548. /** Defines the mime type of the video */
  110549. mimeType: string;
  110550. /** Defines the video the video should be recorded at */
  110551. fps: number;
  110552. /** Defines the chunk size for the recording data */
  110553. recordChunckSize: number;
  110554. /** The audio tracks to attach to the record */
  110555. audioTracks?: MediaStreamTrack[];
  110556. }
  110557. /**
  110558. * This can helps recording videos from BabylonJS.
  110559. * This is based on the available WebRTC functionalities of the browser.
  110560. *
  110561. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  110562. */
  110563. export class VideoRecorder {
  110564. private static readonly _defaultOptions;
  110565. /**
  110566. * Returns wehther or not the VideoRecorder is available in your browser.
  110567. * @param engine Defines the Babylon Engine to check the support for
  110568. * @returns true if supported otherwise false
  110569. */
  110570. static IsSupported(engine: Engine): boolean;
  110571. private readonly _options;
  110572. private _canvas;
  110573. private _mediaRecorder;
  110574. private _recordedChunks;
  110575. private _fileName;
  110576. private _resolve;
  110577. private _reject;
  110578. /**
  110579. * True wether a recording is already in progress.
  110580. */
  110581. readonly isRecording: boolean;
  110582. /**
  110583. * Create a new VideoCapture object which can help converting what you see in Babylon to
  110584. * a video file.
  110585. * @param engine Defines the BabylonJS Engine you wish to record
  110586. * @param options Defines options that can be used to customized the capture
  110587. */
  110588. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  110589. /**
  110590. * Stops the current recording before the default capture timeout passed in the startRecording
  110591. * functions.
  110592. */
  110593. stopRecording(): void;
  110594. /**
  110595. * Starts recording the canvas for a max duration specified in parameters.
  110596. * @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.
  110597. * @param maxDuration Defines the maximum recording time in seconds.
  110598. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  110599. * @return a promise callback at the end of the recording with the video data in Blob.
  110600. */
  110601. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  110602. /**
  110603. * Releases internal resources used during the recording.
  110604. */
  110605. dispose(): void;
  110606. private _handleDataAvailable;
  110607. private _handleError;
  110608. private _handleStop;
  110609. }
  110610. }
  110611. declare module BABYLON {
  110612. /**
  110613. * Helper class to push actions to a pool of workers.
  110614. */
  110615. export class WorkerPool implements IDisposable {
  110616. private _workerInfos;
  110617. private _pendingActions;
  110618. /**
  110619. * Constructor
  110620. * @param workers Array of workers to use for actions
  110621. */
  110622. constructor(workers: Array<Worker>);
  110623. /**
  110624. * Terminates all workers and clears any pending actions.
  110625. */
  110626. dispose(): void;
  110627. /**
  110628. * Pushes an action to the worker pool. If all the workers are active, the action will be
  110629. * pended until a worker has completed its action.
  110630. * @param action The action to perform. Call onComplete when the action is complete.
  110631. */
  110632. push(action: (worker: Worker, onComplete: () => void) => void): void;
  110633. private _execute;
  110634. }
  110635. }
  110636. declare module BABYLON {
  110637. /**
  110638. * Class containing a set of static utilities functions for screenshots
  110639. */
  110640. export class ScreenshotTools {
  110641. /**
  110642. * Captures a screenshot of the current rendering
  110643. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  110644. * @param engine defines the rendering engine
  110645. * @param camera defines the source camera
  110646. * @param size This parameter can be set to a single number or to an object with the
  110647. * following (optional) properties: precision, width, height. If a single number is passed,
  110648. * it will be used for both width and height. If an object is passed, the screenshot size
  110649. * will be derived from the parameters. The precision property is a multiplier allowing
  110650. * rendering at a higher or lower resolution
  110651. * @param successCallback defines the callback receives a single parameter which contains the
  110652. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  110653. * src parameter of an <img> to display it
  110654. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  110655. * Check your browser for supported MIME types
  110656. */
  110657. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  110658. /**
  110659. * Generates an image screenshot from the specified camera.
  110660. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  110661. * @param engine The engine to use for rendering
  110662. * @param camera The camera to use for rendering
  110663. * @param size This parameter can be set to a single number or to an object with the
  110664. * following (optional) properties: precision, width, height. If a single number is passed,
  110665. * it will be used for both width and height. If an object is passed, the screenshot size
  110666. * will be derived from the parameters. The precision property is a multiplier allowing
  110667. * rendering at a higher or lower resolution
  110668. * @param successCallback The callback receives a single parameter which contains the
  110669. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  110670. * src parameter of an <img> to display it
  110671. * @param mimeType The MIME type of the screenshot image (default: image/png).
  110672. * Check your browser for supported MIME types
  110673. * @param samples Texture samples (default: 1)
  110674. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  110675. * @param fileName A name for for the downloaded file.
  110676. */
  110677. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  110678. }
  110679. }
  110680. declare module BABYLON {
  110681. /**
  110682. * A cursor which tracks a point on a path
  110683. */
  110684. export class PathCursor {
  110685. private path;
  110686. /**
  110687. * Stores path cursor callbacks for when an onchange event is triggered
  110688. */
  110689. private _onchange;
  110690. /**
  110691. * The value of the path cursor
  110692. */
  110693. value: number;
  110694. /**
  110695. * The animation array of the path cursor
  110696. */
  110697. animations: Animation[];
  110698. /**
  110699. * Initializes the path cursor
  110700. * @param path The path to track
  110701. */
  110702. constructor(path: Path2);
  110703. /**
  110704. * Gets the cursor point on the path
  110705. * @returns A point on the path cursor at the cursor location
  110706. */
  110707. getPoint(): Vector3;
  110708. /**
  110709. * Moves the cursor ahead by the step amount
  110710. * @param step The amount to move the cursor forward
  110711. * @returns This path cursor
  110712. */
  110713. moveAhead(step?: number): PathCursor;
  110714. /**
  110715. * Moves the cursor behind by the step amount
  110716. * @param step The amount to move the cursor back
  110717. * @returns This path cursor
  110718. */
  110719. moveBack(step?: number): PathCursor;
  110720. /**
  110721. * Moves the cursor by the step amount
  110722. * If the step amount is greater than one, an exception is thrown
  110723. * @param step The amount to move the cursor
  110724. * @returns This path cursor
  110725. */
  110726. move(step: number): PathCursor;
  110727. /**
  110728. * Ensures that the value is limited between zero and one
  110729. * @returns This path cursor
  110730. */
  110731. private ensureLimits;
  110732. /**
  110733. * Runs onchange callbacks on change (used by the animation engine)
  110734. * @returns This path cursor
  110735. */
  110736. private raiseOnChange;
  110737. /**
  110738. * Executes a function on change
  110739. * @param f A path cursor onchange callback
  110740. * @returns This path cursor
  110741. */
  110742. onchange(f: (cursor: PathCursor) => void): PathCursor;
  110743. }
  110744. }
  110745. declare module BABYLON {
  110746. /** @hidden */
  110747. export var blurPixelShader: {
  110748. name: string;
  110749. shader: string;
  110750. };
  110751. }
  110752. declare module BABYLON {
  110753. /** @hidden */
  110754. export var bones300Declaration: {
  110755. name: string;
  110756. shader: string;
  110757. };
  110758. }
  110759. declare module BABYLON {
  110760. /** @hidden */
  110761. export var instances300Declaration: {
  110762. name: string;
  110763. shader: string;
  110764. };
  110765. }
  110766. declare module BABYLON {
  110767. /** @hidden */
  110768. export var pointCloudVertexDeclaration: {
  110769. name: string;
  110770. shader: string;
  110771. };
  110772. }
  110773. // Mixins
  110774. interface Window {
  110775. mozIndexedDB: IDBFactory;
  110776. webkitIndexedDB: IDBFactory;
  110777. msIndexedDB: IDBFactory;
  110778. webkitURL: typeof URL;
  110779. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  110780. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  110781. WebGLRenderingContext: WebGLRenderingContext;
  110782. MSGesture: MSGesture;
  110783. CANNON: any;
  110784. AudioContext: AudioContext;
  110785. webkitAudioContext: AudioContext;
  110786. PointerEvent: any;
  110787. Math: Math;
  110788. Uint8Array: Uint8ArrayConstructor;
  110789. Float32Array: Float32ArrayConstructor;
  110790. mozURL: typeof URL;
  110791. msURL: typeof URL;
  110792. VRFrameData: any; // WebVR, from specs 1.1
  110793. DracoDecoderModule: any;
  110794. setImmediate(handler: (...args: any[]) => void): number;
  110795. }
  110796. interface Document {
  110797. mozCancelFullScreen(): void;
  110798. msCancelFullScreen(): void;
  110799. webkitCancelFullScreen(): void;
  110800. requestPointerLock(): void;
  110801. exitPointerLock(): void;
  110802. mozFullScreen: boolean;
  110803. msIsFullScreen: boolean;
  110804. readonly webkitIsFullScreen: boolean;
  110805. readonly pointerLockElement: Element;
  110806. mozPointerLockElement: HTMLElement;
  110807. msPointerLockElement: HTMLElement;
  110808. webkitPointerLockElement: HTMLElement;
  110809. }
  110810. interface HTMLCanvasElement {
  110811. requestPointerLock(): void;
  110812. msRequestPointerLock?(): void;
  110813. mozRequestPointerLock?(): void;
  110814. webkitRequestPointerLock?(): void;
  110815. /** Track wether a record is in progress */
  110816. isRecording: boolean;
  110817. /** Capture Stream method defined by some browsers */
  110818. captureStream(fps?: number): MediaStream;
  110819. }
  110820. interface CanvasRenderingContext2D {
  110821. msImageSmoothingEnabled: boolean;
  110822. }
  110823. interface MouseEvent {
  110824. mozMovementX: number;
  110825. mozMovementY: number;
  110826. webkitMovementX: number;
  110827. webkitMovementY: number;
  110828. msMovementX: number;
  110829. msMovementY: number;
  110830. }
  110831. interface Navigator {
  110832. mozGetVRDevices: (any: any) => any;
  110833. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  110834. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  110835. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  110836. webkitGetGamepads(): Gamepad[];
  110837. msGetGamepads(): Gamepad[];
  110838. webkitGamepads(): Gamepad[];
  110839. }
  110840. interface HTMLVideoElement {
  110841. mozSrcObject: any;
  110842. }
  110843. interface Math {
  110844. fround(x: number): number;
  110845. imul(a: number, b: number): number;
  110846. }
  110847. interface WebGLProgram {
  110848. context?: WebGLRenderingContext;
  110849. vertexShader?: WebGLShader;
  110850. fragmentShader?: WebGLShader;
  110851. isParallelCompiled: boolean;
  110852. onCompiled?: () => void;
  110853. }
  110854. interface WebGLRenderingContext {
  110855. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  110856. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  110857. vertexAttribDivisor(index: number, divisor: number): void;
  110858. createVertexArray(): any;
  110859. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  110860. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  110861. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  110862. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  110863. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  110864. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  110865. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  110866. // Queries
  110867. createQuery(): WebGLQuery;
  110868. deleteQuery(query: WebGLQuery): void;
  110869. beginQuery(target: number, query: WebGLQuery): void;
  110870. endQuery(target: number): void;
  110871. getQueryParameter(query: WebGLQuery, pname: number): any;
  110872. getQuery(target: number, pname: number): any;
  110873. MAX_SAMPLES: number;
  110874. RGBA8: number;
  110875. READ_FRAMEBUFFER: number;
  110876. DRAW_FRAMEBUFFER: number;
  110877. UNIFORM_BUFFER: number;
  110878. HALF_FLOAT_OES: number;
  110879. RGBA16F: number;
  110880. RGBA32F: number;
  110881. R32F: number;
  110882. RG32F: number;
  110883. RGB32F: number;
  110884. R16F: number;
  110885. RG16F: number;
  110886. RGB16F: number;
  110887. RED: number;
  110888. RG: number;
  110889. R8: number;
  110890. RG8: number;
  110891. UNSIGNED_INT_24_8: number;
  110892. DEPTH24_STENCIL8: number;
  110893. /* Multiple Render Targets */
  110894. drawBuffers(buffers: number[]): void;
  110895. readBuffer(src: number): void;
  110896. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  110897. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  110898. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  110899. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  110900. // Occlusion Query
  110901. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  110902. ANY_SAMPLES_PASSED: number;
  110903. QUERY_RESULT_AVAILABLE: number;
  110904. QUERY_RESULT: number;
  110905. }
  110906. interface WebGLBuffer {
  110907. references: number;
  110908. capacity: number;
  110909. is32Bits: boolean;
  110910. }
  110911. interface WebGLProgram {
  110912. transformFeedback?: WebGLTransformFeedback | null;
  110913. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  110914. }
  110915. interface EXT_disjoint_timer_query {
  110916. QUERY_COUNTER_BITS_EXT: number;
  110917. TIME_ELAPSED_EXT: number;
  110918. TIMESTAMP_EXT: number;
  110919. GPU_DISJOINT_EXT: number;
  110920. QUERY_RESULT_EXT: number;
  110921. QUERY_RESULT_AVAILABLE_EXT: number;
  110922. queryCounterEXT(query: WebGLQuery, target: number): void;
  110923. createQueryEXT(): WebGLQuery;
  110924. beginQueryEXT(target: number, query: WebGLQuery): void;
  110925. endQueryEXT(target: number): void;
  110926. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  110927. deleteQueryEXT(query: WebGLQuery): void;
  110928. }
  110929. interface WebGLUniformLocation {
  110930. _currentState: any;
  110931. }
  110932. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  110933. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  110934. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  110935. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  110936. interface WebGLRenderingContext {
  110937. readonly RASTERIZER_DISCARD: number;
  110938. readonly DEPTH_COMPONENT24: number;
  110939. readonly TEXTURE_3D: number;
  110940. readonly TEXTURE_2D_ARRAY: number;
  110941. readonly TEXTURE_COMPARE_FUNC: number;
  110942. readonly TEXTURE_COMPARE_MODE: number;
  110943. readonly COMPARE_REF_TO_TEXTURE: number;
  110944. readonly TEXTURE_WRAP_R: number;
  110945. readonly HALF_FLOAT: number;
  110946. readonly RGB8: number;
  110947. readonly RED_INTEGER: number;
  110948. readonly RG_INTEGER: number;
  110949. readonly RGB_INTEGER: number;
  110950. readonly RGBA_INTEGER: number;
  110951. readonly R8_SNORM: number;
  110952. readonly RG8_SNORM: number;
  110953. readonly RGB8_SNORM: number;
  110954. readonly RGBA8_SNORM: number;
  110955. readonly R8I: number;
  110956. readonly RG8I: number;
  110957. readonly RGB8I: number;
  110958. readonly RGBA8I: number;
  110959. readonly R8UI: number;
  110960. readonly RG8UI: number;
  110961. readonly RGB8UI: number;
  110962. readonly RGBA8UI: number;
  110963. readonly R16I: number;
  110964. readonly RG16I: number;
  110965. readonly RGB16I: number;
  110966. readonly RGBA16I: number;
  110967. readonly R16UI: number;
  110968. readonly RG16UI: number;
  110969. readonly RGB16UI: number;
  110970. readonly RGBA16UI: number;
  110971. readonly R32I: number;
  110972. readonly RG32I: number;
  110973. readonly RGB32I: number;
  110974. readonly RGBA32I: number;
  110975. readonly R32UI: number;
  110976. readonly RG32UI: number;
  110977. readonly RGB32UI: number;
  110978. readonly RGBA32UI: number;
  110979. readonly RGB10_A2UI: number;
  110980. readonly R11F_G11F_B10F: number;
  110981. readonly RGB9_E5: number;
  110982. readonly RGB10_A2: number;
  110983. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  110984. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  110985. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  110986. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  110987. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  110988. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  110989. 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;
  110990. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  110991. readonly TRANSFORM_FEEDBACK: number;
  110992. readonly INTERLEAVED_ATTRIBS: number;
  110993. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  110994. createTransformFeedback(): WebGLTransformFeedback;
  110995. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  110996. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  110997. beginTransformFeedback(primitiveMode: number): void;
  110998. endTransformFeedback(): void;
  110999. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  111000. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  111001. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  111002. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  111003. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  111004. }
  111005. interface ImageBitmap {
  111006. readonly width: number;
  111007. readonly height: number;
  111008. close(): void;
  111009. }
  111010. interface WebGLQuery extends WebGLObject {
  111011. }
  111012. declare var WebGLQuery: {
  111013. prototype: WebGLQuery;
  111014. new(): WebGLQuery;
  111015. };
  111016. interface WebGLSampler extends WebGLObject {
  111017. }
  111018. declare var WebGLSampler: {
  111019. prototype: WebGLSampler;
  111020. new(): WebGLSampler;
  111021. };
  111022. interface WebGLSync extends WebGLObject {
  111023. }
  111024. declare var WebGLSync: {
  111025. prototype: WebGLSync;
  111026. new(): WebGLSync;
  111027. };
  111028. interface WebGLTransformFeedback extends WebGLObject {
  111029. }
  111030. declare var WebGLTransformFeedback: {
  111031. prototype: WebGLTransformFeedback;
  111032. new(): WebGLTransformFeedback;
  111033. };
  111034. interface WebGLVertexArrayObject extends WebGLObject {
  111035. }
  111036. declare var WebGLVertexArrayObject: {
  111037. prototype: WebGLVertexArrayObject;
  111038. new(): WebGLVertexArrayObject;
  111039. };
  111040. // Type definitions for WebVR API
  111041. // Project: https://w3c.github.io/webvr/
  111042. // Definitions by: six a <https://github.com/lostfictions>
  111043. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  111044. interface VRDisplay extends EventTarget {
  111045. /**
  111046. * Dictionary of capabilities describing the VRDisplay.
  111047. */
  111048. readonly capabilities: VRDisplayCapabilities;
  111049. /**
  111050. * z-depth defining the far plane of the eye view frustum
  111051. * enables mapping of values in the render target depth
  111052. * attachment to scene coordinates. Initially set to 10000.0.
  111053. */
  111054. depthFar: number;
  111055. /**
  111056. * z-depth defining the near plane of the eye view frustum
  111057. * enables mapping of values in the render target depth
  111058. * attachment to scene coordinates. Initially set to 0.01.
  111059. */
  111060. depthNear: number;
  111061. /**
  111062. * An identifier for this distinct VRDisplay. Used as an
  111063. * association point in the Gamepad API.
  111064. */
  111065. readonly displayId: number;
  111066. /**
  111067. * A display name, a user-readable name identifying it.
  111068. */
  111069. readonly displayName: string;
  111070. readonly isConnected: boolean;
  111071. readonly isPresenting: boolean;
  111072. /**
  111073. * If this VRDisplay supports room-scale experiences, the optional
  111074. * stage attribute contains details on the room-scale parameters.
  111075. */
  111076. readonly stageParameters: VRStageParameters | null;
  111077. /**
  111078. * Passing the value returned by `requestAnimationFrame` to
  111079. * `cancelAnimationFrame` will unregister the callback.
  111080. * @param handle Define the hanle of the request to cancel
  111081. */
  111082. cancelAnimationFrame(handle: number): void;
  111083. /**
  111084. * Stops presenting to the VRDisplay.
  111085. * @returns a promise to know when it stopped
  111086. */
  111087. exitPresent(): Promise<void>;
  111088. /**
  111089. * Return the current VREyeParameters for the given eye.
  111090. * @param whichEye Define the eye we want the parameter for
  111091. * @returns the eye parameters
  111092. */
  111093. getEyeParameters(whichEye: string): VREyeParameters;
  111094. /**
  111095. * Populates the passed VRFrameData with the information required to render
  111096. * the current frame.
  111097. * @param frameData Define the data structure to populate
  111098. * @returns true if ok otherwise false
  111099. */
  111100. getFrameData(frameData: VRFrameData): boolean;
  111101. /**
  111102. * Get the layers currently being presented.
  111103. * @returns the list of VR layers
  111104. */
  111105. getLayers(): VRLayer[];
  111106. /**
  111107. * Return a VRPose containing the future predicted pose of the VRDisplay
  111108. * when the current frame will be presented. The value returned will not
  111109. * change until JavaScript has returned control to the browser.
  111110. *
  111111. * The VRPose will contain the position, orientation, velocity,
  111112. * and acceleration of each of these properties.
  111113. * @returns the pose object
  111114. */
  111115. getPose(): VRPose;
  111116. /**
  111117. * Return the current instantaneous pose of the VRDisplay, with no
  111118. * prediction applied.
  111119. * @returns the current instantaneous pose
  111120. */
  111121. getImmediatePose(): VRPose;
  111122. /**
  111123. * The callback passed to `requestAnimationFrame` will be called
  111124. * any time a new frame should be rendered. When the VRDisplay is
  111125. * presenting the callback will be called at the native refresh
  111126. * rate of the HMD. When not presenting this function acts
  111127. * identically to how window.requestAnimationFrame acts. Content should
  111128. * make no assumptions of frame rate or vsync behavior as the HMD runs
  111129. * asynchronously from other displays and at differing refresh rates.
  111130. * @param callback Define the eaction to run next frame
  111131. * @returns the request handle it
  111132. */
  111133. requestAnimationFrame(callback: FrameRequestCallback): number;
  111134. /**
  111135. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  111136. * Repeat calls while already presenting will update the VRLayers being displayed.
  111137. * @param layers Define the list of layer to present
  111138. * @returns a promise to know when the request has been fulfilled
  111139. */
  111140. requestPresent(layers: VRLayer[]): Promise<void>;
  111141. /**
  111142. * Reset the pose for this display, treating its current position and
  111143. * orientation as the "origin/zero" values. VRPose.position,
  111144. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  111145. * updated when calling resetPose(). This should be called in only
  111146. * sitting-space experiences.
  111147. */
  111148. resetPose(): void;
  111149. /**
  111150. * The VRLayer provided to the VRDisplay will be captured and presented
  111151. * in the HMD. Calling this function has the same effect on the source
  111152. * canvas as any other operation that uses its source image, and canvases
  111153. * created without preserveDrawingBuffer set to true will be cleared.
  111154. * @param pose Define the pose to submit
  111155. */
  111156. submitFrame(pose?: VRPose): void;
  111157. }
  111158. declare var VRDisplay: {
  111159. prototype: VRDisplay;
  111160. new(): VRDisplay;
  111161. };
  111162. interface VRLayer {
  111163. leftBounds?: number[] | Float32Array | null;
  111164. rightBounds?: number[] | Float32Array | null;
  111165. source?: HTMLCanvasElement | null;
  111166. }
  111167. interface VRDisplayCapabilities {
  111168. readonly canPresent: boolean;
  111169. readonly hasExternalDisplay: boolean;
  111170. readonly hasOrientation: boolean;
  111171. readonly hasPosition: boolean;
  111172. readonly maxLayers: number;
  111173. }
  111174. interface VREyeParameters {
  111175. /** @deprecated */
  111176. readonly fieldOfView: VRFieldOfView;
  111177. readonly offset: Float32Array;
  111178. readonly renderHeight: number;
  111179. readonly renderWidth: number;
  111180. }
  111181. interface VRFieldOfView {
  111182. readonly downDegrees: number;
  111183. readonly leftDegrees: number;
  111184. readonly rightDegrees: number;
  111185. readonly upDegrees: number;
  111186. }
  111187. interface VRFrameData {
  111188. readonly leftProjectionMatrix: Float32Array;
  111189. readonly leftViewMatrix: Float32Array;
  111190. readonly pose: VRPose;
  111191. readonly rightProjectionMatrix: Float32Array;
  111192. readonly rightViewMatrix: Float32Array;
  111193. readonly timestamp: number;
  111194. }
  111195. interface VRPose {
  111196. readonly angularAcceleration: Float32Array | null;
  111197. readonly angularVelocity: Float32Array | null;
  111198. readonly linearAcceleration: Float32Array | null;
  111199. readonly linearVelocity: Float32Array | null;
  111200. readonly orientation: Float32Array | null;
  111201. readonly position: Float32Array | null;
  111202. readonly timestamp: number;
  111203. }
  111204. interface VRStageParameters {
  111205. sittingToStandingTransform?: Float32Array;
  111206. sizeX?: number;
  111207. sizeY?: number;
  111208. }
  111209. interface Navigator {
  111210. getVRDisplays(): Promise<VRDisplay[]>;
  111211. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  111212. }
  111213. interface Window {
  111214. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  111215. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  111216. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  111217. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  111218. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  111219. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  111220. }
  111221. interface Gamepad {
  111222. readonly displayId: number;
  111223. }
  111224. interface XRDevice {
  111225. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  111226. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  111227. }
  111228. interface XRSession {
  111229. getInputSources(): Array<any>;
  111230. baseLayer: XRWebGLLayer;
  111231. requestFrameOfReference(type: string): Promise<void>;
  111232. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  111233. end(): Promise<void>;
  111234. requestAnimationFrame: Function;
  111235. addEventListener: Function;
  111236. }
  111237. interface XRSessionCreationOptions {
  111238. outputContext?: WebGLRenderingContext | null;
  111239. immersive?: boolean;
  111240. environmentIntegration?: boolean;
  111241. }
  111242. interface XRLayer {
  111243. getViewport: Function;
  111244. framebufferWidth: number;
  111245. framebufferHeight: number;
  111246. }
  111247. interface XRView {
  111248. projectionMatrix: Float32Array;
  111249. }
  111250. interface XRFrame {
  111251. getDevicePose: Function;
  111252. getInputPose: Function;
  111253. views: Array<XRView>;
  111254. baseLayer: XRLayer;
  111255. }
  111256. interface XRFrameOfReference {
  111257. }
  111258. interface XRWebGLLayer extends XRLayer {
  111259. framebuffer: WebGLFramebuffer;
  111260. }
  111261. declare var XRWebGLLayer: {
  111262. prototype: XRWebGLLayer;
  111263. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  111264. };